diff options
author | Anton Tananaev <anton.tananaev@gmail.com> | 2021-09-03 09:41:20 -0700 |
---|---|---|
committer | Anton Tananaev <anton.tananaev@gmail.com> | 2021-09-03 09:41:20 -0700 |
commit | 6ac6ceaed16b2ae5ef58ba599d24a868ac2f816a (patch) | |
tree | edd24c732d6439e6fb3c03f021d9f0842468d474 /modern/src/settings | |
parent | 105e4ec887e249ec47db83095504012bad22df80 (diff) | |
download | trackermap-web-6ac6ceaed16b2ae5ef58ba599d24a868ac2f816a.tar.gz trackermap-web-6ac6ceaed16b2ae5ef58ba599d24a868ac2f816a.tar.bz2 trackermap-web-6ac6ceaed16b2ae5ef58ba599d24a868ac2f816a.zip |
Finish migrations
Diffstat (limited to 'modern/src/settings')
-rw-r--r-- | modern/src/settings/MaintenancesPage.js | 4 | ||||
-rw-r--r-- | modern/src/settings/NotificationsPage.js | 2 | ||||
-rw-r--r-- | modern/src/settings/OptionsLayout/useRoutes.js | 26 |
3 files changed, 18 insertions, 14 deletions
diff --git a/modern/src/settings/MaintenancesPage.js b/modern/src/settings/MaintenancesPage.js index a59a24e1..89b0279e 100644 --- a/modern/src/settings/MaintenancesPage.js +++ b/modern/src/settings/MaintenancesPage.js @@ -41,9 +41,9 @@ const MaintenancesView = ({ updateTimestamp, onMenuClick }) => { if (attribute && attribute.dataType) { switch (attribute.dataType) { case 'speed': - return formatSpeed(value, speedUnit); + return formatSpeed(value, speedUnit, t); case 'distance': - return formatDistance(value, distanceUnit); + return formatDistance(value, distanceUnit, t); default: return value; } diff --git a/modern/src/settings/NotificationsPage.js b/modern/src/settings/NotificationsPage.js index 01483637..0d49d5ab 100644 --- a/modern/src/settings/NotificationsPage.js +++ b/modern/src/settings/NotificationsPage.js @@ -62,7 +62,7 @@ const NotificationsView = ({ updateTimestamp, onMenuClick }) => { </IconButton> </TableCell> <TableCell>{t(prefixString('event', item.type))}</TableCell> - <TableCell>{formatBoolean(item.always)}</TableCell> + <TableCell>{formatBoolean(item.always, t)}</TableCell> <TableCell>{formatList('alarm', item.attributes.alarms)}</TableCell> <TableCell>{formatList('notificator', item.notificators)}</TableCell> </TableRow> 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, |