From 4fcb1cec73cae2362007c73d1c54e74f0bb58ada Mon Sep 17 00:00:00 2001 From: Elyor Djalilov Date: Fri, 14 Jun 2024 13:34:33 +0500 Subject: [PATCH] added method for disable users --- .../dialogs/DisableUserDialog/index.js | 48 +++++++++++++++---- .../categories/security/sessions/index.js | 6 +++ .../client/src/store/SelectionPeopleStore.js | 7 +-- 3 files changed, 48 insertions(+), 13 deletions(-) diff --git a/packages/client/src/components/dialogs/DisableUserDialog/index.js b/packages/client/src/components/dialogs/DisableUserDialog/index.js index 775369aa22..f635a4b22d 100644 --- a/packages/client/src/components/dialogs/DisableUserDialog/index.js +++ b/packages/client/src/components/dialogs/DisableUserDialog/index.js @@ -1,22 +1,50 @@ -import { Button } from "@docspace/shared/components/button"; import { ModalDialog } from "@docspace/shared/components/modal-dialog"; +import { Button } from "@docspace/shared/components/button"; +import { toastr } from "@docspace/shared/components/toast"; +import { EmployeeStatus } from "@docspace/shared/enums"; import ModalDialogContainer from "../ModalDialogContainer"; -const DisableUserDialog = ({ t, visible, onClose, isLoading }) => { +const DisableUserDialog = ({ + t, + visible, + onClose, + isLoading, + fetchData, + selection, + updateUserStatus, +}) => { + const userIds = selection.map((user) => user.id); + const onlyOneUser = userIds.length === 1; + + let headerText = ""; + let bodyText = ""; + + headerText = onlyOneUser + ? t("ChangeUserStatusDialog:DisableUser") + : t("ChangeUserStatusDialog:DisableUsers"); + + bodyText = onlyOneUser + ? t("ChangeUserStatusDialog:DisableUserDescription") + : t("ChangeUserStatusDialog:DisableUsersDescription"); + + bodyText = bodyText + t("ChangeUserStatusDialog:DisableGeneralDescription"); + + const onClickDisableUser = async () => { + await updateUserStatus(EmployeeStatus.Disabled, userIds); + toastr.success(t("PeopleTranslations:SuccessChangeUserStatus")); + await fetchData(); + onClose(); + }; + return ( - - {t("ChangeUserStatusDialog:DisableUser")} - - - {t("ChangeUserStatusDialog:DisableUserDescription")}  - {t("ChangeUserStatusDialog:DisableGeneralDescription")} - + {headerText} + {bodyText}