import React, { useCallback } from 'react'; import type { DialogRootProps } from '@luxfi/ui/dialog'; import { DialogBody, DialogContent, DialogHeader, DialogRoot } from '@luxfi/ui/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() }
); }