fix(striker-ui): close form dialog after success in manage mail server

main
Tsu-ba-me 11 months ago
parent c93fced70f
commit 6a6e460961
  1. 16
      striker-ui/components/ManageMailServer/AddMailServerForm.tsx

@ -45,7 +45,6 @@ const AddMailServerForm: FC<AddMailServerFormProps> = (props) => {
}, },
onSubmit: (values, { setSubmitting }) => { onSubmit: (values, { setSubmitting }) => {
const { [msUuid]: mailServer } = values; const { [msUuid]: mailServer } = values;
const { confirm } = tools;
let actionProceedText: string = 'Add'; let actionProceedText: string = 'Add';
let errorMessage: ReactNode = <>Failed to add mail server.</>; let errorMessage: ReactNode = <>Failed to add mail server.</>;
@ -65,16 +64,18 @@ const AddMailServerForm: FC<AddMailServerFormProps> = (props) => {
const { confirmPassword, uuid, ...rest } = mailServer; const { confirmPassword, uuid, ...rest } = mailServer;
confirm.prepare({ tools.confirm.prepare({
actionProceedText, actionProceedText,
content: <FormSummary entries={rest} />, content: <FormSummary entries={rest} />,
onCancelAppend: () => setSubmitting(false), onCancelAppend: () => setSubmitting(false),
onProceedAppend: () => { onProceedAppend: () => {
confirm.loading(true); tools.confirm.loading(true);
api[method](url, mailServer) api[method](url, mailServer)
.then(() => { .then(() => {
confirm.finish('Success', { children: successMessage }); tools.confirm.finish('Success', { children: successMessage });
tools[method === 'post' ? 'add' : 'edit'].open(false);
}) })
.catch((error) => { .catch((error) => {
const emsg = handleAPIError(error); const emsg = handleAPIError(error);
@ -85,16 +86,15 @@ const AddMailServerForm: FC<AddMailServerFormProps> = (props) => {
</> </>
); );
confirm.finish('Error', emsg); tools.confirm.finish('Error', emsg);
})
.finally(() => {
setSubmitting(false); setSubmitting(false);
}); });
}, },
titleText, titleText,
}); });
confirm.open(true); tools.confirm.open(true);
}, },
validationSchema: mailServerListSchema, validationSchema: mailServerListSchema,
}); });

Loading…
Cancel
Save