"use client"; import Link from "next/link"; import Image from "next/image"; import { useTranslations } from "next-intl"; import { Package, Clock, ChefHat } from "lucide-react"; import { Badge } from "@/components/ui/badge"; import { Progress } from "@/components/ui/progress"; import { EmptyState } from "@/components/shared/empty-state"; type ScoredItem = { recipe: { id: string; title: string; description: string | null; photos: Array<{ url: string }>; }; matched: number; total: number; pct: number; missing: string[]; usesExpiring: string[]; }; type Props = { pantryCount: number; scored: ScoredItem[]; }; function RecipeRow({ s }: { s: ScoredItem }) { const t = useTranslations("canCook"); const cover = s.recipe.photos?.[0]; return ( {cover ? (
{s.recipe.title}
) : (
)}

{s.recipe.title}

{s.usesExpiring.length > 0 && ( {t("useItUp")} )}
{t("ingredientProgress", { matched: s.matched, total: s.total })}
{s.missing.length > 0 && (

{t("missing")}: {s.missing.join(", ")}{s.missing.length < s.total - s.matched ? "…" : ""}

)}
{s.pct}% ); } export function CanCookContent({ pantryCount, scored }: Props) { const t = useTranslations("canCook"); if (pantryCount === 0) { return (

{t("title")}

{t("subtitle")}

); } const canCook = scored.filter((s) => s.pct === 100); const almostCook = scored.filter((s) => s.pct >= 70 && s.pct < 100); const rest = scored.filter((s) => s.pct < 70 && s.pct > 0); return (

{t("title")}

{t("subtitle", { count: pantryCount })}

{canCook.length > 0 && (

{t("readyToCook")} {canCook.length}

{canCook.map((s) => )}
)} {almostCook.length > 0 && (

{t("almostThere")} (70–99%) {almostCook.length}

{almostCook.map((s) => )}
)} {canCook.length === 0 && almostCook.length === 0 && ( )} {rest.length > 0 && (

{t("partialMatches")}

{rest.slice(0, 5).map((s) => )}
)}
); }