From 45df9837e787b4fafa679ea15d7c48019b545380 Mon Sep 17 00:00:00 2001 From: Joao Ramos Date: Thu, 25 Jul 2024 11:23:11 +0100 Subject: [PATCH] Added permissions to filter out the user update --- src/components/UserCard.tsx | 16 ++++++- src/constants/userPermissions.ts | 71 ++++++++++++++++++++++------ src/pages/(admin)/Lists/UserList.tsx | 37 ++++++++++++--- src/pages/api/user.ts | 2 +- 4 files changed, 104 insertions(+), 22 deletions(-) diff --git a/src/components/UserCard.tsx b/src/components/UserCard.tsx index 7b826542..49dad039 100644 --- a/src/components/UserCard.tsx +++ b/src/components/UserCard.tsx @@ -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 ( <>