Skip to content

Remove redundant logic across MealPlan and Recipe components#257

Draft
Copilot wants to merge 2 commits into
mainfrom
copilot/review-redundant-logic
Draft

Remove redundant logic across MealPlan and Recipe components#257
Copilot wants to merge 2 commits into
mainfrom
copilot/review-redundant-logic

Conversation

Copy link
Copy Markdown

Copilot AI commented Feb 19, 2026

Several components contained copy-pasted patterns and unused extractions — notably, navigation hooks were already written but never wired up, and mutation error handlers were duplicated verbatim across four mutations.

Changes

  • MealPlanCalendar.tsx (-64 lines): Replaced inline view/currentDate state + getDateRange/handlePrevious/handleNext/handleToday with the already-existing useCalendarNavigation hook. Merged duplicate dayWeekProps/monthProps into a single viewProps. Fixed onMealRemove to use mutateAsync instead of new Promise((resolve) => { mutate(); resolve(); }).

  • useMealPlanMutations.ts: All four mutations had identical onError/onSettled handlers. Extracted into buildSharedHandlers:

    const shared = buildSharedHandlers(queryClient, queryKey);
    // replaces 7 lines of copy-pasted onError + onSettled in each mutation
  • CalendarSubscription.tsx (-12 lines): Three API functions shared the same try/catch/finally loading+error boilerplate. Extracted into a callApi helper with an optional onError callback for cases needing extra cleanup (e.g. clearing stale tokenData on fetch failure).

  • RecipeProvider.tsx (-6 lines): Removed no-op onSuccess: (_data) => { /* comment */ } callbacks.

  • RecipeActions.tsx: Removed redundant isOpen={activeDialog === "X"} expressions already guarded by {activeDialog === "X" && ...} wrappers — simplified to isOpen.

  • RecipeHeader.tsx (-12 lines): Inlined handleAddToCollection/handleSaveRecipe — both were single-line wrappers used exactly once.

Original prompt

can you review the app for redundant logic that can be improved and or removed? i would like to have things Inder 200 lines if possible


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

@vercel
Copy link
Copy Markdown
Contributor

vercel Bot commented Feb 19, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
book-cook Ready Ready Preview, Comment Feb 19, 2026 6:38pm

…clean up callbacks

Co-authored-by: czearing <7192338+czearing@users.noreply.github.com>
Copilot AI changed the title [WIP] Review app for redundant logic improvements Remove redundant logic across MealPlan and Recipe components Feb 19, 2026
Copilot AI requested a review from czearing February 19, 2026 18:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants