From 6a6e46096185b5ee84b0632979e195eb9b3ea0db Mon Sep 17 00:00:00 2001 From: Tsu-ba-me Date: Thu, 25 Jan 2024 15:19:19 -0500 Subject: [PATCH] fix(striker-ui): close form dialog after success in manage mail server --- .../ManageMailServer/AddMailServerForm.tsx | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/striker-ui/components/ManageMailServer/AddMailServerForm.tsx b/striker-ui/components/ManageMailServer/AddMailServerForm.tsx index dbcadec0..ea1ce702 100644 --- a/striker-ui/components/ManageMailServer/AddMailServerForm.tsx +++ b/striker-ui/components/ManageMailServer/AddMailServerForm.tsx @@ -45,7 +45,6 @@ const AddMailServerForm: FC = (props) => { }, onSubmit: (values, { setSubmitting }) => { const { [msUuid]: mailServer } = values; - const { confirm } = tools; let actionProceedText: string = 'Add'; let errorMessage: ReactNode = <>Failed to add mail server.; @@ -65,16 +64,18 @@ const AddMailServerForm: FC = (props) => { const { confirmPassword, uuid, ...rest } = mailServer; - confirm.prepare({ + tools.confirm.prepare({ actionProceedText, content: , onCancelAppend: () => setSubmitting(false), onProceedAppend: () => { - confirm.loading(true); + tools.confirm.loading(true); api[method](url, mailServer) .then(() => { - confirm.finish('Success', { children: successMessage }); + tools.confirm.finish('Success', { children: successMessage }); + + tools[method === 'post' ? 'add' : 'edit'].open(false); }) .catch((error) => { const emsg = handleAPIError(error); @@ -85,16 +86,15 @@ const AddMailServerForm: FC = (props) => { ); - confirm.finish('Error', emsg); - }) - .finally(() => { + tools.confirm.finish('Error', emsg); + setSubmitting(false); }); }, titleText, }); - confirm.open(true); + tools.confirm.open(true); }, validationSchema: mailServerListSchema, });