diff --git a/src/components/AppBar/NavigationToggle.tsx b/src/components/AppBar/NavigationToggle.tsx
index 9f61753..23551b7 100644
--- a/src/components/AppBar/NavigationToggle.tsx
+++ b/src/components/AppBar/NavigationToggle.tsx
@@ -4,10 +4,17 @@ import MenuIcon from "@mui/icons-material/Menu";
import NavigationContent from "../NavigationContent";
import React from "react";
import Drawer from "@mui/material/Drawer";
+import { getServerSession } from "next-auth";
+import { authOptions } from "@/config/authConfig";
+import { Session } from "inspector";
+export interface SessionWithAbilities extends Session {
+ abilities?: string[]
+}
-const NavigationToggle: React.FC = () => {
+const NavigationToggle: React.FC = async () => {
const [isOpened, setIsOpened] = React.useState(false);
-
+ const session = await getServerSession(authOptions) as SessionWithAbilities;
+ const abilities: string[] = session.abilities || []
const openNavigation = () => {
setIsOpened(true);
};
@@ -18,7 +25,7 @@ const NavigationToggle: React.FC = () => {
return (
<>
-
+
{
keepMounted: true,
}}
>
-
+
, label: "User Workspace", path: "/home" },
- {
- icon: ,
- label: "Dashboard",
- path: "",
- children: [
- {
- icon: ,
- label: "Financial Summary",
- path: "/dashboard/ProjectFinancialSummary",
- },
- {
- icon: ,
- label: "Company / Team Cash Flow",
- path: "/dashboard/CompanyTeamCashFlow",
- },
- {
- icon: ,
- label: "Project Cash Flow",
- path: "/dashboard/ProjectCashFlow",
- },
- {
- icon: ,
- label: "Project Status by Client",
- path: "/dashboard/ProjectStatusByClient",
- },
- {
- icon: ,
- label: "Project Status by Team",
- path: "/dashboard/ProjectStatusByTeam",
- },
- {
- icon: ,
- label: "Staff Utilization",
- path: "/dashboard/StaffUtilization",
- },
- {
- icon: ,
- label: "Project Resource Summary",
- path: "/dashboard/ProjectResourceSummary",
- }
- ],
- },
- {
- icon: ,
- label: "Staff Reimbursement",
- path: "/staffReimbursement",
- children: [
- {
- icon: ,
- label: "Claim Approval",
- path: "/staffReimbursement/ClaimApproval",
- },
- {
- icon: ,
- label: "Claim Summary",
- path: "/staffReimbursement/ClaimSummary",
- },
- ],
- },
- { icon: , label: "Project Management", path: "/projects" },
- { icon: , label: "Task Template", path: "/tasks" },
- { icon: , label: "Invoice", path: "/invoice" },
- { icon: , label: "Analysis Report", path: "",
- children: [
- {icon: , label:"Late Start Report", path: "/analytics/LateStartReport"},
- {icon: , label:"Delay Report", path: "/analytics/DelayReport"},
- {icon: , label:"Resource Overconsumption Report", path: "/analytics/ResourceOverconsumptionReport"},
- {icon: , label:"Cost and Expense Report", path: "/analytics/CostandExpenseReport"},
- {icon: , label:"Completion Report", path: "/analytics/ProjectCompletionReport"},
- {icon: , label:"Completion Report with Outstanding Un-billed Hours Report", path: "/analytics/ProjectCompletionReportWO"},
- {icon: , label:"Project Claims Report", path: "/analytics/ProjectClaimsReport"},
- {icon: , label:"Project P&L Report", path: "/analytics/ProjectPLReport"},
- {icon: , label:"Financial Status Report", path: "/analytics/FinancialStatusReport"},
- {icon: , label:"EX02 - Project Cash Flow Report", path: "/analytics/EX02ProjectCashFlowReport"},
- ],
-},
- {
- icon: , label: "Setting", path: "",
- children: [
- { icon: , label: "Client", path: "/settings/customer" },
- { icon: , label: "Subsidiary", path: "/settings/subsidiary" },
- { icon: , label: "Staff", path: "/settings/staff" },
- { icon: , label: "Company", path: "/settings/company" },
- { icon: , label: "Skill", path: "/settings/skill" },
- { icon: , label: "Department", path: "/settings/department" },
- { icon: , label: "Position", path: "/settings/position" },
- { icon: , label: "Salary", path: "/settings/salary" },
- { icon: , label: "Team", path: "/settings/team" },
- { icon: , label: "User", path: "/settings/user" },
- { icon: , label: "Holiday", path: "/settings/holiday" },
+interface Props {
+ abilities: string[]
+}
+// console.log(getUserData())
+
+
+const NavigationContent: React.FC = async ({abilities}) => {
+ const navigationItems: NavigationItem[] = [
+ { icon: , label: "User Workspace", path: "/home" },
+ {
+ icon: ,
+ label: "Dashboard",
+ path: "",
+ children: [
+ {
+ icon: ,
+ label: "Financial Summary",
+ path: "/dashboard/ProjectFinancialSummary",
+ },
+ {
+ icon: ,
+ label: "Company / Team Cash Flow",
+ path: "/dashboard/CompanyTeamCashFlow",
+ },
+ {
+ icon: ,
+ label: "Project Cash Flow",
+ path: "/dashboard/ProjectCashFlow",
+ },
+ {
+ icon: ,
+ label: "Project Status by Client",
+ path: "/dashboard/ProjectStatusByClient",
+ },
+ {
+ icon: ,
+ label: "Project Status by Team",
+ path: "/dashboard/ProjectStatusByTeam",
+ },
+ {
+ icon: ,
+ label: "Staff Utilization",
+ path: "/dashboard/StaffUtilization",
+ },
+ {
+ icon: ,
+ label: "Project Resource Summary",
+ path: "/dashboard/ProjectResourceSummary",
+ }
+ ],
+ },
+ {
+ icon: ,
+ label: "Staff Reimbursement",
+ path: "/staffReimbursement",
+ children: [
+ {
+ icon: ,
+ label: "Claim Approval",
+ path: "/staffReimbursement/ClaimApproval",
+ },
+ {
+ icon: ,
+ label: "Claim Summary",
+ path: "/staffReimbursement/ClaimSummary",
+ },
+ ],
+ },
+ { icon: , label: "Project Management", path: "/projects" },
+ { icon: , label: "Task Template", path: "/tasks" },
+ { icon: , label: "Invoice", path: "/invoice" },
+ { icon: , label: "Analysis Report", path: "", isHidden: ![GENERATE_REPORTS].some((ability) => abilities.includes(ability)),
+ children: [
+ {icon: , label:"Late Start Report", path: "/analytics/LateStartReport"},
+ {icon: , label:"Delay Report", path: "/analytics/DelayReport"},
+ {icon: , label:"Resource Overconsumption Report", path: "/analytics/ResourceOverconsumptionReport"},
+ {icon: , label:"Cost and Expense Report", path: "/analytics/CostandExpenseReport"},
+ {icon: , label:"Completion Report", path: "/analytics/ProjectCompletionReport"},
+ {icon: , label:"Completion Report with Outstanding Un-billed Hours Report", path: "/analytics/ProjectCompletionReportWO"},
+ {icon: , label:"Project Claims Report", path: "/analytics/ProjectClaimsReport"},
+ {icon: , label:"Project P&L Report", path: "/analytics/ProjectPLReport"},
+ {icon: , label:"Financial Status Report", path: "/analytics/FinancialStatusReport"},
+ {icon: , label:"EX02 - Project Cash Flow Report", path: "/analytics/EX02ProjectCashFlowReport"},
],
},
-];
-
-const NavigationContent: React.FC = () => {
+ {
+ icon: , label: "Setting", path: "", isHidden: ![VIEW_MASTERDATA, MAINTAIN_MASTERDATA].some((ability) => abilities.includes(ability)),
+ children: [
+ { icon: , label: "Client", path: "/settings/customer" },
+ { icon: , label: "Subsidiary", path: "/settings/subsidiary" },
+ { icon: , label: "Staff", path: "/settings/staff" },
+ { icon: , label: "Company", path: "/settings/company" },
+ { icon: , label: "Skill", path: "/settings/skill" },
+ { icon: , label: "Department", path: "/settings/department" },
+ { icon: , label: "Position", path: "/settings/position" },
+ { icon: , label: "Salary", path: "/settings/salary" },
+ { icon: , label: "Team", path: "/settings/team" },
+ { icon: , label: "User", path: "/settings/user", isHidden: ![MAINTAIN_USER, VIEW_USER].some((ability) => abilities.includes(ability))},
+ { icon: , label: "Holiday", path: "/settings/holiday" },
+ ],
+ },
+ ];
const { t } = useTranslation("common");
const pathname = usePathname();
@@ -188,7 +195,7 @@ const NavigationContent: React.FC = () => {
- {navigationItems.map((item) => renderNavigationItem(item))}
+ {navigationItems.filter(item => item.isHidden !== true).map((item) => renderNavigationItem(item))}
{/* {navigationItems.map(({ icon, label, path }, index) => {
return (
{
const staff = await fetchStaff();
const session = await getServerSession(authOptions) as SessionWithAbilities;