import React, { useState } from 'react'; import TextField from '@material-ui/core/TextField'; import { Accordion, AccordionSummary, AccordionDetails, makeStyles, Typography, } 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'; 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" /> 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;