fix: make account menu actions reliable
This commit is contained in:
+3
-8
@@ -595,7 +595,7 @@ function wireToolbar() {
|
|||||||
await protectedFetch("/api/auth/logout", { method: "POST" });
|
await protectedFetch("/api/auth/logout", { method: "POST" });
|
||||||
} finally {
|
} finally {
|
||||||
clearDraft();
|
clearDraft();
|
||||||
location.assign("/");
|
location.replace("/");
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
document.getElementById("btn-add-actuator").addEventListener("click", () => {
|
document.getElementById("btn-add-actuator").addEventListener("click", () => {
|
||||||
@@ -664,6 +664,8 @@ async function init() {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const { user } = await meResponse.json();
|
const { user } = await meResponse.json();
|
||||||
|
if (user.role === "admin")
|
||||||
|
document.getElementById("menu-admin").classList.remove("hidden");
|
||||||
state.plan = loadFromStorage(user.id) ?? blankPlan();
|
state.plan = loadFromStorage(user.id) ?? blankPlan();
|
||||||
const response = await fetch("/api/plans");
|
const response = await fetch("/api/plans");
|
||||||
if (response.ok) {
|
if (response.ok) {
|
||||||
@@ -687,13 +689,6 @@ async function init() {
|
|||||||
wireToolbar();
|
wireToolbar();
|
||||||
wirePwa();
|
wirePwa();
|
||||||
wireSectionNav();
|
wireSectionNav();
|
||||||
fetch("/api/auth/me")
|
|
||||||
.then((r) => (r.ok ? r.json() : null))
|
|
||||||
.then((body) => {
|
|
||||||
if (body?.user?.role === "admin")
|
|
||||||
document.getElementById("menu-admin").classList.remove("hidden");
|
|
||||||
})
|
|
||||||
.catch(() => {});
|
|
||||||
initPrefillPanel({
|
initPrefillPanel({
|
||||||
state,
|
state,
|
||||||
renderBlendRows: renderBlend,
|
renderBlendRows: renderBlend,
|
||||||
|
|||||||
Reference in New Issue
Block a user