aboutsummaryrefslogtreecommitdiff
path: root/modern/src/settings/components
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/components
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/components')
-rw-r--r--modern/src/settings/components/EditItemView.js19
1 files changed, 11 insertions, 8 deletions
diff --git a/modern/src/settings/components/EditItemView.js b/modern/src/settings/components/EditItemView.js
index 8c3df663..a5ac31b1 100644
--- a/modern/src/settings/components/EditItemView.js
+++ b/modern/src/settings/components/EditItemView.js
@@ -37,17 +37,20 @@ const EditItemView = ({
const { id } = useParams();
useEffectAsync(async () => {
- if (id) {
- const response = await fetch(`/api/${endpoint}/${id}`);
- if (response.ok) {
- setItem(await response.json());
+ console.log(item);
+ if (!item) {
+ if (id) {
+ const response = await fetch(`/api/${endpoint}/${id}`);
+ if (response.ok) {
+ setItem(await response.json());
+ } else {
+ throw Error(await response.text());
+ }
} else {
- throw Error(await response.text());
+ setItem(defaultItem || {});
}
- } else {
- setItem(defaultItem || {});
}
- }, [id]);
+ }, [id, item, defaultItem]);
const handleSave = useCatch(async () => {
let url = `/api/${endpoint}`;