From c507a8892ff66412f95ba3ceeafbea0b7c659e89 Mon Sep 17 00:00:00 2001 From: ajnart Date: Tue, 21 Mar 2023 11:39:34 +0800 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9B=20Fix=20bug=20with=20notification?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../header/SettingsMenu/EditModeToggle.tsx | 31 +++++++++---------- 1 file changed, 15 insertions(+), 16 deletions(-) diff --git a/src/components/layout/header/SettingsMenu/EditModeToggle.tsx b/src/components/layout/header/SettingsMenu/EditModeToggle.tsx index e27c48139..fed323e8c 100644 --- a/src/components/layout/header/SettingsMenu/EditModeToggle.tsx +++ b/src/components/layout/header/SettingsMenu/EditModeToggle.tsx @@ -18,22 +18,21 @@ function ModalContent() { axios .post('/api/configs/tryPassword', { tried: values.triedPassword, type: 'edit' }) .then((res) => { - if (res.data.success) { - showNotification({ - title: 'Success', - message: 'Successfully toggled edit mode, reloading the page...', - color: 'green', - }); - setTimeout(() => { - window.location.reload(); - }, 500); - } else { - showNotification({ - title: 'Wrong password', - message: 'The password you entered is wrong.', - color: 'red', - }); - } + showNotification({ + title: 'Success', + message: 'Successfully toggled edit mode, reloading the page...', + color: 'green', + }); + setTimeout(() => { + window.location.reload(); + }, 500); + }) + .catch((_) => { + showNotification({ + title: 'Error', + message: 'Failed to toggle edit mode, please try again.', + color: 'red', + }); }); })} >