feat(meal-plan) open recipes at the planned servings and return to the plan #41
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "open-recipe-with-plan-servings"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Closes #31
What
Opening a recipe from the meal plan now:
Opening a recipe from the recipe list or via a plain URL behaves exactly as before.
How
getRecipeDetailUrl(id, servings?)appends the newRECIPE_DETAIL_SERVINGS_PARAM(?servings=8). A URL param rather than router state, so the servings survive a reload and a copied link.RecipeDetailPagepre-scales the working copy when the param is valid; invalid values (0,2.5,abc, …) fall back to the recipe's own servings. Back target and label come from the new typedRecipeDetailLocationStateinroutes.ts.MealPlanRecipeLinkcomponent, shared by the list view (MealPlanDishCard) and the week overview (MealPlanCalendar), so both links behave identically.src/utils/servingsUtils.ts(scaleRecipeToServings,parseServingsParam) with tests. Side effect: a recipe with 0 base servings is no longer scaled toInfinity.docs/architecture.mdmentions typed router navigation state in theroutes.tssection.Verification
npm run build✓,npm run lint(0 errors; 2 pre-existing warnings elsewhere),npm run test✓ 204/204/verify-uiasuseron all five viewports: list view and week overview both open the recipe at 8 servings / 1000 g, stepper recalculates (7 → 875 g), back returns to the same plan and week; recipe list path and?servings=abcunchanged at 4 / 500 g; no console errors.Notes
MealPlanDishCard.tsxas the #32 branch (meal-plan-dish-card-wrap) — whichever merges second needs a small conflict resolution.🤖 Generated with Claude Code
@ -125,0 +143,4 @@* several places (recipe list, meal plan) and the URL alone doesn't say which.* Absent when the page is opened directly (bookmark, reload of a fresh tab).*/export interface RecipeDetailLocationState {should this live here or would it be better off in its own file?
Re review comment on
src/routes.ts("should this live here or would it be better off in its own file?"):Moved in
87fbe6b.RecipeDetailLocationStatenow lives in its own file,src/components/recipes/RecipeDetailLocationState.ts, next toRecipeDetailPage, which owns and reads it.routes.tsis back to URL information only, since router state is deliberately not part of the URL.RecipeListItem, the other caller that sets this state, now uses the interface instead of an untyped{ backTo }object, anddocs/architecture.mdis updated to match.Posted by Claude Code.