Reorganise the views and prepare summary
All checks were successful
Build and Deploy / build-and-push (push) Successful in 23s
All checks were successful
Build and Deploy / build-and-push (push) Successful in 23s
This commit is contained in:
@@ -296,6 +296,20 @@ export function toggleItemInList(listId, itemId) {
|
||||
return s;
|
||||
}
|
||||
|
||||
export function updateKitchenItemAmount(listId, itemId, newAmount) {
|
||||
const s = loadShoppingState();
|
||||
const list = s.lists.find((l) => l.id === listId && l.type === 'kitchen');
|
||||
if (!list) return s;
|
||||
const it = /** @type {KitchenShoppingItem[]} */ (list.items).find((i) => i.id === itemId);
|
||||
if (!it) return s;
|
||||
it.amount = Math.max(0, Math.round(newAmount * 100) / 100);
|
||||
if (it.amount <= 0) {
|
||||
list.items = list.items.filter((i) => i.id !== itemId);
|
||||
}
|
||||
saveShoppingState(s);
|
||||
return s;
|
||||
}
|
||||
|
||||
export function removeItemFromList(listId, itemId) {
|
||||
const s = loadShoppingState();
|
||||
const list = s.lists.find((l) => l.id === listId);
|
||||
|
||||
@@ -5,7 +5,9 @@ import { getDayPlan } from './planStore.js';
|
||||
|
||||
export function dayHasAnyMeal(plans, d) {
|
||||
const p = getDayPlan(plans, d);
|
||||
const skipped = p._skipped || {};
|
||||
return MEAL_SLOTS.some((s) => {
|
||||
if (skipped[s.id]) return false;
|
||||
const arr = p[s.id];
|
||||
return Array.isArray(arr) && arr.length > 0;
|
||||
});
|
||||
@@ -17,7 +19,9 @@ export function sumDayNutrition(dayPlan) {
|
||||
let fat = 0;
|
||||
let carbs = 0;
|
||||
let mealCount = 0;
|
||||
const skipped = dayPlan._skipped || {};
|
||||
MEAL_SLOTS.forEach((slot) => {
|
||||
if (skipped[slot.id]) return;
|
||||
const entries = dayPlan[slot.id];
|
||||
if (!Array.isArray(entries)) return;
|
||||
entries.forEach((entry) => {
|
||||
@@ -56,7 +60,9 @@ function resolveLine(ing, scaledAmount) {
|
||||
export function flattenDayIngredientLines(dayPlan) {
|
||||
/** @type {ReturnType<typeof resolveLine>[]} */
|
||||
const out = [];
|
||||
const skipped = dayPlan._skipped || {};
|
||||
MEAL_SLOTS.forEach((slot) => {
|
||||
if (skipped[slot.id]) return;
|
||||
const entries = dayPlan[slot.id];
|
||||
if (!Array.isArray(entries)) return;
|
||||
entries.forEach((entry) => {
|
||||
@@ -112,7 +118,9 @@ export function aggregateWeekIngredientNeed(plans, weekStart) {
|
||||
export function aggregateDayIngredientsBySlot(dayPlan) {
|
||||
/** @type {{ mealLabel: string, recipes: { recipeTitle: string, items: { ingredientId: string, name: string, amount: number, unit: string, category: string }[] }[] }[]} */
|
||||
const blocks = [];
|
||||
const skipped = dayPlan._skipped || {};
|
||||
MEAL_SLOTS.forEach((slot) => {
|
||||
if (skipped[slot.id]) return;
|
||||
const entries = dayPlan[slot.id];
|
||||
if (!Array.isArray(entries) || entries.length === 0) return;
|
||||
const recipes = [];
|
||||
|
||||
@@ -47,6 +47,13 @@ export function normalizeDayPlan(day) {
|
||||
const arr = normalizeSlotValue(day[s.id]);
|
||||
if (arr.length > 0) out[s.id] = arr;
|
||||
});
|
||||
if (day._skipped && typeof day._skipped === 'object') {
|
||||
const sk = {};
|
||||
for (const k of Object.keys(day._skipped)) {
|
||||
if (day._skipped[k] === true) sk[k] = true;
|
||||
}
|
||||
if (Object.keys(sk).length > 0) out._skipped = sk;
|
||||
}
|
||||
return out;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user