import { ModalForm, ProFormRadio, ProFormSelect, ProFormText, ProFormTextArea, } from '@ant-design/pro-components'; import { Form } from 'antd'; import React from 'react'; import { OPTIONS } from '../../constants'; import { ConfigFields, addApi, updateApi } from './services'; import { SelectOptionFields } from '../../services'; interface EditFormProps { title: string; type: 'add' | 'update'; trigger: JSX.Element; value?: ConfigFields; onOk: () => void; appList: SelectOptionFields[]; } const EditForm: React.FC = ({ trigger, title, value, type, onOk, appList, }) => { const [form] = Form.useForm(); return ( labelCol={{ flex: '120px' }} width={1000} layout="horizontal" title={title} trigger={trigger} form={form} autoFocusFirstInput modalProps={{ destroyOnClose: true, }} submitTimeout={2000} onFinish={async (values) => { const { label: appName } = appList.find((item) => item.value === values.appId) || {}; if (type === 'add') { await addApi({ ...values, appName }); } else if (type === 'update') { await updateApi({ ...values, appName, configId: value?.configId, }); } onOk(); return true; }} > ); }; export default EditForm;