Spaces:
Runtime error
Runtime error
Download ui/src/pages/table-list/components/CreateForm.tsx from shancode/py-server-demo: direct link, hf CLI and curl.
- Browser
- Download file 2.01 kB
-
https://huggingface.co/spaces/shancode/py-server-demo/resolve/main/ui/src/pages/table-list/components/CreateForm.tsx
- Command line
-
hf download hf://spaces/shancode/py-server-demo/ui/src/pages/table-list/components/CreateForm.tsx
-
curl -L -o CreateForm.tsx https://huggingface.co/spaces/shancode/py-server-demo/resolve/main/ui/src/pages/table-list/components/CreateForm.tsx
2.01 kB
| 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<CreateFormProps> = (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} | |
| <ModalForm | |
| title={intl.formatMessage({ | |
| id: 'pages.searchTable.createForm.newRule', | |
| defaultMessage: 'New rule', | |
| })} | |
| trigger={ | |
| <Button type="primary" icon={<PlusOutlined />}> | |
| <FormattedMessage id="pages.searchTable.new" defaultMessage="New" /> | |
| </Button> | |
| } | |
| width="400px" | |
| modalProps={{ okButtonProps: { loading } }} | |
| onFinish={async (value) => { | |
| await run({ data: value as API.RuleListItem }); | |
| return true; | |
| }} | |
| > | |
| <ProFormText | |
| rules={[ | |
| { | |
| required: true, | |
| message: ( | |
| <FormattedMessage | |
| id="pages.searchTable.ruleName" | |
| defaultMessage="Rule name is required" | |
| /> | |
| ), | |
| }, | |
| ]} | |
| width="md" | |
| name="name" | |
| /> | |
| <ProFormTextArea width="md" name="desc" /> | |
| </ModalForm> | |
| </> | |
| ); | |
| }; | |
| export default CreateForm; | |