|
@@ -24,7 +24,7 @@ import { usePathname } from "next/navigation"; |
|
|
import Link from "next/link"; |
|
|
import Link from "next/link"; |
|
|
import { NAVIGATION_CONTENT_WIDTH } from "@/config/uiConfig"; |
|
|
import { NAVIGATION_CONTENT_WIDTH } from "@/config/uiConfig"; |
|
|
import Logo from "../Logo"; |
|
|
import Logo from "../Logo"; |
|
|
|
|
|
|
|
|
|
|
|
import GroupIcon from '@mui/icons-material/Group'; |
|
|
interface NavigationItem { |
|
|
interface NavigationItem { |
|
|
icon: React.ReactNode; |
|
|
icon: React.ReactNode; |
|
|
label: string; |
|
|
label: string; |
|
@@ -87,7 +87,13 @@ const navigationItems: NavigationItem[] = [ |
|
|
{ icon: <Task />, label: "Task Template", path: "/tasks" }, |
|
|
{ icon: <Task />, label: "Task Template", path: "/tasks" }, |
|
|
{ icon: <Payments />, label: "Invoice", path: "/invoice" }, |
|
|
{ icon: <Payments />, label: "Invoice", path: "/invoice" }, |
|
|
{ icon: <Analytics />, label: "Analysis Report", path: "/analytics" }, |
|
|
{ icon: <Analytics />, label: "Analysis Report", path: "/analytics" }, |
|
|
{ icon: <Settings />, label: "Setting", path: "/settings", children: [{ icon: <Staff />, label: "Staff", path: "/staff" }]}, |
|
|
|
|
|
|
|
|
{ |
|
|
|
|
|
icon: <Settings />, label: "Setting", path: "", |
|
|
|
|
|
children: [ |
|
|
|
|
|
{ icon: <GroupIcon />, label: "Customer", path: "/customer" }, |
|
|
|
|
|
{ icon: <Staff />, label: "Staff", path: "/staff" } |
|
|
|
|
|
], |
|
|
|
|
|
}, |
|
|
]; |
|
|
]; |
|
|
|
|
|
|
|
|
const NavigationContent: React.FC = () => { |
|
|
const NavigationContent: React.FC = () => { |
|
@@ -95,16 +101,16 @@ const NavigationContent: React.FC = () => { |
|
|
const pathname = usePathname(); |
|
|
const pathname = usePathname(); |
|
|
|
|
|
|
|
|
const [openItems, setOpenItems] = React.useState<string[]>([]); |
|
|
const [openItems, setOpenItems] = React.useState<string[]>([]); |
|
|
const toggleItem = (path: string) => { |
|
|
|
|
|
|
|
|
const toggleItem = (label: string) => { |
|
|
setOpenItems((prevOpenItems) => |
|
|
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 renderNavigationItem = (item: NavigationItem) => { |
|
|
const isOpen = openItems.includes(item.path); |
|
|
|
|
|
|
|
|
const isOpen = openItems.includes(item.label); |
|
|
|
|
|
|
|
|
return ( |
|
|
return ( |
|
|
<Box |
|
|
<Box |
|
@@ -114,8 +120,8 @@ const NavigationContent: React.FC = () => { |
|
|
sx={{ textDecoration: "none", color: "inherit" }} |
|
|
sx={{ textDecoration: "none", color: "inherit" }} |
|
|
> |
|
|
> |
|
|
<ListItemButton |
|
|
<ListItemButton |
|
|
selected={pathname.includes(item.path)} |
|
|
|
|
|
onClick={() => item.children && toggleItem(item.path)} |
|
|
|
|
|
|
|
|
selected={pathname.includes(item.label)} |
|
|
|
|
|
onClick={() => item.children && toggleItem(item.label)} |
|
|
> |
|
|
> |
|
|
<ListItemIcon>{item.icon}</ListItemIcon> |
|
|
<ListItemIcon>{item.icon}</ListItemIcon> |
|
|
<ListItemText primary={t(item.label)} /> |
|
|
<ListItemText primary={t(item.label)} /> |
|
|