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 './EditItemView'; import EditAttributesView from './attributes/EditAttributesView'; import LinkField from './form/LinkField'; import { useTranslation } from './LocalizationProvider'; import useUserAttributes from './attributes/useUserAttributes'; import { sessionActions } from './store'; import SelectField from './form/SelectField'; 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 ( {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;