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

{title}

}
{children}
); } export default Modal;