add logging to initializeApp
This commit is contained in:
parent
6cb764faf7
commit
0cabc5288e
@ -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 ---
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user