diff --git a/assets/css/style.css b/assets/css/style.css index dfaf11e..029f453 100644 --- a/assets/css/style.css +++ b/assets/css/style.css @@ -2609,6 +2609,15 @@ body { border-radius: 8px; line-height: 1.3; } +.stat-price-total { + display: block; + font-size: 0.62rem; + font-weight: 600; + color: #15803d; + margin-top: 2px; + white-space: nowrap; + line-height: 1.2; +} /* ===== PRODUCT PREVIEW ===== */ .product-preview, .product-preview-small { diff --git a/assets/js/app.js b/assets/js/app.js index 8f4fedc..e238cfa 100644 --- a/assets/js/app.js +++ b/assets/js/app.js @@ -9001,6 +9001,7 @@ async function fetchAllPrices(forceRefresh = false) { if (totalEl) totalEl.textContent = pricesFound > 0 ? `ca. ${sym}${runningTotal.toFixed(2)}` : '–'; if (fetchBtn) fetchBtn.disabled = false; if (refreshBtn) { refreshBtn.disabled = false; refreshBtn.textContent = '🔄'; } + _updateDashboardPriceTotal(); } } @@ -9228,6 +9229,29 @@ function _updateSmartUrgencyBadge() { } } +function _updateDashboardPriceTotal() { + const el = document.getElementById('stat-price-total'); + if (!el) return; + const s = getSettings(); + if (!s.price_enabled || !shoppingItems.length) { el.style.display = 'none'; return; } + const sym = _currencySymbol(s.price_currency || 'EUR'); + const items = _buildPricePayload(); + let total = 0, count = 0; + for (const item of items) { + const e = _cachedPrices[item.name]; + if (e && e._qty === item.quantity && e._unit === item.unit && e.estimated_total != null) { + total += e.estimated_total; + count++; + } + } + if (count > 0) { + el.textContent = `ca. ${sym}${total.toFixed(2)}`; + el.style.display = ''; + } else { + el.style.display = 'none'; + } +} + /** * Sync the on_bring flag for every smartShoppingItem against the current shoppingItems list. * The server cache can be up to 10 min old so on_bring may be stale — this corrects it @@ -9579,6 +9603,7 @@ async function loadShoppingCount() { } } catch { /* ignore */ } } + _updateDashboardPriceTotal(); } /** diff --git a/index.html b/index.html index 970a153..22bbaba 100644 --- a/index.html +++ b/index.html @@ -11,7 +11,7 @@