refactor: fold batch-cooking into the main recipes list and Generate dialog

Batch-cook recipes no longer live in a separate /batch-cooking section:
- Removed the dedicated page/route and its nav button.
- /recipes shows both kinds together, with a chef-hat badge marking
  batch sessions, and a filter to isolate/hide them.
- "Batch cooking" is now a third tab in the existing "Generate recipe
  with AI" dialog (alongside Describe/Photo) instead of a separate
  button — one AI entry point instead of three.
- Extracted the counters/difficulty/dietary form into BatchCookFields,
  shared between that dialog and the meal-planner's batch-cooking
  dialog.
- Also fixed a dialog resize issue (progress bar mounting mid-generate
  grew the dialog's height, which the positioning library didn't
  always handle) by reserving space up front and capping dialog height
  with a scroll fallback.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
Arnaud
2026-07-12 09:31:04 +02:00
parent f29fa531a1
commit 646c97128d
10 changed files with 238 additions and 200 deletions
-31
View File
@@ -1,31 +0,0 @@
import type { Metadata } from "next";
import { headers } from "next/headers";
import { auth } from "@/lib/auth/server";
import { db, recipes, eq, and, desc } from "@epicure/db";
import { BatchCookingPageContent } from "@/components/recipe/batch-cooking-page-content";
export const metadata: Metadata = {};
export default async function BatchCookingPage() {
const session = await auth.api.getSession({ headers: await headers() });
if (!session) return null;
const sessions = await db.query.recipes.findMany({
where: and(eq(recipes.authorId, session.user.id), eq(recipes.isBatchCook, true)),
orderBy: desc(recipes.createdAt),
with: { batchDishes: true },
});
return (
<BatchCookingPageContent
sessions={sessions.map((r) => ({
id: r.id,
title: r.title,
description: r.description,
baseServings: r.baseServings,
createdAt: r.createdAt.toISOString(),
dishCount: r.batchDishes.length,
}))}
/>
);
}
+7 -3
View File
@@ -20,6 +20,7 @@ type SearchParams = Promise<{
difficulty?: string;
tag?: string;
page?: string;
batchCook?: string;
}>;
const SORT_MAP = {
@@ -38,7 +39,7 @@ export default async function RecipesPage({ searchParams }: { searchParams: Sear
if (!session) return null;
const m = getMessages((session.user as { locale?: string }).locale);
const { q, sort, visibility, difficulty, tag, page: pageParam } = await searchParams;
const { q, sort, visibility, difficulty, tag, page: pageParam, batchCook } = await searchParams;
const query = (q ?? "").trim().slice(0, 200);
const sortKey: SortKey = (sort && sort in SORT_MAP ? sort : "updated_desc") as SortKey;
const tagFilter = tag?.trim().slice(0, 50) || undefined;
@@ -51,10 +52,11 @@ export default async function RecipesPage({ searchParams }: { searchParams: Sear
const difficultyFilter = difficulty && ["easy", "medium", "hard"].includes(difficulty)
? (difficulty as "easy" | "medium" | "hard")
: undefined;
const batchCookFilter = batchCook === "1" || batchCook === "0" ? batchCook : undefined;
const where = and(
eq(recipes.authorId, session.user.id),
eq(recipes.isBatchCook, false),
batchCookFilter ? eq(recipes.isBatchCook, batchCookFilter === "1") : undefined,
query
? or(ilike(recipes.title, `%${query}%`), ilike(recipes.description, `%${query}%`))
: undefined,
@@ -94,6 +96,7 @@ export default async function RecipesPage({ searchParams }: { searchParams: Sear
if (visibilityFilter) params.set("visibility", visibilityFilter);
if (difficultyFilter) params.set("difficulty", difficultyFilter);
if (tagFilter) params.set("tag", tagFilter);
if (batchCookFilter) params.set("batchCook", batchCookFilter);
if (p > 1) params.set("page", String(p));
const qs = params.toString();
return qs ? `/recipes?${qs}` : "/recipes";
@@ -114,9 +117,10 @@ export default async function RecipesPage({ searchParams }: { searchParams: Sear
initialVisibility={visibilityFilter ?? ""}
initialDifficulty={difficultyFilter ?? ""}
initialTag={tagFilter ?? ""}
initialBatchCook={batchCookFilter ?? ""}
/>
<RecipesEmptyState query={query} count={total} />
<RecipesGrid key={`${query}-${sortKey}-${visibilityFilter}-${difficultyFilter}-${tagFilter}-${page}`} recipes={recipesWithFavorites} />
<RecipesGrid key={`${query}-${sortKey}-${visibilityFilter}-${difficultyFilter}-${tagFilter}-${batchCookFilter}-${page}`} recipes={recipesWithFavorites} />
{totalPages > 1 && (
<div className="flex items-center justify-center gap-2 pt-2">