import { Box, Modal, ModalOverlay, ModalContent, ModalHeader, ModalBody, ModalCloseButton, Text, } from '@chakra-ui/react'; import React, { useCallback } from 'react'; import FormSubmitAlert from 'ui/shared/FormSubmitAlert'; interface Props { isOpen: boolean; onClose: () => void; data?: TData; title: string; text: string; renderForm: () => JSX.Element; isAlertVisible: boolean; setAlertVisible: (isAlertVisible: boolean) => void; } export default function FormModal({ isOpen, onClose, title, text, renderForm, isAlertVisible, setAlertVisible, }: Props) { const onModalClose = useCallback(() => { setAlertVisible(false); onClose(); }, [ onClose, setAlertVisible ]); return ( { title } { (isAlertVisible || text) && ( { text && ( { text } ) } { isAlertVisible && } ) } { renderForm() } ); }