// ConfirmationModal - Reusable confirmation dialog component function ConfirmationModal({ title = 'Conferma', message, confirmText = 'Conferma', cancelText = 'Annulla', variant = 'danger', // 'danger' | 'warning' | 'info' | 'success' onConfirm, onCancel, loading = false }) { const variantStyles = { danger: { icon: ( ), iconBg: 'bg-red-100', iconColor: 'text-red-600', buttonBg: 'bg-red-500 hover:bg-red-600', }, warning: { icon: ( ), iconBg: 'bg-amber-100', iconColor: 'text-amber-600', buttonBg: 'bg-amber-500 hover:bg-amber-600', }, info: { icon: ( ), iconBg: 'bg-blue-100', iconColor: 'text-blue-600', buttonBg: 'bg-blue-500 hover:bg-blue-600', }, success: { icon: ( ), iconBg: 'bg-green-100', iconColor: 'text-green-600', buttonBg: 'bg-green-500 hover:bg-green-600', }, }; const style = variantStyles[variant] || variantStyles.danger; // Handle escape key React.useEffect(() => { const handleKeyDown = (e) => { if (e.key === 'Escape' && !loading) { onCancel(); } }; window.addEventListener('keydown', handleKeyDown); return () => window.removeEventListener('keydown', handleKeyDown); }, [onCancel, loading]); return (
{ if (e.target === e.currentTarget && !loading) { onCancel(); } }} >
e.stopPropagation()} >
{/* Icon */}
{style.icon}
{/* Title */}

{title}

{/* Message */}

{message}

{/* Actions */}
); } window.ConfirmationModal = ConfirmationModal;