import { ChevronRight, People, Person } from "@mui/icons-material"; import ChevronLeft from "@mui/icons-material/ChevronLeft"; import { darken, Divider, Grid2 as Grid, IconButton, lighten, List, ListItemButton, ListItemIcon, ListItemText, SwipeableDrawer, Theme, Toolbar, Tooltip, useTheme } from "@mui/material"; import classNames from "classnames"; import { useWidth } from "../hooks/useWidth"; import { makeStyles } from "@mui/styles"; import BindaptIcon from "../products/Bindapt/BindaptIcon"; import { Link, useLocation } from "react-router-dom"; import BinsIcon from "products/Bindapt/BinsIcon"; import { useGlobalState } from "providers"; import { // hasTutorialPlaylist, // IsAdaptiveAgriculture, // IsAdCon, // isBXT, IsMiVent, // IsOmniAir } from "services/whiteLabel"; import MiningIcon from "products/ventilation/MiningIcon"; import { useAuth0 } from "@auth0/auth0-react"; const drawerWidth = 230; const useStyles = makeStyles((theme: Theme) => ({ sideMenu: { position: "fixed", height: "100%", width: drawerWidth, flexShrink: 0, whiteSpace: "nowrap", background: theme.palette.background.default }, sideMenuOpened: { zIndex: theme.zIndex.drawer + 2, width: drawerWidth, transition: theme.transitions.create(["width"], { easing: theme.transitions.easing.sharp, duration: theme.transitions.duration.enteringScreen }) }, sideMenuOnClosed: { transition: theme.transitions.create(["width", "z-index", "opacity"], { easing: theme.transitions.easing.sharp, duration: theme.transitions.duration.leavingScreen }), overflowX: "hidden", width: theme.spacing(7), zIndex: theme.zIndex.drawer, opacity: 0, [theme.breakpoints.up("md")]: { width: theme.spacing(9), opacity: 1 } }, list: { paddingTop: 0 }, listItem: { paddingLeft: theme.spacing(2), paddingRight: theme.spacing(2), [theme.breakpoints.up("md")]: { paddingLeft: theme.spacing(3), paddingRight: theme.spacing(3) }, }, activeItem: theme.palette.mode === "light" ? { background: darken(theme.palette.background.default, 0.25), "&:hover": { background: darken(theme.palette.background.default, 0.25) } } : { background: lighten(theme.palette.background.default, 0.25), "&:hover": { background: lighten(theme.palette.background.default, 0.25) } } })) interface Props { open: boolean; onOpen: () => void; onClose: () => void; } export default function SideNavigator(props: Props) { const { open, onOpen, onClose } = props; const { isAuthenticated } = useAuth0() const theme = useTheme(); const width = useWidth(); const classes = useStyles(); const location = useLocation(); const [{ user }] = useGlobalState() const getClasses = (page: string) => { if (page === "/device") { if (location.pathname.startsWith("/device") || location.pathname.startsWith("/group")) { return ({ root: `${classes.listItem} ${classes.activeItem}` }) } } if (location.pathname.startsWith(page)) { return ({ root: `${classes.listItem} ${classes.activeItem}` }) } return ({ root: `${classes.listItem}` }) } const authenticatedSideMenu = () => { const isMiVent = IsMiVent(); return ( {open && } {open && } {(isMiVent || user.hasFeature("admin")) && ( {open && } )} {open && } {open && } ) } return ( > {theme.direction === "rtl" ? : } {/* {isAuthenticated || isOffline() ? authenticatedSideMenu() : unauthenticatedSideMenu()} */} {isAuthenticated && authenticatedSideMenu()} ); }