add logging to initializeApp

This commit is contained in:
chris 2025-08-10 09:29:50 -04:00
parent 6cb764faf7
commit 0cabc5288e

View File

@ -253,23 +253,32 @@ export function attachAdminDashboardListeners() {
// --- APP INITIALIZER ---
function initializeApp() {
console.log("A. Inside initializeApp()."); // Checkpoint A
authToken = localStorage.getItem('authToken');
const userString = localStorage.getItem('user');
user = userString ? JSON.parse(userString) : null;
console.log("B. Auth Token found:", !!authToken); // Checkpoint B
console.log("C. User data found:", user); // Checkpoint C
if (authToken && user) {
const userControls = document.getElementById('nav-user-controls');
userControls.classList.remove('hidden');
userControls.querySelector('#welcome-message').textContent = `Welcome, ${user.username}`;
if (user.role === 'admin') {
console.log("D. User is an admin, calling renderAdminDashboard()."); // Checkpoint D
renderAdminDashboard();
} else {
console.log("E. User is an employee, calling renderEmployeeDashboard()."); // Checkpoint E
renderEmployeeDashboard();
}
} else {
console.log("F. No user or token, calling renderAuthView()."); // Checkpoint F
document.getElementById('nav-user-controls').classList.add('hidden');
renderAuthView();
}
console.log("G. initializeApp() finished."); // Checkpoint G
}
// --- HELPERS ---