Added permissions to filter out the user update
This commit is contained in:
@@ -4,6 +4,7 @@ import {
|
||||
CorporateUser,
|
||||
EMPLOYMENT_STATUS,
|
||||
User,
|
||||
Type,
|
||||
} from "@/interfaces/user";
|
||||
import { groupBySession, averageScore } from "@/utils/stats";
|
||||
import { RadioGroup } from "@headlessui/react";
|
||||
@@ -32,6 +33,8 @@ import { USER_TYPE_LABELS } from "@/resources/user";
|
||||
import { CURRENCIES } from "@/resources/paypal";
|
||||
import useCodes from "@/hooks/useCodes";
|
||||
import { checkAccess, getTypesOfUser } from "@/utils/permissions";
|
||||
import { PERMISSIONS } from "@/constants/userPermissions";
|
||||
import { PermissionType } from "@/interfaces/permissions";
|
||||
|
||||
const expirationDateColor = (date: Date) => {
|
||||
const momentDate = moment(date);
|
||||
@@ -261,6 +264,10 @@ const UserCard = ({
|
||||
]
|
||||
: [];
|
||||
|
||||
const updateUserPermission = PERMISSIONS.updateUser[user.type] as {
|
||||
list: Type[];
|
||||
perm: PermissionType;
|
||||
};
|
||||
return (
|
||||
<>
|
||||
<ProfileSummary
|
||||
@@ -817,7 +824,14 @@ const UserCard = ({
|
||||
Close
|
||||
</Button>
|
||||
<Button
|
||||
disabled={disabled}
|
||||
disabled={
|
||||
disabled ||
|
||||
!checkAccess(
|
||||
loggedInUser,
|
||||
updateUserPermission.list,
|
||||
updateUserPermission.perm
|
||||
)
|
||||
}
|
||||
onClick={updateUser}
|
||||
className="w-full max-w-[200px]"
|
||||
>
|
||||
|
||||
Reference in New Issue
Block a user