import React, { useEffect, useRef } from 'react'; import { X } from 'lucide-react'; interface ModalProps { isOpen: boolean; onClose: () => void; title: string; children: React.ReactNode; primaryAction?: { label: string; onClick: () => void; danger?: boolean; }; secondaryAction?: { label: string; onClick: () => void; }; } export default function Modal({ isOpen, onClose, title, children, primaryAction, secondaryAction }: ModalProps) { const modalRef = useRef(null); useEffect(() => { const handleEscape = (e: KeyboardEvent) => { if (e.key === 'Escape') onClose(); }; if (isOpen) { document.addEventListener('keydown', handleEscape); document.body.style.overflow = 'hidden'; } return () => { document.removeEventListener('keydown', handleEscape); document.body.style.overflow = 'unset'; }; }, [isOpen, onClose]); if (!isOpen) return null; return (
e.stopPropagation()} >

{title}

{children}
{secondaryAction && ( )} {primaryAction && ( )}
); }