import { useResetFormOnCloseModal } from '@/hooks/logic-hooks'; import { IModalProps } from '@/interfaces/common'; import { Form, Input, Modal, Select, Switch } from 'antd'; import { DefaultOptionType } from 'antd/es/select'; import { useEffect, useMemo } from 'react'; import { BeginQueryType, BeginQueryTypeIconMap } from '../../constant'; import { BeginQuery } from '../../interface'; import BeginDynamicOptions from './begin-dynamic-options'; export const ModalForm = ({ visible, initialValue, hideModal, otherThanCurrentQuery, }: IModalProps & { initialValue: BeginQuery; otherThanCurrentQuery: BeginQuery[]; }) => { const [form] = Form.useForm(); const options = useMemo(() => { return Object.values(BeginQueryType).reduce( (pre, cur) => { const Icon = BeginQueryTypeIconMap[cur]; return [ ...pre, { label: (
{cur}
), value: cur, }, ]; }, [], ); }, []); useResetFormOnCloseModal({ form, visible: visible, }); useEffect(() => { form.setFieldsValue(initialValue); }, [form, initialValue]); const onOk = () => { form.submit(); }; return (
prevValues.type !== curValues.type } > {({ getFieldValue }) => { const type: BeginQueryType = getFieldValue('type'); return ( type === BeginQueryType.Options && ( ) ); }}
); };