import { Box, Modal, ModalOverlay, ModalContent, ModalHeader, ModalBody, ModalCloseButton, Text, } from '@chakra-ui/react'; import React, { useCallback } from 'react'; import useIsMobile from 'lib/hooks/useIsMobile'; 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 && setAlertVisible(false); onClose(); }, [ onClose, setAlertVisible ]); const isMobile = useIsMobile(); return ( { title } { (isAlertVisible || text) && ( { text && ( { text } ) } { isAlertVisible && } ) } { renderForm() } ); }