remember tab added

This commit is contained in:
chris 2025-08-10 09:36:10 -04:00
parent 2c4ba19b71
commit 688712e6da
2 changed files with 30 additions and 0 deletions

View File

@ -20,6 +20,7 @@ import {
// --- STATE MANAGEMENT --- // --- STATE MANAGEMENT ---
let user = null; let user = null;
let authToken = null; let authToken = null;
let lastAdminTab = 'overview';
// --- EVENT HANDLERS (The "Logic") --- // --- EVENT HANDLERS (The "Logic") ---
async function handleAuthSubmit(e) { async function handleAuthSubmit(e) {
@ -304,6 +305,25 @@ function setupTabbedInterface() {
}); });
} }
function setupTabbedInterface() {
const tabsContainer = document.getElementById('admin-tabs-nav');
const contentContainer = document.getElementById('admin-tabs-content');
if (!tabsContainer || !contentContainer) return;
tabsContainer.addEventListener('click', (e) => {
const clickedTab = e.target.closest('.tab-btn');
if (!clickedTab) return;
const tabTarget = clickedTab.dataset.tab;
// --- 2. ADD THIS LINE to update our variable ---
lastAdminTab = tabTarget;
// ... (the rest of the function stays the same) ...
});
}
// --- START THE APP --- // --- START THE APP ---
// Register the service worker for PWA functionality // Register the service worker for PWA functionality
if ('serviceWorker' in navigator) { if ('serviceWorker' in navigator) {

View File

@ -211,6 +211,16 @@ export async function renderAdminDashboard() {
adminTimerIntervals.push(intervalId); adminTimerIntervals.push(intervalId);
} }
}); });
if (lastAdminTab && lastAdminTab !== 'overview') {
// Remove active state from the default tab and panel
document.querySelector('.tab-btn[data-tab="overview"]').classList.remove('active-tab');
document.getElementById('tab-content-overview').classList.add('hidden');
// Add active state to the last viewed tab and panel
document.querySelector(`.tab-btn[data-tab="${lastAdminTab}"]`).classList.add('active-tab');
document.getElementById(`tab-content-${lastAdminTab}`).classList.remove('hidden');
}
} }
export function renderArchiveView() { export function renderArchiveView() {