'use client'; import { useEffect } from 'react'; import { AlertTriangle, AlertCircle, Info, Loader2, X } from 'lucide-react'; import { cn } from '@/lib/utils'; 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) { useEffect(() => { if (!isOpen) return; const onKey = (e: KeyboardEvent) => { if (e.key === 'Escape') onClose(); }; document.addEventListener('keydown', onKey); return () => document.removeEventListener('keydown', onKey); }, [isOpen, onClose]); useEffect(() => { document.body.style.overflow = isOpen ? 'hidden' : 'unset'; return () => { document.body.style.overflow = 'unset'; }; }, [isOpen]); if (!isOpen) return null; return (
{/* Backdrop */}
{/* Panel */}
{/* Top accent */}
{/* Header */}
{isDanger ? : }

{title}

{!isLoading && ( )}
{/* Body */}

{message}

{warning && (

{warning}

)} {error && (

{error}

)}
{/* Footer */}
{cancelText} {confirmText}
); }