'use client'; import { useEffect, useRef } from 'react'; interface InfoModalProps { open: boolean; title: string; content: string | React.ReactNode; onClose: () => void; } export default function InfoModal({ open, title, content, onClose: handleClose }: InfoModalProps) { const modalRef = useRef(null); useEffect(() => { const handleEscKey = (event: KeyboardEvent) => { if (event.key === 'Escape' && open) { handleClose(); } }; document.addEventListener('keydown', handleEscKey); return () => { document.removeEventListener('keydown', handleEscKey); }; }, [open, handleClose]); const handleBackdropClick = (e: React.MouseEvent) => { if (modalRef.current && !modalRef.current.contains(e.target as Node)) { handleClose(); } }; if (!open) return null; return (

{title}

{typeof content === 'string' ? (

{content}

) : ( content )}
); }