diff --git a/assets/js/app.js b/assets/js/app.js index cfd11ad..a2f89dd 100644 --- a/assets/js/app.js +++ b/assets/js/app.js @@ -2690,6 +2690,16 @@ async function useRecipeIngredient(idx, productId, location, qtyNumber, btn) { } btn.textContent = 'โœ”๏ธ Scalato'; btn.classList.add('btn-used'); + + // Persist used state in cached recipe + try { + const cached = JSON.parse(localStorage.getItem('cachedRecipe') || 'null'); + if (cached && cached.recipe && cached.recipe.ingredients && cached.recipe.ingredients[idx]) { + cached.recipe.ingredients[idx].used = true; + localStorage.setItem('cachedRecipe', JSON.stringify(cached)); + } + } catch (e) { /* ignore */ } + showToast('๐Ÿ“ฆ Ingrediente scalato dalla dispensa!', 'success'); } else { btn.disabled = false; @@ -2727,7 +2737,8 @@ function renderRecipe(r) { if (ing.from_pantry && ing.product_id) { const qtyNum = ing.qty_number || 0; const loc = (ing.location || 'dispensa').replace(/'/g, "\\'"); - html += `
  • `; + const alreadyUsed = ing.used === true; + html += `
  • `; html += `${ing.name}${ing.brand ? ' (' + ing.brand + ')' : ''}: ${ing.qty} โœ…`; // Detail line: location + expiry let details = []; @@ -2744,7 +2755,11 @@ function renderRecipe(r) { } if (details.length) html += `
    ${details.join(' ยท ')}`; html += `
    `; - html += ``; + if (alreadyUsed) { + html += ``; + } else { + html += ``; + } html += `
  • `; } else { const pantryIcon = ing.from_pantry ? ' โœ…' : ' ๐Ÿ›’'; diff --git a/data/dispensa.db b/data/dispensa.db index 89649c4..7174fc7 100644 Binary files a/data/dispensa.db and b/data/dispensa.db differ