From 0ab07c40f48889727b1503eaedb5daa8f344dd19 Mon Sep 17 00:00:00 2001 From: Ashutosh Bishnoi Date: Mon, 17 May 2021 15:10:29 +0530 Subject: Initial draft of Reports Development --- modern/src/reports/ReportLayoutPage.js | 60 +++++++++++++++++++--------------- 1 file changed, 33 insertions(+), 27 deletions(-) (limited to 'modern/src/reports') diff --git a/modern/src/reports/ReportLayoutPage.js b/modern/src/reports/ReportLayoutPage.js index e203b5a..4ffc881 100644 --- a/modern/src/reports/ReportLayoutPage.js +++ b/modern/src/reports/ReportLayoutPage.js @@ -1,5 +1,5 @@ import React, { useState } from 'react'; -import { AppBar, Toolbar, Typography, List, ListItem, ListItemText, ListItemIcon, Divider, Drawer, makeStyles, useMediaQuery, IconButton } from '@material-ui/core'; +import { AppBar, Toolbar, Typography, List, ListItem, ListItemText, ListItemIcon, Divider, Drawer, makeStyles, IconButton, Hidden } 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'; @@ -10,7 +10,7 @@ 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 { Link, useHistory, useLocation } from 'react-router-dom'; import t from '../common/localization'; @@ -21,9 +21,6 @@ const useStyles = makeStyles(theme => ({ }, drawerContainer: { width: theme.dimensions.drawerWidth, - [theme.breakpoints.down("md")]: { - width: 0, - } }, drawer: { width: theme.dimensions.drawerWidth, @@ -53,29 +50,32 @@ const useStyles = makeStyles(theme => ({ }, })); +const routes = [ + { name: t('reportRoute'), href: '/reports/route', icon: }, + { name: t('reportEvents'), href: '/reports/event', icon: }, + { name: t('reportTrips'), href: '/reports/trip', icon: }, + { name: t('reportStops'), href: '/reports/stop', icon: }, + { name: t('reportSummary'), href: '/reports/summary', icon: }, + { name: t('reportChart'), href: '/reports/chart', icon: }, +]; + 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 location = useLocation(); const navigationList = ( - {routes.map(route => ( + {routes.map((route, index) => ( handleListItemClick(route)}> + to={route.href} + selected={route.href === location.pathname}> {route.icon} @@ -119,23 +119,29 @@ const ReportLayoutPage = ({ children, filter }) => { ); - const handleListItemClick = (route) => { - history.push(route.link); - } - return (
- {matchesMD && appBar} -
+ + {appBar} setOpenDrawer(!openDrawer)} classes={{paper: classes.drawer}}> - {!matchesMD && drawerHeader} + {drawerHeader} {navigationList} -
+ + +
+ + {drawerHeader} + {navigationList} + +
+
{filter} -- cgit v1.2.3