aboutsummaryrefslogtreecommitdiff
path: root/modern/src/settings/OptionsLayout/useRoutes.js
diff options
context:
space:
mode:
authorAnton Tananaev <anton.tananaev@gmail.com>2021-09-03 09:41:20 -0700
committerAnton Tananaev <anton.tananaev@gmail.com>2021-09-03 09:41:20 -0700
commit6ac6ceaed16b2ae5ef58ba599d24a868ac2f816a (patch)
treeedd24c732d6439e6fb3c03f021d9f0842468d474 /modern/src/settings/OptionsLayout/useRoutes.js
parent105e4ec887e249ec47db83095504012bad22df80 (diff)
downloadtrackermap-web-6ac6ceaed16b2ae5ef58ba599d24a868ac2f816a.tar.gz
trackermap-web-6ac6ceaed16b2ae5ef58ba599d24a868ac2f816a.tar.bz2
trackermap-web-6ac6ceaed16b2ae5ef58ba599d24a868ac2f816a.zip
Finish migrations
Diffstat (limited to 'modern/src/settings/OptionsLayout/useRoutes.js')
-rw-r--r--modern/src/settings/OptionsLayout/useRoutes.js26
1 files changed, 15 insertions, 11 deletions
diff --git a/modern/src/settings/OptionsLayout/useRoutes.js b/modern/src/settings/OptionsLayout/useRoutes.js
index 4f0621ca..b6ed75fa 100644
--- a/modern/src/settings/OptionsLayout/useRoutes.js
+++ b/modern/src/settings/OptionsLayout/useRoutes.js
@@ -9,13 +9,9 @@ import BuildIcon from '@material-ui/icons/Build';
import PeopleIcon from '@material-ui/icons/People';
import BarChartIcon from '@material-ui/icons/BarChart';
import { getIsAdmin, getUserId } from '../../common/selectors';
+import { useTranslation } from '../../LocalizationProvider';
-const accountRoute = {
- name: t('settingsUser'),
- icon: <PersonIcon />,
-};
-
-const adminRoutes = [
+const useAdminRoutes = (t) => useMemo([
{ subheader: t('userAdmin') },
{
name: t('settingsServer'),
@@ -32,10 +28,14 @@ const adminRoutes = [
href: '/admin/statistics',
icon: <BarChartIcon />,
},
-];
+], [t]);
-const mainRoutes = [
- accountRoute,
+const useMainRoutes = (t, userId) => useMemo([
+ {
+ name: t('settingsUser'),
+ href: `/user/${userId}`,
+ icon: <PersonIcon />,
+ },
{
match: 'geofence',
name: t('sharedGeofences'),
@@ -72,12 +72,16 @@ const mainRoutes = [
href: '/settings/maintenances',
icon: <BuildIcon />,
},
-];
+], [t, userId]);
export default () => {
+ const t = useTranslation();
+
const isAdmin = useSelector(getIsAdmin);
const userId = useSelector(getUserId);
- accountRoute.href = `/user/${userId}`;
+
+ const mainRoutes = useMainRoutes(t, userId);
+ const adminRoutes = useAdminRoutes(t);
return useMemo(() => [...mainRoutes, ...(isAdmin ? adminRoutes : [])], [
isAdmin,