Files
Epicure/apps/web/components/recipe/mark-cooked-section.tsx
T
Arnaud 04a911b431 feat: mark recipe as cooked (multi-cook history + backdate) and enable auto-deduct pantry on cook (v0.75.0)
Adds a general-purpose "mark cooked" dialog for any recipe (not just batch-cook dishes), with a date picker for backdating and a pantry-deduct checkbox defaulted on. Also flips the previously dead-in-the-UI deductFromPantry flag to true for the existing batch-cook and meal-planner cook actions.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
2026-07-24 11:28:41 +02:00

47 lines
1.3 KiB
TypeScript

"use client";
import { useRouter } from "next/navigation";
import { useTranslations } from "next-intl";
import { ChefHat } from "lucide-react";
import { Button } from "@/components/ui/button";
import { useLocale } from "@/lib/i18n/provider";
import { MarkCookedDialog } from "./mark-cooked-dialog";
export function MarkCookedSection({
recipeId,
baseServings,
cookCount,
lastCookedAt,
}: {
recipeId: string;
baseServings: number;
cookCount: number;
lastCookedAt: string | null;
}) {
const t = useTranslations("recipe");
const router = useRouter();
const { locale } = useLocale();
return (
<div className="flex items-center gap-3">
<MarkCookedDialog
recipeId={recipeId}
baseServings={baseServings}
onLogged={() => router.refresh()}
trigger={
<Button type="button" variant="outline" size="sm">
<ChefHat className="h-3.5 w-3.5" />
{t("markCookedButton")}
</Button>
}
/>
{cookCount > 0 && (
<p className="text-xs text-muted-foreground">
{cookCount === 1 ? t("markCookedCountSingular") : t("markCookedCountPlural", { count: cookCount })}
{lastCookedAt && t("markCookedLast", { date: new Date(lastCookedAt).toLocaleDateString(locale, { month: "short", day: "numeric" }) })}
</p>
)}
</div>
);
}