From 8650b377a4d7ce1b738173feae213411b1b9d8a9 Mon Sep 17 00:00:00 2001 From: dadaloop82 Date: Tue, 10 Mar 2026 17:39:49 +0000 Subject: [PATCH] feat: mostra marca, scadenza e posizione negli ingredienti ricetta MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Backend: aggiunge brand e expiry_date all'arricchimento ingredienti - Frontend: sotto ogni ingrediente dalla dispensa mostra: - Marca in corsivo (se presente) - Icona posizione (๐ŸงŠ Frigo/Freezer, ๐Ÿ—„๏ธ Dispensa) - Scadenza con colore urgenza (โ›” scaduto, ๐Ÿ”ด <3gg, ๐ŸŸก <7gg, ๐Ÿ“… data) - Nuovo stile CSS per riga dettaglio ingrediente --- api/index.php | 6 ++++++ assets/css/style.css | 6 ++++++ assets/js/app.js | 17 ++++++++++++++++- data/dispensa.db | Bin 73728 -> 73728 bytes 4 files changed, 28 insertions(+), 1 deletion(-) diff --git a/api/index.php b/api/index.php index 94584c0..7b167e9 100644 --- a/api/index.php +++ b/api/index.php @@ -857,6 +857,12 @@ PROMPT; $ing['product_id'] = (int)$bestMatch['product_id']; $ing['location'] = $bestMatch['location']; $ing['available_qty'] = $bestMatch['quantity'] . ' ' . $bestMatch['unit']; + if (!empty($bestMatch['brand'])) { + $ing['brand'] = $bestMatch['brand']; + } + if (!empty($bestMatch['expiry_date'])) { + $ing['expiry_date'] = $bestMatch['expiry_date']; + } } } } diff --git a/assets/css/style.css b/assets/css/style.css index 37742d6..4fc9fc1 100644 --- a/assets/css/style.css +++ b/assets/css/style.css @@ -2088,6 +2088,12 @@ body { opacity: 0.5; } +.recipe-ing-detail { + color: var(--text-muted); + font-size: 0.78rem; + line-height: 1.3; +} + /* ===== AI IDENTIFICATION RESULTS ===== */ .ai-identified-card { background: var(--bg-light); diff --git a/assets/js/app.js b/assets/js/app.js index 1e43f31..cfd11ad 100644 --- a/assets/js/app.js +++ b/assets/js/app.js @@ -2728,7 +2728,22 @@ function renderRecipe(r) { const qtyNum = ing.qty_number || 0; const loc = (ing.location || 'dispensa').replace(/'/g, "\\'"); html += `
  • `; - html += `${ing.name}: ${ing.qty} โœ…`; + html += `${ing.name}${ing.brand ? ' (' + ing.brand + ')' : ''}: ${ing.qty} โœ…`; + // Detail line: location + expiry + let details = []; + const locLabels = { 'frigo': '๐ŸงŠ Frigo', 'freezer': '๐ŸงŠ Freezer', 'dispensa': '๐Ÿ—„๏ธ Dispensa' }; + details.push(locLabels[ing.location] || ('๐Ÿ“ ' + ing.location)); + if (ing.expiry_date) { + const exp = new Date(ing.expiry_date); + const now = new Date(); now.setHours(0,0,0,0); + const diffDays = Math.round((exp - now) / 86400000); + if (diffDays < 0) details.push(`โ›” Scaduto da ${Math.abs(diffDays)}g`); + else if (diffDays <= 3) details.push(`๐Ÿ”ด Scade tra ${diffDays}g`); + else if (diffDays <= 7) details.push(`๐ŸŸก Scade tra ${diffDays}g`); + else details.push(`๐Ÿ“… ${exp.toLocaleDateString('it-IT')}`); + } + if (details.length) html += `
    ${details.join(' ยท ')}`; + html += `
    `; html += ``; html += `
  • `; } else { diff --git a/data/dispensa.db b/data/dispensa.db index 2d7597fc20ed4686592abec05394b89163510d7d..89649c4d20cd304b9494eb2b9dbfacdc578d1df4 100644 GIT binary patch delta 276 zcmZoTz|wGlWy42%#@NlD?1coFV;LQu+ok> zmiNkJ_6hk+K&otl5)<#O%`+xg@J@a(mxV(=mX(>2(IIB@gSje9%(3jAli3$+XJJod z_uSan&NjJnxqt%H##nJ?V@51i#7v&JTzGTO@@fx8#?2fbd{{)Bbb)S@WmGga)=$YS pE=bKQPE47c`9+fhY7)cdnP1jRF)~f}fz7jvQF%TCTMgio2as=*bZ{uM zqL4BTk&qCx;GHA_16v1qlLw%;v4Oh=lS!u#vx%pENC5z|2=Gh<6+