import type { DialogRootProps } from '@chakra-ui/react'; import { Box, Text } from '@chakra-ui/react'; import React, { useCallback } from 'react'; import { DialogBody, DialogContent, DialogHeader, DialogRoot } from 'toolkit/chakra/dialog'; import FormSubmitAlert from 'ui/shared/FormSubmitAlert'; interface Props extends Omit { data?: TData; title: string; text?: string; renderForm: () => React.JSX.Element; isAlertVisible?: boolean; setAlertVisible?: (isAlertVisible: boolean) => void; } export default function FormModal({ open, onOpenChange, title, text, renderForm, isAlertVisible, setAlertVisible, ...rest }: Props) { const handleOpenChange = useCallback(({ open }: { open: boolean }) => { !open && setAlertVisible?.(false); onOpenChange?.({ open }); }, [ onOpenChange, setAlertVisible ]); return ( { title } { (isAlertVisible || text) && ( { text && ( { text } ) } { isAlertVisible && } ) } { renderForm() } ); }