import { AlertTriangle, CheckCircle, XCircle, Info } from 'lucide-react'; import { createPortal } from 'react-dom'; import { useTranslation } from 'react-i18next'; export type ModalType = 'confirm' | 'success' | 'error' | 'info'; interface ModalDialogProps { isOpen: boolean; title: string; message?: string; children?: React.ReactNode; type?: ModalType; onConfirm: () => void; onCancel?: () => void; confirmText?: string; cancelText?: string; isDestructive?: boolean; } export default function ModalDialog({ isOpen, title, message, children, type = 'confirm', onConfirm, onCancel, confirmText, cancelText, isDestructive = false }: ModalDialogProps) { const { t } = useTranslation(); const finalConfirmText = confirmText || t('common.confirm'); const finalCancelText = cancelText || t('common.cancel'); if (!isOpen) return null; const getIcon = () => { switch (type) { case 'success': return ; case 'error': return ; case 'info': return ; case 'confirm': default: return isDestructive ? : ; } }; const getIconBg = () => { switch (type) { case 'success': return 'bg-green-50 dark:bg-green-900/20'; case 'error': return 'bg-red-50 dark:bg-red-900/20'; case 'info': return 'bg-blue-50 dark:bg-blue-900/20'; case 'confirm': default: return isDestructive ? 'bg-red-50 dark:bg-red-900/20' : 'bg-blue-50 dark:bg-blue-900/20'; } }; const showCancel = type === 'confirm' && onCancel; return createPortal(
{/* Draggable Top Region */}
{getIcon()}

{title}

{children ? (
{children}
) : (

{message}

)}
{showCancel && ( )}
, document.body ); }