From a2a1a5ba776b9f19a6b169b398bb2eff8c7dab27 Mon Sep 17 00:00:00 2001 From: morgane Date: Wed, 17 Jun 2026 13:51:54 +0000 Subject: [PATCH] Actualiser assets/js/app.js --- assets/js/app.js | 26 +++++++------------------- 1 file changed, 7 insertions(+), 19 deletions(-) diff --git a/assets/js/app.js b/assets/js/app.js index 77929d0..ec130d7 100644 --- a/assets/js/app.js +++ b/assets/js/app.js @@ -5197,35 +5197,23 @@ function _applyInsightPhase() { // ===== DASHBOARD ===== async function loadDashboard() { - // Show shimmer on stat cards while loading - ['stat-dispensa', 'stat-frigo', 'stat-freezer'].forEach(id => { - const el = document.getElementById(id); - if (el) el.classList.add('stat-loading'); - }); - + // Render one card per known location, with shimmer while loading + renderDashboardLocationCards({}); try { const [summaryData, statsData] = await Promise.all([ api('inventory_summary'), api('stats') ]); - // Update stat cards const summary = summaryData.summary || []; let total = 0; - ['dispensa', 'frigo', 'freezer'].forEach(loc => { + const counts = {}; + Object.keys(LOCATIONS).forEach(loc => { const s = summary.find(x => x.location === loc); - const count = s ? s.product_count : 0; - const el = document.getElementById(`stat-${loc}`); - el.textContent = count; - el.classList.remove('stat-loading'); - total += count; - }); - // Add non-standard locations - summary.forEach(s => { - if (!['dispensa', 'frigo', 'freezer'].includes(s.location)) { - total += s.product_count; - } + counts[loc] = s ? s.product_count : 0; + total += counts[loc]; }); + renderDashboardLocationCards(counts); // Load shopping list count from Bring! loadShoppingCount(); // Show last known total instantly, then refresh from server