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 colors = [
"#6366f1", "#10b981", "#f59e0b", "#ef4444", "#8b5cf6",
"#ec4899", "#14b8a6", "#f97316", "#06b6d4", "#84cc16",
];
const content = (
Admin Panel
{resources.map((r, i) => {
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: `${colors[i % colors.length]}15`,
"&:hover": { bgcolor: `${colors[i % colors.length]}20` },
},
}}
>
);
})}
);
if (isMobile) {
return (
{content}
);
}
return (
{content}
);
}
export { drawerWidth };