From 6ac6ceaed16b2ae5ef58ba599d24a868ac2f816a Mon Sep 17 00:00:00 2001 From: Anton Tananaev Date: Fri, 3 Sep 2021 09:41:20 -0700 Subject: Finish migrations --- modern/src/settings/OptionsLayout/useRoutes.js | 26 +++++++++++++++----------- 1 file changed, 15 insertions(+), 11 deletions(-) (limited to 'modern/src/settings/OptionsLayout') 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: , -}; - -const adminRoutes = [ +const useAdminRoutes = (t) => useMemo([ { subheader: t('userAdmin') }, { name: t('settingsServer'), @@ -32,10 +28,14 @@ const adminRoutes = [ href: '/admin/statistics', icon: , }, -]; +], [t]); -const mainRoutes = [ - accountRoute, +const useMainRoutes = (t, userId) => useMemo([ + { + name: t('settingsUser'), + href: `/user/${userId}`, + icon: , + }, { match: 'geofence', name: t('sharedGeofences'), @@ -72,12 +72,16 @@ const mainRoutes = [ href: '/settings/maintenances', icon: , }, -]; +], [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, -- cgit v1.2.3