-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathdashboard.js
More file actions
57 lines (50 loc) · 1.71 KB
/
dashboard.js
File metadata and controls
57 lines (50 loc) · 1.71 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
document.addEventListener("DOMContentLoaded", async () => {
const dashboardEl = document.getElementById("dashboard");
if (!dashboardEl) return;
const token = getAuthToken();
if (!token) {
window.location.replace("index.html");
return;
}
// Restore current user from storage (used in settings UI)
try {
currentUser = JSON.parse(localStorage.getItem(STORAGE_USER_KEY) || "null");
} catch {
currentUser = null;
}
// Restore onboarding flags (set during signup flow on index.html)
const isGuest = token.startsWith("guest_");
if (isGuest) {
onboardingMode = null;
shouldShowOnboarding = false;
localStorage.removeItem("planwise_should_show_onboarding");
localStorage.removeItem("planwise_onboarding_mode");
} else {
shouldShowOnboarding = localStorage.getItem("planwise_should_show_onboarding") === "1";
onboardingMode = localStorage.getItem("planwise_onboarding_mode") || null;
}
const ok = await loadUserData();
if (!ok) {
window.location.replace("index.html");
return;
}
showView("dashboard");
initAuth(); // includes logout/settings handlers used on dashboard
if (isGuest) {
const logoutBtn = document.getElementById("logoutBtn");
if (logoutBtn) {
logoutBtn.title = "Login";
logoutBtn.setAttribute("aria-label", "Login");
logoutBtn.innerHTML = `
<svg width="20" height="20" viewBox="0 0 20 20" fill="none" stroke="currentColor" stroke-width="2">
<path d="M11 3h5a2 2 0 0 1 2 2v10a2 2 0 0 1-2 2h-5"/>
<path d="M7 7l-4 4 4 4"/>
<path d="M3 11h10"/>
</svg>
`.trim();
}
}
initDashboard();
window.AxisNotifications?.init?.();
window.AxisOnboardingTour?.maybeStart?.();
});