From 74d99a11bfc8964d7d8b10df2a6fd01e9869b689 Mon Sep 17 00:00:00 2001 From: dadaloop82 Date: Mon, 16 Mar 2026 07:59:56 +0000 Subject: [PATCH] 20260316e: Fix quick recipe + use from opened packages first - Quick recipe: prompt now specifies 1 persona, excludes freezer products - USE form: auto-selects location with opened package as default (deducts from already-opened packages before sealed ones) - Move-after-use modal verified working (shows after partial use) --- assets/js/app.js | 13 ++++++++++--- index.html | 2 +- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/assets/js/app.js b/assets/js/app.js index e945724..b7d266b 100644 --- a/assets/js/app.js +++ b/assets/js/app.js @@ -936,7 +936,7 @@ function quickRecipeSuggestion() { // Navigate to chat and auto-send a prompt about expiring products showPage('chat'); setTimeout(() => { - document.getElementById('chat-input').value = 'Suggeriscimi una ricetta veloce usando i prodotti che scadono prima!'; + document.getElementById('chat-input').value = 'Suggeriscimi una ricetta veloce PER UNA PERSONA usando i prodotti che scadono prima! Ignora i prodotti in freezer (hanno scadenze molto lunghe), concentrati su frigo e dispensa.'; sendChatMessage(); }, 500); } @@ -3341,8 +3341,15 @@ async function loadUseInventoryInfo() { return; } - // Auto-select the first available location and show only relevant location buttons - const firstLoc = items[0].location; + // Auto-select the location with an opened package first (use from opened before sealed) + const openedItem = items.find(i => { + const q = parseFloat(i.quantity); + const dq = parseFloat(i.default_quantity) || 0; + if (i.unit === 'conf' && dq > 0) return q !== Math.floor(q); + if (dq > 0) return Math.abs(q - Math.round(q / dq) * dq) > dq * 0.02; + return false; + }); + const firstLoc = openedItem ? openedItem.location : items[0].location; document.getElementById('use-location').value = firstLoc; // Build location buttons only for locations where the product exists diff --git a/index.html b/index.html index 6b56501..5e71433 100644 --- a/index.html +++ b/index.html @@ -911,6 +911,6 @@ - +