import React from 'react'; import Hook from '../../hook'; import { Accordion, AccordionSummary, Divider, ListItem, ListItemIcon, ListItemText, Typography } from '@mui/material'; import { ExpandMore } from '@mui/icons-material'; import { SideMenuContentChildren, SideMenuContentPanel } from './styled.panel-content'; export interface AppSideSubMenuItem { path: string; icon: React.FC; label: string, } export interface AppSideMenuItem { path: string; icon: React.FC; label: string, children?: AppSideSubMenuItem[]; } export interface AppSideMenuContentProps { path: string, menuItems: AppSideMenuItem[], } export const AppSideMenuContent: React.FC = ({ menuItems }) => { const [theme] = Hook.useTheme(); const [, navigate] = Hook.useRouter(); const pathname = window.location.pathname.toLowerCase(); const [expanded, setExpanded] = React.useState(pathname); const handleExpandedChange = (panel: string) => (e: any, isExpanded: boolean) => { setExpanded(isExpanded ? panel : !e && false); } const handleRedirect = (route: string) => () => { navigate(route) } return ( { menuItems.map(item => ( { !item.children || item.children.length === 0 ? <> {item.label} } /> : } aria-controls={`${item.path}-content`} id={`${item.path}-header`} style={{ color: pathname.startsWith(item.path.toLowerCase()) ? theme.palette.primary.light : '' }}> {item.label} { item.children.map(child => ( {child.label} } /> )) } } )) } ); }