import { PlusOutlined } from '@ant-design/icons'; import { type ActionType, ModalForm, ProFormText, ProFormTextArea, } from '@ant-design/pro-components'; import { FormattedMessage, useIntl, useRequest } from '@umijs/max'; import { Button, message } from 'antd'; import type { FC } from 'react'; import { addRule } from '@/services/ant-design-pro/api'; interface CreateFormProps { reload?: ActionType['reload']; } const CreateForm: FC = (props) => { const { reload } = props; const [messageApi, contextHolder] = message.useMessage(); /** * @en-US International configuration * @zh-CN 国际化配置 * */ const intl = useIntl(); const { run, loading } = useRequest(addRule, { manual: true, onSuccess: () => { messageApi.success('Added successfully'); reload?.(); }, onError: () => { messageApi.error('Adding failed, please try again!'); }, }); return ( <> {contextHolder} }> } width="400px" modalProps={{ okButtonProps: { loading } }} onFinish={async (value) => { await run({ data: value as API.RuleListItem }); return true; }} > ), }, ]} width="md" name="name" /> ); }; export default CreateForm;