From 92007aab121cf1ddb5f9ceb1c5408a58693fc91b Mon Sep 17 00:00:00 2001 From: "cyril.tsui" Date: Wed, 27 Mar 2024 17:32:15 +0800 Subject: [PATCH] update navigation content --- .../NavigationContent/NavigationContent.tsx | 24 ++++++++++++------- 1 file changed, 15 insertions(+), 9 deletions(-) diff --git a/src/components/NavigationContent/NavigationContent.tsx b/src/components/NavigationContent/NavigationContent.tsx index e606bd9..1bb497e 100644 --- a/src/components/NavigationContent/NavigationContent.tsx +++ b/src/components/NavigationContent/NavigationContent.tsx @@ -24,7 +24,7 @@ import { usePathname } from "next/navigation"; import Link from "next/link"; import { NAVIGATION_CONTENT_WIDTH } from "@/config/uiConfig"; import Logo from "../Logo"; - +import GroupIcon from '@mui/icons-material/Group'; interface NavigationItem { icon: React.ReactNode; label: string; @@ -87,7 +87,13 @@ const navigationItems: NavigationItem[] = [ { icon: , label: "Task Template", path: "/tasks" }, { icon: , label: "Invoice", path: "/invoice" }, { icon: , label: "Analysis Report", path: "/analytics" }, - { icon: , label: "Setting", path: "/settings", children: [{ icon: , label: "Staff", path: "/staff" }]}, + { + icon: , label: "Setting", path: "", + children: [ + { icon: , label: "Customer", path: "/customer" }, + { icon: , label: "Staff", path: "/staff" } + ], + }, ]; const NavigationContent: React.FC = () => { @@ -95,16 +101,16 @@ const NavigationContent: React.FC = () => { const pathname = usePathname(); const [openItems, setOpenItems] = React.useState([]); - const toggleItem = (path: string) => { + const toggleItem = (label: string) => { setOpenItems((prevOpenItems) => - prevOpenItems.includes(path) - ? prevOpenItems.filter((item) => item !== path) - : [...prevOpenItems, path], + prevOpenItems.includes(label) + ? prevOpenItems.filter((item) => item !== label) + : [...prevOpenItems, label], ); }; const renderNavigationItem = (item: NavigationItem) => { - const isOpen = openItems.includes(item.path); + const isOpen = openItems.includes(item.label); return ( { sx={{ textDecoration: "none", color: "inherit" }} > item.children && toggleItem(item.path)} + selected={pathname.includes(item.label)} + onClick={() => item.children && toggleItem(item.label)} > {item.icon}