import React, { useState } from 'react'; import TextField from '@material-ui/core/TextField'; import { Accordion, AccordionSummary, AccordionDetails, makeStyles, Typography, FormControl, InputLabel, Select, MenuItem, } from '@material-ui/core'; import ExpandMoreIcon from '@material-ui/icons/ExpandMore'; import { useDispatch, useSelector } from 'react-redux'; import EditItemView from './components/EditItemView'; import EditAttributesView from './components/EditAttributesView'; import LinkField from '../common/components/LinkField'; import { useTranslation } from '../common/components/LocalizationProvider'; import useUserAttributes from '../common/attributes/useUserAttributes'; import { sessionActions } from '../store'; import SelectField from '../common/components/SelectField'; import SettingsMenu from './components/SettingsMenu'; const useStyles = makeStyles(() => ({ details: { flexDirection: 'column', }, })); const UserPage = () => { const classes = useStyles(); const dispatch = useDispatch(); const t = useTranslation(); const currentUserId = useSelector((state) => state.session.user.id); const userAttributes = useUserAttributes(t); const [item, setItem] = useState(); const onItemSaved = (result) => { if (result.id === currentUserId) { dispatch(sessionActions.updateUser(result)); } }; const validate = () => item && item.name && item.email && (item.id || item.password); return ( } breadcrumbs={['settingsTitle', 'settingsUser']} > {item && ( <> }> {t('sharedRequired')} setItem({ ...item, name: event.target.value })} label={t('sharedName')} variant="filled" /> setItem({ ...item, email: event.target.value })} label={t('userEmail')} variant="filled" /> setItem({ ...item, password: event.target.value })} label={t('userPassword')} variant="filled" /> }> {t('sharedPreferences')} setItem({ ...item, phone: event.target.value })} label={t('sharedPhone')} variant="filled" /> {t('settingsSpeedUnit')} {t('settingsDistanceUnit')} {t('settingsVolumeUnit')} setItem({ ...item, attributes: { ...item.attributes, timezone: e.target.value } })} endpoint="/api/server/timezones" keyGetter={(it) => it} titleGetter={(it) => it} label={t('sharedTimezone')} variant="filled" /> setItem({ ...item, poiLayer: event.target.value })} label={t('mapPoiLayer')} variant="filled" /> }> {t('sharedAttributes')} setItem({ ...item, attributes })} definitions={userAttributes} /> {item.id && ( }> {t('sharedConnections')} )} )} ); }; export default UserPage;