aboutsummaryrefslogtreecommitdiff
path: root/modern/src/UserPage.js
diff options
context:
space:
mode:
authorAnton Tananaev <anton@traccar.org>2022-05-06 14:23:44 -0700
committerAnton Tananaev <anton@traccar.org>2022-05-06 14:23:44 -0700
commita0406374030e930b8bd8032900e83b4a432ae28a (patch)
tree7ac2a8c1ac60289477a482fd57e669362affdc7b /modern/src/UserPage.js
parent3812292cc4413efff1358eb34cc5bccab9d1cbae (diff)
downloadtrackermap-web-a0406374030e930b8bd8032900e83b4a432ae28a.tar.gz
trackermap-web-a0406374030e930b8bd8032900e83b4a432ae28a.tar.bz2
trackermap-web-a0406374030e930b8bd8032900e83b4a432ae28a.zip
Fix account and server updates
Diffstat (limited to 'modern/src/UserPage.js')
-rw-r--r--modern/src/UserPage.js13
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>