mirror of
https://github.com/Tria-plc/edr-platform.git
synced 2026-08-29 17:38:12 +00:00
74 lines
2.3 KiB
TypeScript
74 lines
2.3 KiB
TypeScript
'use client';
|
|
|
|
import { AlertCircle, AlertTriangle } from 'lucide-react';
|
|
import Modal from './Modal';
|
|
import ActionButton from './ActionButton'
|
|
|
|
interface ConfirmDialogProps {
|
|
isOpen: boolean;
|
|
onClose: () => void;
|
|
onConfirm: () => void;
|
|
title: string;
|
|
message: string;
|
|
confirmText?: string;
|
|
cancelText?: string;
|
|
isLoading?: boolean;
|
|
isDanger?: boolean;
|
|
warning?: string;
|
|
error?: string;
|
|
}
|
|
|
|
export default function ConfirmDialog({
|
|
isOpen,
|
|
onClose,
|
|
onConfirm,
|
|
title,
|
|
message,
|
|
confirmText = 'Confirm',
|
|
cancelText = 'Cancel',
|
|
isLoading = false,
|
|
isDanger = false,
|
|
warning,
|
|
error,
|
|
}: ConfirmDialogProps) {
|
|
return (
|
|
<Modal isOpen={isOpen} onClose={onClose} title={title} size="sm">
|
|
<div className="space-y-4">
|
|
<div className="flex gap-3">
|
|
{isDanger && (
|
|
<AlertCircle className="h-6 w-6 text-red-600 dark:text-red-400 flex-shrink-0 mt-0.5" />
|
|
)}
|
|
<p className="text-foreground">{message}</p>
|
|
</div>
|
|
{warning && (
|
|
<div className="rounded-lg bg-amber-50 dark:bg-amber-900/20 border border-amber-200 dark:border-amber-800 p-3 flex gap-3">
|
|
<AlertTriangle className="h-5 w-5 text-amber-600 dark:text-amber-400 flex-shrink-0 mt-0.5" />
|
|
<div>
|
|
<p className="font-semibold text-amber-900 dark:text-amber-200 text-sm">Warning</p>
|
|
<p className="text-amber-800 dark:text-amber-300 text-sm mt-1">{warning}</p>
|
|
</div>
|
|
</div>
|
|
)}
|
|
{error && (
|
|
<div className="rounded-lg bg-red-50 dark:bg-red-900/20 border border-red-200 dark:border-red-800 p-3 flex gap-3">
|
|
<AlertCircle className="h-5 w-5 text-red-600 dark:text-red-400 flex-shrink-0 mt-0.5" />
|
|
<p className="text-red-800 dark:text-red-300 text-sm">{error}</p>
|
|
</div>
|
|
)}
|
|
<div className="flex justify-end gap-2 pt-4">
|
|
<ActionButton variant="secondary" onClick={onClose} disabled={isLoading}>
|
|
{cancelText}
|
|
</ActionButton>
|
|
<ActionButton
|
|
variant={isDanger ? 'danger' : 'primary'}
|
|
onClick={onConfirm}
|
|
disabled={isLoading}
|
|
>
|
|
{isLoading ? 'Processing...' : confirmText}
|
|
</ActionButton>
|
|
</div>
|
|
</div>
|
|
</Modal>
|
|
);
|
|
}
|