aboutsummaryrefslogtreecommitdiff
path: root/modern/src/settings/UserPage.js
diff options
context:
space:
mode:
authorAnton Tananaev <anton@traccar.org>2022-06-22 06:56:51 -0700
committerAnton Tananaev <anton@traccar.org>2022-06-22 07:19:50 -0700
commitb1dd7bfd252278649622c99b4153e9cfa563cd9f (patch)
tree3a4ff1317cba795aebf3ec59d738b447c1e397d3 /modern/src/settings/UserPage.js
parent9f03571e5c6bd532ac177615066f830e1c8939e3 (diff)
downloadtrackermap-web-b1dd7bfd252278649622c99b4153e9cfa563cd9f.tar.gz
trackermap-web-b1dd7bfd252278649622c99b4153e9cfa563cd9f.tar.bz2
trackermap-web-b1dd7bfd252278649622c99b4153e9cfa563cd9f.zip
Avoid loading current user
Diffstat (limited to 'modern/src/settings/UserPage.js')
-rw-r--r--modern/src/settings/UserPage.js8
1 files changed, 5 insertions, 3 deletions
diff --git a/modern/src/settings/UserPage.js b/modern/src/settings/UserPage.js
index 964291e8..6e637d49 100644
--- a/modern/src/settings/UserPage.js
+++ b/modern/src/settings/UserPage.js
@@ -1,4 +1,5 @@
import React, { useEffect, useState } from 'react';
+import { useParams } from 'react-router-dom';
import {
Accordion,
AccordionSummary,
@@ -51,12 +52,13 @@ const UserPage = () => {
const admin = useAdministrator();
const manager = useManager();
- const currentUserId = useSelector((state) => state.session.user.id);
+ const currentUser = useSelector((state) => state.session.user);
const commonUserAttributes = useCommonUserAttributes(t);
const userAttributes = useUserAttributes(t);
- const [item, setItem] = useState();
+ const { id } = useParams();
+ const [item, setItem] = useState(id === currentUser.id.toString() ? currentUser : null);
const query = useQuery();
const [queryHandled, setQueryHandled] = useState(false);
@@ -74,7 +76,7 @@ const UserPage = () => {
}, [item, queryHandled, setQueryHandled, attribute]);
const onItemSaved = (result) => {
- if (result.id === currentUserId) {
+ if (result.id === currentUser.id) {
dispatch(sessionActions.updateUser(result));
}
};