aboutsummaryrefslogtreecommitdiff
path: root/modern/src/settings/PreferencesPage.js
diff options
context:
space:
mode:
authorAnton Tananaev <anton@traccar.org>2022-06-11 18:32:36 -0700
committerAnton Tananaev <anton@traccar.org>2022-06-11 18:32:36 -0700
commite7995f3b7a6b0828b81bebaf556ef7afb59bef61 (patch)
treebd9aebc2ed24253ca0bb2a604ac65ae96730a3d1 /modern/src/settings/PreferencesPage.js
parent0aecbc3bf856b17f42e363eff2bac4fb0ce1f7ed (diff)
downloadtrackermap-web-e7995f3b7a6b0828b81bebaf556ef7afb59bef61.tar.gz
trackermap-web-e7995f3b7a6b0828b81bebaf556ef7afb59bef61.tar.bz2
trackermap-web-e7995f3b7a6b0828b81bebaf556ef7afb59bef61.zip
Automatically add map keys
Diffstat (limited to 'modern/src/settings/PreferencesPage.js')
-rw-r--r--modern/src/settings/PreferencesPage.js32
1 files changed, 18 insertions, 14 deletions
diff --git a/modern/src/settings/PreferencesPage.js b/modern/src/settings/PreferencesPage.js
index c128e5e4..2a2674f7 100644
--- a/modern/src/settings/PreferencesPage.js
+++ b/modern/src/settings/PreferencesPage.js
@@ -1,17 +1,8 @@
import React from 'react';
+import { useSelector } from 'react-redux';
+import { useNavigate } from 'react-router-dom';
import {
- Accordion,
- AccordionSummary,
- AccordionDetails,
- Typography,
- Container,
- FormControl,
- InputLabel,
- Select,
- MenuItem,
- Checkbox,
- FormControlLabel,
- FormGroup,
+ Accordion, AccordionSummary, AccordionDetails, Typography, Container, FormControl, InputLabel, Select, MenuItem, Checkbox, FormControlLabel, FormGroup,
} from '@mui/material';
import makeStyles from '@mui/styles/makeStyles';
import ExpandMoreIcon from '@mui/icons-material/ExpandMore';
@@ -38,8 +29,11 @@ const useStyles = makeStyles((theme) => ({
const PreferencesPage = () => {
const classes = useStyles();
+ const navigate = useNavigate();
const t = useTranslation();
+ const userId = useSelector((state) => state.session.user.id);
+
const { languages, language, setLanguage } = useLocalization();
const languageList = Object.entries(languages).map((values) => ({ code: values[0], name: values[1].name }));
@@ -96,11 +90,21 @@ const PreferencesPage = () => {
<Select
label={t('mapActive')}
value={activeMapStyles}
- onChange={(e) => setActiveMapStyles(e.target.value)}
+ onChange={(e, child) => {
+ const clicked = mapStyles.find((s) => s.id === child.props.value);
+ if (clicked.available) {
+ setActiveMapStyles(e.target.value);
+ } else if (clicked.id !== 'custom') {
+ const query = new URLSearchParams({ attribute: clicked.attribute });
+ navigate(`/settings/user/${userId}?${query.toString()}`);
+ }
+ }}
multiple
>
{mapStyles.map((style) => (
- <MenuItem key={style.id} value={style.id}>{style.title}</MenuItem>
+ <MenuItem key={style.id} value={style.id}>
+ <Typography component="span" color={style.available ? 'textPrimary' : 'error'}>{style.title}</Typography>
+ </MenuItem>
))}
</Select>
</FormControl>