646c97128d
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>
100 lines
3.3 KiB
TypeScript
100 lines
3.3 KiB
TypeScript
"use client";
|
|
|
|
import { useTranslations } from "next-intl";
|
|
import { Minus, Plus } from "lucide-react";
|
|
import { Button } from "@/components/ui/button";
|
|
import { Label } from "@/components/ui/label";
|
|
import { Input } from "@/components/ui/input";
|
|
import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from "@/components/ui/select";
|
|
|
|
function Counter({
|
|
value,
|
|
onChange,
|
|
max = 6,
|
|
disabled,
|
|
}: {
|
|
value: number;
|
|
onChange: (v: number) => void;
|
|
max?: number;
|
|
disabled?: boolean;
|
|
}) {
|
|
return (
|
|
<div className="flex items-center gap-2">
|
|
<Button type="button" variant="outline" size="icon" disabled={disabled} onClick={() => onChange(Math.max(0, value - 1))}>
|
|
<Minus className="h-4 w-4" />
|
|
</Button>
|
|
<span className="w-8 text-center font-medium tabular-nums">{value}</span>
|
|
<Button type="button" variant="outline" size="icon" disabled={disabled} onClick={() => onChange(Math.min(max, value + 1))}>
|
|
<Plus className="h-4 w-4" />
|
|
</Button>
|
|
</div>
|
|
);
|
|
}
|
|
|
|
export type BatchCookFieldsState = {
|
|
dinners: number;
|
|
lunches: number;
|
|
servings: number;
|
|
difficulty: "" | "easy" | "medium" | "hard";
|
|
dietaryPrefs: string;
|
|
};
|
|
|
|
export function BatchCookFields({
|
|
state,
|
|
onChange,
|
|
disabled,
|
|
}: {
|
|
state: BatchCookFieldsState;
|
|
onChange: (state: BatchCookFieldsState) => void;
|
|
disabled?: boolean;
|
|
}) {
|
|
const t = useTranslations("batchCooking");
|
|
const tCommon = useTranslations("common");
|
|
const tRecipe = useTranslations("recipe");
|
|
|
|
return (
|
|
<div className="space-y-4">
|
|
<div className="flex items-center justify-between">
|
|
<Label>{t("dinners")}</Label>
|
|
<Counter value={state.dinners} onChange={(v) => onChange({ ...state, dinners: v })} disabled={disabled} />
|
|
</div>
|
|
<div className="flex items-center justify-between">
|
|
<Label>{t("lunches")}</Label>
|
|
<Counter value={state.lunches} onChange={(v) => onChange({ ...state, lunches: v })} disabled={disabled} />
|
|
</div>
|
|
<div className="flex items-center justify-between">
|
|
<Label>{t("servingsPerMeal")}</Label>
|
|
<Counter value={state.servings} onChange={(v) => onChange({ ...state, servings: v })} max={12} disabled={disabled} />
|
|
</div>
|
|
<div className="space-y-2">
|
|
<Label>{tCommon("difficulty")}</Label>
|
|
<Select
|
|
value={state.difficulty}
|
|
onValueChange={(v) => onChange({ ...state, difficulty: v as BatchCookFieldsState["difficulty"] })}
|
|
disabled={disabled}
|
|
>
|
|
<SelectTrigger>
|
|
<SelectValue placeholder={t("anyDifficulty")} />
|
|
</SelectTrigger>
|
|
<SelectContent>
|
|
<SelectItem value="">{t("anyDifficulty")}</SelectItem>
|
|
<SelectItem value="easy">{tRecipe("difficulty.easy")}</SelectItem>
|
|
<SelectItem value="medium">{tRecipe("difficulty.medium")}</SelectItem>
|
|
<SelectItem value="hard">{tRecipe("difficulty.hard")}</SelectItem>
|
|
</SelectContent>
|
|
</Select>
|
|
</div>
|
|
<div className="space-y-2">
|
|
<Label htmlFor="batch-dietary">{t("dietaryPrefs")}</Label>
|
|
<Input
|
|
id="batch-dietary"
|
|
value={state.dietaryPrefs}
|
|
onChange={(e) => onChange({ ...state, dietaryPrefs: e.target.value })}
|
|
placeholder={t("dietaryPrefsPlaceholder")}
|
|
disabled={disabled}
|
|
/>
|
|
</div>
|
|
</div>
|
|
);
|
|
}
|