diff options
author | Anton Tananaev <anton@traccar.org> | 2022-05-23 06:44:15 -0700 |
---|---|---|
committer | Anton Tananaev <anton@traccar.org> | 2022-05-23 06:44:15 -0700 |
commit | ddcb42512e95e98806db0523e4d954484a6e48cc (patch) | |
tree | 795fbd841eb94ded02ce66a2a2c50c2cc52a7dcd /modern/src/common | |
parent | fdbc6762b10233950d9c84fc71a9a8c11823f0a9 (diff) | |
download | trackermap-web-ddcb42512e95e98806db0523e4d954484a6e48cc.tar.gz trackermap-web-ddcb42512e95e98806db0523e4d954484a6e48cc.tar.bz2 trackermap-web-ddcb42512e95e98806db0523e4d954484a6e48cc.zip |
Upgrade router and navigation
Diffstat (limited to 'modern/src/common')
-rw-r--r-- | modern/src/common/components/BottomMenu.js | 14 | ||||
-rw-r--r-- | modern/src/common/components/PageLayout.js | 6 |
2 files changed, 10 insertions, 10 deletions
diff --git a/modern/src/common/components/BottomMenu.js b/modern/src/common/components/BottomMenu.js index 30960396..7db4dff8 100644 --- a/modern/src/common/components/BottomMenu.js +++ b/modern/src/common/components/BottomMenu.js @@ -1,6 +1,6 @@ import React, { useState } from 'react'; import { useDispatch, useSelector } from 'react-redux'; -import { useHistory, useLocation } from 'react-router-dom'; +import { useNavigate, useLocation } from 'react-router-dom'; import { Paper, BottomNavigation, BottomNavigationAction, Menu, MenuItem, Typography, } from '@material-ui/core'; @@ -16,7 +16,7 @@ import { useTranslation } from './LocalizationProvider'; import { useReadonly } from '../util/permissions'; const BottomMenu = () => { - const history = useHistory(); + const navigate = useNavigate(); const location = useLocation(); const dispatch = useDispatch(); const t = useTranslation(); @@ -41,26 +41,26 @@ const BottomMenu = () => { const handleAccount = () => { setAnchorEl(null); - history.push(`/settings/user/${userId}`); + navigate(`/settings/user/${userId}`); }; const handleLogout = async () => { setAnchorEl(null); await fetch('/api/session', { method: 'DELETE' }); - history.push('/login'); + navigate('/login'); dispatch(sessionActions.updateUser(null)); }; const handleSelection = (event, value) => { switch (value) { case 0: - history.push('/'); + navigate('/'); break; case 1: - history.push('/reports/route'); + navigate('/reports/route'); break; case 2: - history.push('/settings/preferences'); + navigate('/settings/preferences'); break; case 3: if (readonly) { diff --git a/modern/src/common/components/PageLayout.js b/modern/src/common/components/PageLayout.js index a1f117c4..d92b71c3 100644 --- a/modern/src/common/components/PageLayout.js +++ b/modern/src/common/components/PageLayout.js @@ -4,7 +4,7 @@ import { } 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 { useNavigate } from 'react-router-dom'; import { useTranslation } from './LocalizationProvider'; const useStyles = makeStyles((theme) => ({ @@ -56,7 +56,7 @@ const PageTitle = ({ breadcrumbs }) => { const PageLayout = ({ menu, breadcrumbs, children }) => { const classes = useStyles(); - const history = useHistory(); + const navigate = useNavigate(); const [openDrawer, setOpenDrawer] = useState(false); @@ -71,7 +71,7 @@ const PageLayout = ({ menu, breadcrumbs, children }) => { > <div className={classes.toolbar}> <Toolbar> - <IconButton color="inherit" edge="start" onClick={() => history.push('/')}> + <IconButton color="inherit" edge="start" onClick={() => navigate('/')}> <ArrowBackIcon /> </IconButton> <PageTitle breadcrumbs={breadcrumbs} /> |