import React, { useState } from 'react'; import { AppBar, Toolbar, Typography, List, ListItem, ListItemText, ListItemIcon, Divider, Grid, Paper, Drawer, makeStyles, useMediaQuery, IconButton } from '@material-ui/core'; import { useTheme } from "@material-ui/core/styles"; import MenuIcon from '@material-ui/icons/Menu'; import TimelineIcon from '@material-ui/icons/Timeline'; import PauseCircleFilledIcon from '@material-ui/icons/PauseCircleFilled'; import PlayCircleFilledIcon from '@material-ui/icons/PlayCircleFilled'; import NotificationsActiveIcon from '@material-ui/icons/NotificationsActive'; import FormatListBulletedIcon from '@material-ui/icons/FormatListBulleted'; import TrendingUpIcon from '@material-ui/icons/TrendingUp'; import ArrowBackIcon from '@material-ui/icons/ArrowBack'; import { useHistory } from 'react-router-dom'; import t from '../common/localization'; const useStyles = makeStyles(theme => ({ root: { height: '100%', display: 'flex', }, drawer: { width: 360, [theme.breakpoints.down("md")]: { width: 0, } }, content: { flex: 1, padding: theme.spacing(3), }, drawerPaper: { width: 360, [theme.breakpoints.down("md")]: { width: 320, } }, drawerHeader: { ...theme.mixins.toolbar, display: 'flex', alignItems: 'center', padding: theme.spacing(0, 1), }, toolbar: { [theme.breakpoints.down("md")]: { ...theme.mixins.toolbar, } }, form: { padding: theme.spacing(1, 2, 2), }, })); const ReportLayoutPage = ({ children, filter }) => { const classes = useStyles(); const history = useHistory(); const theme = useTheme(); const matchesMD = useMediaQuery(theme.breakpoints.down("md")); const [openDrawer, setOpenDrawer] = useState(false); const routes = [ { name: t('reportRoute'), link: '/reports/route', icon: , activeIndex: 0 }, { name: t('reportEvents'), link: '/reports/event', icon: , activeIndex: 1 }, { name: t('reportTrips'), link: '/reports/trip', icon: , activeIndex: 2 }, { name: t('reportStops'), link: '/reports/stop', icon: , activeIndex: 3 }, { name: t('reportSummary'), link: '/reports/summary', icon: , activeIndex: 4 }, { name: t('reportChart'), link: '/reports/chart', icon: , activeIndex: 5 }, ]; const navigationList = ( {routes.map(route => ( handleListItemClick(route)} > {route.icon} ))} ); const drawerHeader = ( <>
Reports
); const appBar = ( setOpenDrawer(!openDrawer)} className={classes.menuButton} > Reports ); const handleListItemClick = (route) => { history.push(route.link); } return (
{ matchesMD && appBar }
{filter}
); } export default ReportLayoutPage;