From c3b874bceef541ad27dd946e5fc358a411dc59a4 Mon Sep 17 00:00:00 2001 From: "cyril.tsui" Date: Thu, 30 May 2024 16:17:02 +0800 Subject: [PATCH] update project access right --- src/app/(main)/projects/page.tsx | 2 +- src/components/NavigationContent/NavigationContent.tsx | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/app/(main)/projects/page.tsx b/src/app/(main)/projects/page.tsx index faaa2d9..724b25c 100644 --- a/src/app/(main)/projects/page.tsx +++ b/src/app/(main)/projects/page.tsx @@ -22,7 +22,7 @@ const Projects: React.FC = async () => { fetchProjectCategories(); const projects = await fetchProjects(); const abilities = await getUserAbilities() - if (!abilities.includes(VIEW_PROJECT)) { + if (![VIEW_PROJECT, MAINTAIN_PROJECT].some(ability => abilities.includes(ability))) { notFound(); } diff --git a/src/components/NavigationContent/NavigationContent.tsx b/src/components/NavigationContent/NavigationContent.tsx index f033048..ccf1b2a 100644 --- a/src/components/NavigationContent/NavigationContent.tsx +++ b/src/components/NavigationContent/NavigationContent.tsx @@ -37,8 +37,10 @@ import EmojiEventsIcon from "@mui/icons-material/EmojiEvents"; import { GENERATE_REPORTS, MAINTAIN_MASTERDATA, + MAINTAIN_PROJECT, MAINTAIN_USER, VIEW_MASTERDATA, + VIEW_PROJECT, VIEW_USER, } from "@/middleware"; import { SessionWithAbilities } from "../AppBar/NavigationToggle"; @@ -131,7 +133,7 @@ const NavigationContent: React.FC = ({ abilities }) => { // }, // ], // }, - { icon: , label: "Project Management", path: "/projects" }, + { icon: , label: "Project Management", path: "/projects", isHidden: ![VIEW_PROJECT, MAINTAIN_PROJECT].some((ability) => abilities?.includes(ability)) }, { icon: , label: "Task Template", path: "/tasks" }, { icon: , label: "Invoice", path: "/invoice" }, {