From 14faf8111a2496e9755c91d0a3247d66e553fb56 Mon Sep 17 00:00:00 2001 From: Sukma Gladys Date: Thu, 31 Oct 2024 15:16:47 +0700 Subject: [PATCH] feat: add navlink at header --- apps/frontend/src/components/AppHeader.tsx | 89 ++++++++++++++++++++-- 1 file changed, 81 insertions(+), 8 deletions(-) diff --git a/apps/frontend/src/components/AppHeader.tsx b/apps/frontend/src/components/AppHeader.tsx index cab58ab..600beb0 100644 --- a/apps/frontend/src/components/AppHeader.tsx +++ b/apps/frontend/src/components/AppHeader.tsx @@ -3,7 +3,7 @@ import logo from "@/assets/logos/amati-logo.png"; import cx from "clsx"; import classNames from "./styles/appHeader.module.css"; import { IoMdMenu } from "react-icons/io"; -import { Link } from "@tanstack/react-router"; +import { Link, useLocation } from "@tanstack/react-router"; import useAuth from "@/hooks/useAuth"; import { Avatar, AvatarFallback, AvatarImage } from "@/shadcn/components/ui/avatar"; import { DropdownMenu, DropdownMenuContent, DropdownMenuItem, DropdownMenuTrigger } from "@/shadcn/components/ui/dropdown-menu"; @@ -21,6 +21,7 @@ interface User { id: string; name: string; permissions: string[]; + role: string; photoProfile?: string; } @@ -34,22 +35,94 @@ export default function AppHeader({ toggle }: Props) { const [userMenuOpened, setUserMenuOpened] = useState(false); const { user }: { user: User | null } = useAuth(); + const isSuperAdmin = user?.role === "super-admin"; // const userMenus = getUserMenus().map((item, i) => ( // // )); + const { pathname } = useLocation(); + const showAssessmentResultLinks = pathname === "/assessmentResult"; + const showAssessmentLinks = pathname === "/assessment"; + const assessmentRequestsLinks = pathname === "/assessmentRequest"; + const managementResultsLinks = pathname === "/assessmentResultsManagement"; + + const shouldShowButton = !(showAssessmentResultLinks || showAssessmentLinks || assessmentRequestsLinks); + return (
- +
+ {shouldShowButton && ( + + )} - + +
+ + {/* Conditional Navlinks */} +
+ {showAssessmentResultLinks && ( + <> + { + if (window.opener) { + window.close(); + } + }} + > + {isSuperAdmin ? "Manajemen Hasil" : "Permohonan Assessment"} + + + Hasil Assessment + + + )} + + {showAssessmentLinks && ( + <> + { + if (window.opener) { + window.close(); + } + }} + > + Permohonan Assessment + + + Assessment + + + )} +