/* eslint-disable no-nested-ternary */ import React from 'react'; import { makeStyles, Theme, createStyles } from '@material-ui/core/styles'; import List from '@material-ui/core/List'; import Link, { LinkProps } from '@material-ui/core/Link'; import ListItem from '@material-ui/core/ListItem'; import Collapse from '@material-ui/core/Collapse'; import ListItemText from '@material-ui/core/ListItemText'; import Typography from '@material-ui/core/Typography'; import ExpandLess from '@material-ui/icons/ExpandLess'; import ExpandMore from '@material-ui/icons/ExpandMore'; import Breadcrumbs from '@material-ui/core/Breadcrumbs'; import { Route, MemoryRouter } from 'react-router'; import { Link as RouterLink } from 'react-router-dom'; import { Omit } from '@material-ui/types'; interface ListItemLinkProps extends LinkProps { to: string; open?: boolean; } const breadcrumbNameMap: { [key: string]: string } = { '/inbox': 'Inbox', '/inbox/important': 'Important', '/trash': 'Trash', '/spam': 'Spam', '/drafts': 'Drafts', }; function ListItemLink(props: Omit) { const { to, open, ...other } = props; const primary = breadcrumbNameMap[to]; return (
  • {open != null ? open ? : : null}
  • ); } const useStyles = makeStyles((theme: Theme) => createStyles({ root: { display: 'flex', flexDirection: 'column', width: 360, }, lists: { backgroundColor: theme.palette.background.paper, marginTop: theme.spacing(1), }, nested: { paddingLeft: theme.spacing(4), }, }), ); interface LinkRouterProps extends LinkProps { to: string; replace?: boolean; } const LinkRouter = (props: LinkRouterProps) => ; export default function RouterBreadcrumbs() { const classes = useStyles(); const [open, setOpen] = React.useState(true); const handleClick = () => { setOpen((prevOpen) => !prevOpen); }; return (
    {({ location }) => { const pathnames = location.pathname.split('/').filter((x) => x); return ( Home {pathnames.map((value, index) => { const last = index === pathnames.length - 1; const to = `/${pathnames.slice(0, index + 1).join('/')}`; return last ? ( {breadcrumbNameMap[to]} ) : ( {breadcrumbNameMap[to]} ); })} ); }}
    ); }