import React, { useState } from 'react';
import { useHistory } from 'react-router-dom';
import { makeStyles } from '@material-ui/core/styles';
import { useDispatch } from 'react-redux';
import { sessionActions } from './store';
import AppBar from '@material-ui/core/AppBar';
import Toolbar from '@material-ui/core/Toolbar';
import Typography from '@material-ui/core/Typography';
import Button from '@material-ui/core/Button';
import IconButton from '@material-ui/core/IconButton';
import MenuIcon from '@material-ui/icons/Menu';
import Drawer from '@material-ui/core/Drawer';
import List from '@material-ui/core/List';
import ListSubheader from '@material-ui/core/ListSubheader';
import Divider from '@material-ui/core/Divider';
import ListItem from '@material-ui/core/ListItem';
import ListItemIcon from '@material-ui/core/ListItemIcon';
import ListItemText from '@material-ui/core/ListItemText';
import DashboardIcon from '@material-ui/icons/Dashboard';
import BarChartIcon from '@material-ui/icons/BarChart';
import SettingsIcon from '@material-ui/icons/Settings';
import t from './common/localization';
const useStyles = makeStyles(theme => ({
flex: {
flexGrow: 1
},
appBar: {
zIndex: theme.zIndex.drawer + 1,
},
list: {
width: 250
},
menuButton: {
marginLeft: -12,
marginRight: 20,
}
}));
const MainToolbar = () => {
const dispatch = useDispatch();
const [drawer, setDrawer] = useState(false);
const classes = useStyles();
const history = useHistory();
const openDrawer = () => { setDrawer(true) }
const closeDrawer = () => { setDrawer(false) }
const handleLogout = () => {
fetch('/api/session', { method: 'DELETE' }).then(response => {
if (response.ok) {
dispatch(sessionActions.authenticated(false));
history.push('/login');
}
})
}
return (
<>
Traccar
history.push('/')}>
{t('reportTitle')}
}>
{ history.push('/reports/route') }}>
{t('settingsTitle')}
}>
>
);
}
export default MainToolbar;