aboutsummaryrefslogtreecommitdiff
path: root/modern
diff options
context:
space:
mode:
authorDesmond Kyeremeh <elDekyfin@gmail.com>2021-07-02 15:18:00 +0000
committerDesmond Kyeremeh <elDekyfin@gmail.com>2021-07-02 15:18:00 +0000
commit52f565bcb5e14b77757676013d1328ead92e13fa (patch)
tree0a52d564c7be4533fec878df451298e27541babf /modern
parent191ec6d655edd4f77ba40f3a42ae277ea769cc0a (diff)
downloadtrackermap-web-52f565bcb5e14b77757676013d1328ead92e13fa.tar.gz
trackermap-web-52f565bcb5e14b77757676013d1328ead92e13fa.tar.bz2
trackermap-web-52f565bcb5e14b77757676013d1328ead92e13fa.zip
Account Route
Diffstat (limited to 'modern')
-rw-r--r--modern/src/settings/OptionsLayout/index.js7
-rw-r--r--modern/src/settings/OptionsLayout/useRoutes.js17
2 files changed, 19 insertions, 5 deletions
diff --git a/modern/src/settings/OptionsLayout/index.js b/modern/src/settings/OptionsLayout/index.js
index f6f1e4b8..4bcb380e 100644
--- a/modern/src/settings/OptionsLayout/index.js
+++ b/modern/src/settings/OptionsLayout/index.js
@@ -1,5 +1,5 @@
import React, { useState, useEffect } from 'react';
-import { useHistory, useLocation } from 'react-router-dom';
+import { useLocation } from 'react-router-dom';
import {
Typography,
Divider,
@@ -49,14 +49,13 @@ const useStyles = makeStyles(theme => ({
const OptionsLayout = ({ children }) => {
const classes = useStyles();
- const history = useHistory();
const location = useLocation();
const [openDrawer, setOpenDrawer] = useState(false);
const [optionTitle, setOptionTitle] = useState();
const routes = useRoutes();
useEffect(() => {
- const activeRoute = routes.find(route => route.href === location.pathname);
+ const activeRoute = routes.find(route => location.pathname.match(route.match));
setOptionTitle(activeRoute.name);
}, [location, routes]);
@@ -82,7 +81,7 @@ const OptionsLayout = ({ children }) => {
classes={{ root: classes.drawerContainer, paper: classes.drawer }}
>
<div className={classes.drawerHeader}>
- <IconButton onClick={() => history.push('/')}>
+ <IconButton component="a" href="/">
<ArrowBackIcon />
</IconButton>
<Typography variant="h6" color="inherit" noWrap>
diff --git a/modern/src/settings/OptionsLayout/useRoutes.js b/modern/src/settings/OptionsLayout/useRoutes.js
index e53e8fd4..6796a563 100644
--- a/modern/src/settings/OptionsLayout/useRoutes.js
+++ b/modern/src/settings/OptionsLayout/useRoutes.js
@@ -8,9 +8,14 @@ import StorageIcon from '@material-ui/icons/Storage';
import BuildIcon from '@material-ui/icons/Build';
import PeopleIcon from '@material-ui/icons/People';
import BarChartIcon from '@material-ui/icons/BarChart';
-import { getIsAdmin } from '../../selectors';
+import { getIsAdmin, getUserId } from '../../selectors';
import t from '../../common/localization';
+const accountRoute = {
+ name: t('settingsUser'),
+ icon: <PersonIcon />
+};
+
const adminRoutes = [
{ subheader: t('userAdmin') },
{
@@ -31,32 +36,39 @@ const adminRoutes = [
];
const mainRoutes = [
+ accountRoute,
{
+ match: 'geofence',
name: t('sharedGeofences'),
href: '/geofences',
icon: <CreateIcon />
},
{
+ match: 'notification',
name: t('sharedNotifications'),
href: '/settings/notifications',
icon: <NotificationsIcon />
},
{
+ match: 'group',
name: t('settingsGroups'),
href: '/settings/groups',
icon: <FolderIcon />
},
{
+ match: 'driver',
name: t('sharedDrivers'),
href: '/settings/drivers',
icon: <PersonIcon />
},
{
+ match: 'attribute',
name: t('sharedComputedAttributes'),
href: '/settings/attributes',
icon: <StorageIcon />
},
{
+ match: 'maintenance',
name: t('sharedMaintenance'),
href: '/settings/maintenances',
icon: <BuildIcon />
@@ -65,6 +77,9 @@ const mainRoutes = [
export default () => {
const isAdmin = useSelector(getIsAdmin);
+ const userId = useSelector(getUserId);
+ accountRoute.match = accountRoute.href = `/user/${userId}`;
+
return useMemo(() => [...mainRoutes, ...(isAdmin ? adminRoutes : [])], [
isAdmin
]);