From 38c72daee2d67bffbe1aeea5b4e2e577699d6d71 Mon Sep 17 00:00:00 2001 From: Abhishek P Anil Date: Tue, 10 Sep 2024 11:43:01 +0530 Subject: [PATCH 1/2] fix: invited status is considered during post --- src/pages/Dashboard/AddUser/AddUser.jsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/pages/Dashboard/AddUser/AddUser.jsx b/src/pages/Dashboard/AddUser/AddUser.jsx index b1e00268..8d0f1814 100644 --- a/src/pages/Dashboard/AddUser/AddUser.jsx +++ b/src/pages/Dashboard/AddUser/AddUser.jsx @@ -117,7 +117,7 @@ const AddUser = () => { .unwrap() .then((response) => { const activeCalendars = response?.roles?.filter((r) => { - return r.status == userActivityStatus[0].key; + return r.status === userActivityStatus[0].key || r.status === userActivityStatus[2].key; }); setSelectedCalendars( activeCalendars @@ -147,7 +147,7 @@ const AddUser = () => { .unwrap() .then((response) => { const activeCalendars = response?.roles.filter((r) => { - return r.status == userActivityStatus[0].key; + return r.status == userActivityStatus[0].key || r.status == userActivityStatus[2].key; }); setSelectedCalendars( activeCalendars From 3e2c893f1e17ab6e7967290a9f08c0a0c808613b Mon Sep 17 00:00:00 2001 From: Abhishek P Anil Date: Tue, 10 Sep 2024 12:11:18 +0530 Subject: [PATCH 2/2] fix: corrected roles showing super admin if empty --- .../UserManagement/UserManagement.jsx | 2 +- .../Dashboard/UserReadOnly/UserReadOnly.jsx | 4 +- src/utils/roleHandler.js | 44 ++++++++++--------- 3 files changed, 27 insertions(+), 23 deletions(-) diff --git a/src/pages/Dashboard/Settings/UserManagement/UserManagement.jsx b/src/pages/Dashboard/Settings/UserManagement/UserManagement.jsx index d4213ff2..b1414bc2 100644 --- a/src/pages/Dashboard/Settings/UserManagement/UserManagement.jsx +++ b/src/pages/Dashboard/Settings/UserManagement/UserManagement.jsx @@ -608,7 +608,7 @@ const UserManagement = (props) => { return listItemHandler(item?._id); }} title={createTitleHandler(item?.firstName, item?.lastName, item?.userName)} - description={roleHandler({ roles: item?.roles, calendarId })} + description={roleHandler({ roles: item?.roles, calendarId, isSuperAdmin: item?.isSuperAdmin })} activityStatus={currentCalendarUserStatus(item)} styles={handleListCardStyles(item)} invitedBy={item?.invitedBy && } diff --git a/src/pages/Dashboard/UserReadOnly/UserReadOnly.jsx b/src/pages/Dashboard/UserReadOnly/UserReadOnly.jsx index cf1a48eb..72bc28f8 100644 --- a/src/pages/Dashboard/UserReadOnly/UserReadOnly.jsx +++ b/src/pages/Dashboard/UserReadOnly/UserReadOnly.jsx @@ -180,11 +180,11 @@ const UserReadOnly = () => { }, })} - {userInfo?.roles && + {(userInfo?.roles || userInfo?.isSuperAdmin) && createUserInfoRowItem({ isCopiableText: false, infoType: 'userType', - infoText: roleHandler({ roles: userInfo.roles, calendarId }), + infoText: roleHandler({ roles: userInfo.roles, calendarId, isSuperAdmin: userInfo.isSuperAdmin }), })} {userInfo?.interfaceLanguage && diff --git a/src/utils/roleHandler.js b/src/utils/roleHandler.js index ca7a63ea..06f5e0cd 100644 --- a/src/utils/roleHandler.js +++ b/src/utils/roleHandler.js @@ -1,30 +1,34 @@ import { Translation } from 'react-i18next'; import { userRoles } from '../constants/userRoles'; -export const roleHandler = ({ roles, calendarId }) => { - const requiredRole = roles.filter((r) => { - return r.calendarId === calendarId; - }); +export const roleHandler = ({ roles, calendarId, isSuperAdmin }) => { let role = ''; - switch (requiredRole[0]?.role) { - case userRoles.ADMIN: - role = {(t) => t('dashboard.settings.userManagement.admin')}; - break; - case userRoles.CONTRIBUTOR: - role = {(t) => t('dashboard.settings.userManagement.contributor')}; - break; + if (isSuperAdmin) role = {(t) => t('dashboard.settings.userManagement.superAdmin')}; + else { + const requiredRole = roles?.filter((r) => { + return r.calendarId === calendarId; + }); - case userRoles.EDITOR: - role = {(t) => t('dashboard.settings.userManagement.editor')}; - break; + switch (requiredRole[0]?.role) { + case userRoles.ADMIN: + role = {(t) => t('dashboard.settings.userManagement.admin')}; + break; + case userRoles.CONTRIBUTOR: + role = {(t) => t('dashboard.settings.userManagement.contributor')}; + break; - case userRoles.GUEST: - role = {(t) => t('dashboard.settings.userManagement.guest')}; - break; + case userRoles.EDITOR: + role = {(t) => t('dashboard.settings.userManagement.editor')}; + break; - default: - role = {(t) => t('dashboard.settings.userManagement.superAdmin')}; - break; + case userRoles.GUEST: + role = {(t) => t('dashboard.settings.userManagement.guest')}; + break; + + default: + role = ''; + break; + } } return role; };