'use client' import { useEffect, useCallback } from "react" import { X } from 'lucide-react' import { cn } from "@/lib/utils" interface ModalProps { isOpen: boolean onClose: () => void title?: string children: React.ReactNode className?: string } export default function Modal({ isOpen, onClose, title, children, className }: ModalProps) { const handleKeyDown = useCallback((e: KeyboardEvent) => { if (e.key === "Escape") onClose() }, [onClose]) useEffect(() => { if (isOpen) { document.addEventListener("keydown", handleKeyDown) document.body.style.overflow = "hidden" } return () => { document.removeEventListener("keydown", handleKeyDown) document.body.style.overflow = "" } }, [isOpen, handleKeyDown]) if (!isOpen) return null return (
{title && (

{title}

)}
{children}
) }