import React, { useState } from 'react'; import { AppBar, Breadcrumbs, Divider, Drawer, Hidden, IconButton, makeStyles, Toolbar, Typography, useMediaQuery, useTheme, } from '@material-ui/core'; import ArrowBackIcon from '@material-ui/icons/ArrowBack'; import MenuIcon from '@material-ui/icons/Menu'; import { useHistory } from 'react-router-dom'; import { useTranslation } from './LocalizationProvider'; const useStyles = makeStyles((theme) => ({ desktopRoot: { height: '100%', display: 'flex', }, mobileRoot: { height: '100%', display: 'flex', flexDirection: 'column', }, desktopDrawer: { width: theme.dimensions.drawerWidthDesktop, }, mobileDrawer: { width: theme.dimensions.drawerWidthTablet, }, toolbar: theme.mixins.toolbar, content: { flexGrow: 1, alignItems: 'stretch', overflow: 'auto', }, })); const PageTitle = ({ breadcrumbs }) => { const theme = useTheme(); const t = useTranslation(); const desktop = useMediaQuery(theme.breakpoints.up('md')); if (desktop) { return ( {t(breadcrumbs.at(0))} ); } return ( {breadcrumbs.slice(0, -1).map((breadcrumb) => ( {t(breadcrumb)} ))} {t(breadcrumbs.at(-1))} ); }; const PageLayout = ({ menu, breadcrumbs, children }) => { const classes = useStyles(); const history = useHistory(); const [openDrawer, setOpenDrawer] = useState(false); return ( <>
history.push('/')}>
{menu}
{children}
setOpenDrawer(false)} classes={{ paper: classes.mobileDrawer }} > {menu} setOpenDrawer(true)}>
{children}
); }; export default PageLayout;