fix: anti double submit in form
This commit is contained in:
@@ -31,6 +31,7 @@ interface ProviderFormProps {
|
||||
action: PageActionType;
|
||||
currentData?: ListItem; // Used when action is EDIT
|
||||
onFinish: (values: FormData) => Promise<void>;
|
||||
onFinishFailed?: (errorInfo: any) => void;
|
||||
}
|
||||
|
||||
const TABKeysMap = {
|
||||
@@ -51,7 +52,7 @@ const requiredFields = {
|
||||
};
|
||||
|
||||
const ProviderForm: React.FC<ProviderFormProps> = forwardRef((props, ref) => {
|
||||
const { action, currentData, onFinish } = props;
|
||||
const { action, currentData, onFinish, onFinishFailed } = props;
|
||||
const intl = useIntl();
|
||||
const providerRequiredFieldsMap = useProviderRequiredFields();
|
||||
const [form] = Form.useForm();
|
||||
@@ -146,6 +147,11 @@ const ProviderForm: React.FC<ProviderFormProps> = forwardRef((props, ref) => {
|
||||
updateActiveKey
|
||||
});
|
||||
|
||||
const handleFinishFailed = (errorInfo: any) => {
|
||||
handleOnFinishFailed(errorInfo);
|
||||
onFinishFailed?.(errorInfo);
|
||||
};
|
||||
|
||||
useImperativeHandle(ref, () => ({
|
||||
submit: () => {
|
||||
form.submit();
|
||||
@@ -217,7 +223,7 @@ const ProviderForm: React.FC<ProviderFormProps> = forwardRef((props, ref) => {
|
||||
<Form
|
||||
form={form}
|
||||
onFinish={handleOnFinish}
|
||||
onFinishFailed={handleOnFinishFailed}
|
||||
onFinishFailed={handleFinishFailed}
|
||||
initialValues={{
|
||||
proxy_enabled: false,
|
||||
proxy_url: '',
|
||||
|
||||
Reference in New Issue
Block a user