import { useEffect } from 'react'; import { useTranslation } from 'react-i18next'; import { AlertTriangle } from 'lucide-react'; import { Card, CardContent } from './Card'; import { Button } from './Button'; interface AlertModalProps { title: string; message: string; /** Optional secondary line shown above the message — e.g. the file the * alert is about. */ subtitle?: string; closeText?: string; variant?: 'error' | 'warning'; onClose: () => void; } /** * A small acknowledge-only modal: title, message, single Close button. * * Use it to surface something the user must read and act on, where a toast * would auto-dismiss before it can be read (e.g. a slicer rejection message). * For confirm/cancel decisions use ConfirmModal instead. */ export function AlertModal({ title, message, subtitle, closeText, variant = 'error', onClose, }: AlertModalProps) { const { t } = useTranslation(); const resolvedCloseText = closeText ?? t('common.close'); // Close on Escape — matches ConfirmModal's behaviour. useEffect(() => { const handleKeyDown = (e: KeyboardEvent) => { if (e.key === 'Escape') onClose(); }; window.addEventListener('keydown', handleKeyDown); return () => window.removeEventListener('keydown', handleKeyDown); }, [onClose]); const iconColor = variant === 'warning' ? 'text-yellow-400' : 'text-red-400'; return (
e.stopPropagation()}>

{title}

{subtitle &&

{subtitle}

}

{message}

); }