From ed4cdbf230ab64a4224991a1b113b11f15e5cf58 Mon Sep 17 00:00:00 2001 From: Marcel Raddatz Date: Fri, 10 Apr 2026 11:55:55 +0200 Subject: [PATCH] fix(planner): merge recipe tags into slotMap from data.recipes SlotRecipe from the week-plan API carries no tags, so the protein gradient lookup in DesktopDayTile always fell through to --color-surface. Build a recipeById lookup from data.recipes and spread tags onto each slot's recipe when constructing slotMap. Co-Authored-By: Claude Sonnet 4.6 --- frontend/src/routes/(app)/planner/+page.svelte | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/frontend/src/routes/(app)/planner/+page.svelte b/frontend/src/routes/(app)/planner/+page.svelte index cb3575f..a75bd86 100644 --- a/frontend/src/routes/(app)/planner/+page.svelte +++ b/frontend/src/routes/(app)/planner/+page.svelte @@ -25,7 +25,20 @@ let days = $derived(weekDays(weekStart)); let slots = $derived(weekPlan?.slots ?? []); - let slotMap = $derived(Object.fromEntries(slots.map((s: any) => [s.slotDate, s]))); + // SlotRecipe from the API has no tags — merge from data.recipes by id + const recipeById = $derived( + Object.fromEntries((data.recipes ?? []).map((r: any) => [r.id, r])) + ); + let slotMap = $derived( + Object.fromEntries( + slots.map((s: any) => [ + s.slotDate, + s.recipe + ? { ...s, recipe: { ...s.recipe, tags: recipeById[s.recipe.id]?.tags ?? [] } } + : s + ]) + ) + ); // Default selected day: today if in this week, else first day // We read data.weekStart once synchronously here (before reactivity kicks in) to seed the initial value.