shoc-frontend/src/components/LeftNav.js

145 lines
5 KiB
JavaScript
Raw Normal View History

2025-03-09 19:45:02 -05:00
import * as React from 'react';
import { styled, useTheme } from '@mui/material/styles';
import Box from '@mui/material/Box';
import Drawer from '@mui/material/Drawer';
import List from '@mui/material/List';
import Typography from '@mui/material/Typography';
import Divider from '@mui/material/Divider';
import IconButton from '@mui/material/IconButton';
import MenuIcon from '@mui/icons-material/Menu';
import ChevronLeftIcon from '@mui/icons-material/ChevronLeft';
import ChevronRightIcon from '@mui/icons-material/ChevronRight';
import ListItem from '@mui/material/ListItem';
import ListItemButton from '@mui/material/ListItemButton';
import ListItemIcon from '@mui/material/ListItemIcon';
import ListItemText from '@mui/material/ListItemText';
import MonetizationOnIcon from '@mui/icons-material/MonetizationOn';
import PersonIcon from '@mui/icons-material/Person';
import TextSnippetIcon from '@mui/icons-material/TextSnippet';
import { makeStyles } from "@mui/styles";
import { Link } from "react-router-dom";
import { useLocation } from 'react-router-dom';
const drawerWidth = 240;
const Main = styled('main', { shouldForwardProp: (prop) => prop !== 'open' })(({ theme }) => ({
flexGrow: 1,
padding: theme.spacing(3),
transition: theme.transitions.create('margin', {
easing: theme.transitions.easing.sharp,
duration: theme.transitions.duration.leavingScreen,
}),
marginLeft: `-${drawerWidth}px`,
variants: [
{
props: ({ open }) => open,
style: {
transition: theme.transitions.create('margin', {
easing: theme.transitions.easing.easeOut,
duration: theme.transitions.duration.enteringScreen,
}),
marginLeft: 0,
},
},
],
}));
const NavStyles = makeStyles((theme) => ({
header: {
borderBottom: "2px solid rgba(0,0,0,0.1)",
display: "flex",
},
title:{
fontWeight: "600!important",
fontSize: "1.25rem!important",
}
}));
const DrawerHeader = styled('div')(({ theme }) => ({
display: 'flex',
alignItems: 'center',
padding: theme.spacing(0, 1),
background: 'rgb(246 248 249)',
// necessary for content to be below app bar
...theme.mixins.toolbar,
justifyContent: 'flex-end',
}));
export default function PersistentDrawerLeft({ handleDrawerClose, open}) {
const location = useLocation();
const theme = useTheme();
return (
<Drawer
sx={{
width: drawerWidth,
flexShrink: 0,
'& .MuiDrawer-paper': {
width: drawerWidth,
boxSizing: 'border-box',
},
}}
variant="persistent"
anchor="left"
open={open}
>
<DrawerHeader>
<IconButton onClick={handleDrawerClose}>
{theme.direction === 'ltr' ? <ChevronLeftIcon /> : <ChevronRightIcon />}
</IconButton>
</DrawerHeader>
<Divider />
<List>
<ListItem key={'Dashboard'} disablePadding component={Link} to={'dashboard'} selected={location.pathname=='/dashboard'}>
<ListItemButton>
<ListItemIcon>
<PersonIcon />
</ListItemIcon>
<ListItemText primary={'Dashboard'} />
</ListItemButton>
</ListItem>
<ListItem key={'User'} disablePadding component={Link} to={'user'} selected={location.pathname=='/user'}>
<ListItemButton>
<ListItemIcon>
<PersonIcon />
</ListItemIcon>
<ListItemText primary={'User'} />
</ListItemButton>
</ListItem>
<ListItem key={'Quotes'} disablePadding component={Link} to={'quotes'} selected={location.pathname=='/quotes'}>
<ListItemButton>
<ListItemIcon>
<MonetizationOnIcon />
</ListItemIcon>
<ListItemText primary={'Quotes'} />
</ListItemButton>
</ListItem>
<ListItem key={'WorkOrder'} disablePadding component={Link} to={'workOrder'} selected={location.pathname=='/workOrder'}>
<ListItemButton>
<ListItemIcon>
<TextSnippetIcon />
</ListItemIcon>
<ListItemText primary={'Work Order'} />
</ListItemButton>
</ListItem>
<ListItem key={'Contacts'} disablePadding component={Link} to={'contacts'} selected={location.pathname=='/contacts'}>
<ListItemButton>
<ListItemIcon>
<TextSnippetIcon />
</ListItemIcon>
<ListItemText primary={'Contacts'} />
</ListItemButton>
</ListItem>
<ListItem key={'AddressBook'} disablePadding component={Link} to={'addressBook'} selected={location.pathname=='/addressBook'}>
<ListItemButton>
<ListItemIcon>
<TextSnippetIcon />
</ListItemIcon>
<ListItemText primary={'Address Book'} />
</ListItemButton>
</ListItem>
</List>
</Drawer>
);
}