import React from "react"; import { useNavigate, useLocation } from "react-router-dom"; import { Drawer, List, ListItemButton, ListItemIcon, ListItemText, Toolbar, Typography, Box, useMediaQuery, useTheme, } from "@mui/material"; import CircleIcon from "@mui/icons-material/Circle"; import type { ResourceConfig } from "../types"; interface SideMenuProps { resources: ResourceConfig[]; basePath: string; mobileOpen: boolean; onClose: () => void; } const drawerWidth = 260; export function SideMenu({ resources, basePath, mobileOpen, onClose }: SideMenuProps) { const navigate = useNavigate(); const location = useLocation(); const theme = useTheme(); const isMobile = useMediaQuery(theme.breakpoints.down("md")); const content = ( Admin Panel {resources.map((r) => { const listPath = `${basePath}/${r.name}`; const active = location.pathname.startsWith(listPath); return ( { navigate(listPath); if (isMobile) onClose(); }} sx={{ borderRadius: 2, mb: 0.5, "&.Mui-selected": { bgcolor: "primary.main", color: "primary.contrastText", "&:hover": { bgcolor: "primary.main" }, "& .MuiListItemIcon-root": { color: "primary.contrastText" }, }, }} > ); })} ); if (isMobile) { return ( {content} ); } return ( {content} ); } export { drawerWidth };