import { useEffect, useRef } from 'react'; interface ConfirmationModalProps { isOpen: boolean; onClose: () => void; onConfirm: () => void; title: string; message: string; confirmText?: string; cancelText?: string; confirmColor?: 'blue' | 'red' | 'green' | 'purple'; isLoading?: boolean; } export default function ConfirmationModal({ isOpen, onClose, onConfirm, title, message, confirmText = 'Confirm', cancelText = 'Cancel', confirmColor = 'blue', isLoading = false, }: ConfirmationModalProps) { const modalRef = useRef(null); const confirmButtonRef = useRef(null); useEffect(() => { if (isOpen) { confirmButtonRef.current?.focus(); document.body.style.overflow = 'hidden'; } else { document.body.style.overflow = ''; } return () => { document.body.style.overflow = ''; }; }, [isOpen]); useEffect(() => { const handleEscape = (e: KeyboardEvent) => { if (e.key === 'Escape' && isOpen) { onClose(); } }; document.addEventListener('keydown', handleEscape); return () => document.removeEventListener('keydown', handleEscape); }, [isOpen, onClose]); if (!isOpen) return null; const colorClasses = { blue: 'bg-blue-600 hover:bg-blue-700 focus:ring-blue-500', red: 'bg-red-600 hover:bg-red-700 focus:ring-red-500', green: 'bg-green-600 hover:bg-green-700 focus:ring-green-500', purple: 'bg-purple-600 hover:bg-purple-700 focus:ring-purple-500', }; return (
e.stopPropagation()} >

{message}

); }