fix: make account menu actions reliable

This commit is contained in:
2026-07-29 23:29:01 -04:00
parent 8f82000e31
commit 99d7e8f121
+3 -8
View File
@@ -595,7 +595,7 @@ function wireToolbar() {
await protectedFetch("/api/auth/logout", { method: "POST" });
} finally {
clearDraft();
location.assign("/");
location.replace("/");
}
});
document.getElementById("btn-add-actuator").addEventListener("click", () => {
@@ -664,6 +664,8 @@ async function init() {
return;
}
const { user } = await meResponse.json();
if (user.role === "admin")
document.getElementById("menu-admin").classList.remove("hidden");
state.plan = loadFromStorage(user.id) ?? blankPlan();
const response = await fetch("/api/plans");
if (response.ok) {
@@ -687,13 +689,6 @@ async function init() {
wireToolbar();
wirePwa();
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({
state,
renderBlendRows: renderBlend,