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)
This commit is contained in:
dadaloop82
2026-03-16 07:59:56 +00:00
parent 4d9fd8638e
commit 74d99a11bf
2 changed files with 11 additions and 4 deletions
+10 -3
View File
@@ -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
+1 -1
View File
@@ -911,6 +911,6 @@
</div>
</div>
<script src="assets/js/app.js?v=20260316d"></script>
<script src="assets/js/app.js?v=20260316e"></script>
</body>
</html>