"use client"; import { useEffect, useRef } from "react"; import { cn } from "@/lib/utils"; import { X } from "lucide-react"; interface ModalProps { isOpen: boolean; onClose: () => void; title: string; children: React.ReactNode; footer?: React.ReactNode; className?: string; } export function Modal({ isOpen, onClose, title, children, footer, className }: ModalProps) { const overlayRef = useRef(null); useEffect(() => { const handleKey = (e: KeyboardEvent) => { if (e.key === "Escape") onClose(); }; if (isOpen) document.addEventListener("keydown", handleKey); return () => document.removeEventListener("keydown", handleKey); }, [isOpen, onClose]); if (!isOpen) return null; return (
e.target === overlayRef.current && onClose()} >

{title}

{children}
{footer && (
{footer}
)}
); }