diff options
Diffstat (limited to 'modern/src/UserPage.js')
-rw-r--r-- | modern/src/UserPage.js | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/modern/src/UserPage.js b/modern/src/UserPage.js index ce1e082f..549d7c59 100644 --- a/modern/src/UserPage.js +++ b/modern/src/UserPage.js @@ -10,6 +10,8 @@ import EditAttributesView from './attributes/EditAttributesView'; import LinkField from './form/LinkField'; import { useTranslation } from './LocalizationProvider'; import useUserAttributes from './attributes/useUserAttributes'; +import { useDispatch, useSelector } from 'react-redux'; +import { sessionActions } from './store'; const useStyles = makeStyles(() => ({ details: { @@ -19,16 +21,25 @@ const useStyles = makeStyles(() => ({ 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 ( - <EditItemView endpoint="users" item={item} setItem={setItem} validate={validate}> + <EditItemView endpoint="users" item={item} setItem={setItem} validate={validate} onItemSaved={onItemSaved}> {item && ( <> <Accordion defaultExpanded> |