import { useRef } from 'react'; import useClickedOutside from '../../hooks/useClickedOutside'; import useEscapeKey from '../../hooks/useEscapeKey'; import Button from './Button'; interface ModalProps { title?: string submitText?: string show: boolean canSubmit: boolean hideWindow: () => void onSubmit: () => void onCancel?: () => void children: React.ReactNode } function Modal({ title, show, hideWindow, onSubmit, onCancel, canSubmit, children, submitText = 'Продолжить' }: ModalProps) { const ref = useRef(null); useClickedOutside({ ref, callback: hideWindow }); useEscapeKey(hideWindow); if (!show) { return null; } const handleCancel = () => { hideWindow(); if (onCancel) onCancel(); }; const handleSubmit = () => { hideWindow(); onSubmit(); }; return ( <>
{ title &&

{title}

}
{children}
); } export default Modal;