From 4d5ec45c099959921d440e4eba7ee48b547a58dd Mon Sep 17 00:00:00 2001 From: "Aditya @ArchLinux" <132184385+adityadeshlahre@users.noreply.github.com> Date: Wed, 3 Jul 2024 21:14:46 +0530 Subject: [PATCH] Notification fixes --- .../admin/userManagement/UserAddModify.js | 14 +++--- .../admin/userManagement/UserManagement.js | 46 ++++++++++++------- frontend/src/languages/en.json | 4 +- frontend/src/languages/fr.json | 4 +- 4 files changed, 43 insertions(+), 25 deletions(-) diff --git a/frontend/src/components/admin/userManagement/UserAddModify.js b/frontend/src/components/admin/userManagement/UserAddModify.js index 7e057949c..1faa390a8 100644 --- a/frontend/src/components/admin/userManagement/UserAddModify.js +++ b/frontend/src/components/admin/userManagement/UserAddModify.js @@ -278,14 +278,14 @@ function UserAddModify() { id: "notification.title", }), message: intl.formatMessage({ - id: "notification.organization.post.save.success", + id: "notification.user.post.save.success", }), kind: NotificationKinds.success, }); setNotificationVisible(true); - // setTimeout(() => { - // window.location.reload(); - // }, 2000); + setTimeout(() => { + window.location.reload(); + }, 2000); } else { addNotification({ kind: NotificationKinds.error, @@ -293,9 +293,9 @@ function UserAddModify() { message: intl.formatMessage({ id: "server.error.msg" }), }); setNotificationVisible(true); - // setTimeout(() => { - // window.location.reload(); - // }, 2000); + setTimeout(() => { + window.location.reload(); + }, 2000); } } diff --git a/frontend/src/components/admin/userManagement/UserManagement.js b/frontend/src/components/admin/userManagement/UserManagement.js index b95e956ce..42bf84ab4 100644 --- a/frontend/src/components/admin/userManagement/UserManagement.js +++ b/frontend/src/components/admin/userManagement/UserManagement.js @@ -94,7 +94,9 @@ function UserManagement() { ",", )}&startingRecNo=1`, JSON.stringify(selectedRowCombinedUserIDPost), - deleteDeactivateUserManagementCallback(), + (res) => { + deleteDeactivateUserManagementCallback(res); + }, ); } @@ -124,21 +126,33 @@ function UserManagement() { setSelectedRowCombinedUserIDPost(selectedRowCombinedUserIDObject); }, [selectedRowCombinedUserID, userManagementListShow]); - function deleteDeactivateUserManagementCallback() { - setLoading(false); - setNotificationVisible(true); - addNotification({ - title: intl.formatMessage({ - id: "notification.title", - }), - message: intl.formatMessage({ - id: "notification.organization.post.delete.success", - }), - kind: NotificationKinds.success, - }); - setTimeout(() => { - window.location.reload(); - }, 2000); + function deleteDeactivateUserManagementCallback(res) { + if (res) { + setLoading(false); + setNotificationVisible(true); + addNotification({ + title: intl.formatMessage({ + id: "notification.title", + }), + message: intl.formatMessage({ + id: "notification.user.post.delete.success", + }), + kind: NotificationKinds.success, + }); + setTimeout(() => { + window.location.reload(); + }, 2000); + } else { + addNotification({ + kind: NotificationKinds.error, + title: intl.formatMessage({ id: "notification.title" }), + message: intl.formatMessage({ id: "server.error.msg" }), + }); + setNotificationVisible(true); + setTimeout(() => { + window.location.reload(); + }, 2000); + } } const handlePageChange = ({ page, pageSize }) => { diff --git a/frontend/src/languages/en.json b/frontend/src/languages/en.json index 04952305a..f45812547 100644 --- a/frontend/src/languages/en.json +++ b/frontend/src/languages/en.json @@ -1152,5 +1152,7 @@ "systemuserrole.roles.labunit": "Lab Unit Roles", "systemuserrole.newpermissions": "Add New Permission", "systemuserrole.rmpermissions": "Remove Permission", - "barcode.notification.save": "BarCode Configurations has been saved." + "barcode.notification.save": "BarCode Configurations has been saved.", + "notification.user.post.save.success": "User Information Added Succesfully.", + "notification.user.post.delete.success": "User Deactivated Succesfully." } diff --git a/frontend/src/languages/fr.json b/frontend/src/languages/fr.json index 92f8d2ff5..5e15b0eaa 100644 --- a/frontend/src/languages/fr.json +++ b/frontend/src/languages/fr.json @@ -1058,5 +1058,7 @@ "systemuserrole.roles.labunit": "Rôles Unité de Laboratoire", "systemuserrole.newpermissions": "Ajouter une nouvelle permission", "systemuserrole.rmpermissions": "Supprimer la permission", - "barcode.notification.save": "Les configurations de code-barres ont été enregistrées." + "barcode.notification.save": "Les configurations de code-barres ont été enregistrées.", + "notification.user.post.save.success": "Informations utilisateur ajoutées avec succès.", + "notification.user.post.delete.success": "Utilisateur désactivé avec succès." }