import { AlertTriangle, Info } from 'lucide-react'; import type { ReactNode } from 'react'; import { Button } from '@/components/ui/button'; import { Dialog, DialogContent, DialogDescription, DialogFooter, DialogHeader, DialogTitle, } from '@/components/ui/dialog'; import { cn } from '@/lib/utils'; type ConfirmationDialogTone = 'danger' | 'warning' | 'info'; interface ConfirmationDialogProps { readonly open: boolean; readonly title: string; readonly description: ReactNode; readonly confirmLabel: string; readonly cancelLabel?: string; readonly loading?: boolean; readonly loadingLabel?: string; readonly disabled?: boolean; readonly tone?: ConfirmationDialogTone; readonly icon?: ReactNode; readonly onCancel: () => void; readonly onConfirm: () => void; } const toneClasses: Record = { danger: { panelAccent: 'from-red-500/12 via-rose-500/8 to-transparent border-red-500/20', iconWrap: 'border-red-500/30 bg-gradient-to-br from-red-500/25 to-rose-600/15 text-red-200 shadow-red-500/20', confirmButton: 'bg-gradient-to-r from-red-500 to-rose-600 text-white hover:from-red-400 hover:to-rose-500 shadow-lg shadow-red-500/20', }, warning: { panelAccent: 'from-amber-500/12 via-orange-500/8 to-transparent border-amber-500/20', iconWrap: 'border-amber-500/30 bg-gradient-to-br from-amber-400/25 to-orange-500/15 text-amber-200 shadow-amber-500/20', confirmButton: 'bg-gradient-to-r from-amber-400 to-orange-500 text-slate-950 hover:from-amber-300 hover:to-orange-400 shadow-lg shadow-amber-500/20', }, info: { panelAccent: 'from-blue-500/12 via-cyan-500/8 to-transparent border-blue-500/20', iconWrap: 'border-blue-500/30 bg-gradient-to-br from-blue-500/25 to-cyan-500/15 text-blue-200 shadow-blue-500/20', confirmButton: 'bg-gradient-to-r from-blue-500 to-cyan-500 text-white hover:from-blue-400 hover:to-cyan-400 shadow-lg shadow-blue-500/20', }, }; export function ConfirmationDialog({ open, title, description, confirmLabel, cancelLabel = 'Cancel', loading = false, loadingLabel, disabled = false, tone = 'danger', icon, onCancel, onConfirm, }: ConfirmationDialogProps) { const fallbackIcon = tone === 'info' ? : ; const classes = toneClasses[tone]; return ( { if (!nextOpen && !loading) { onCancel(); } }} >
{icon ?? fallbackIcon}
{title} {description}
); }