Add ingredients' products
Some checks failed
Build and Deploy / build-and-push (push) Failing after 1m20s

This commit is contained in:
2026-04-07 22:51:30 +02:00
parent ac32e05c31
commit 868862d031
11 changed files with 576 additions and 57 deletions

View File

@@ -1,4 +1,4 @@
import { INGREDIENTS, RECIPES } from '../data/catalog.js?v=2';
import { INGREDIENTS, RECIPES, PRODUCTS } from '../data/catalog.js?v=6';
import { MEAL_SLOTS } from '../planner/mealSlots.js';
import { PLANS_STORAGE_KEY } from '../storageKeys.js';
import { startOfDay } from './dateUtils.js';
@@ -40,6 +40,13 @@ function normalizeEntryExtras(x) {
.map((a) => ({ ingredientId: a.ingredientId, amount: a.amount, unit: a.unit }));
if (valid.length > 0) out.addedIngredients = valid;
}
if (x.productSelections && typeof x.productSelections === 'object' && !Array.isArray(x.productSelections)) {
const ps = {};
for (const [k, v] of Object.entries(x.productSelections)) {
if (typeof v === 'string' && PRODUCTS[v]) ps[k] = v;
}
if (Object.keys(ps).length > 0) out.productSelections = ps;
}
return out;
}