"use client"; import Link from "next/link"; import Image from "next/image"; import { useTranslations } from "next-intl"; import { ChefHat, Clock } from "lucide-react"; import { Badge } from "@/components/ui/badge"; import { FavoriteButton } from "@/components/social/favorite-button"; import { getPublicUrl } from "@/lib/storage"; import { cn } from "@/lib/utils"; const DIFFICULTY_COLORS: Record = { easy: "bg-green-100 text-green-800 dark:bg-green-900 dark:text-green-200", medium: "bg-yellow-100 text-yellow-800 dark:bg-yellow-900 dark:text-yellow-200", hard: "bg-red-100 text-red-800 dark:bg-red-900 dark:text-red-200", }; export type FavoriteRecipe = { id: string; title: string; difficulty: string | null; prepMins: number | null; cookMins: number | null; authorName: string | null; coverPhotoKey: string | null; }; /** Card for the "Favorites" grid — mirrors SearchResultCard's layout with a cover * photo and an unfavorite toggle, since this view is specifically for managing * (and removing from) your saved recipes, not just browsing them. */ export function FavoriteRecipeCard({ recipe, className, onUnfavorited, }: { recipe: FavoriteRecipe; className?: string; onUnfavorited?: (recipeId: string) => void; }) { const t = useTranslations("recipe"); const totalMins = (recipe.prepMins ?? 0) + (recipe.cookMins ?? 0); const difficultyLabel = recipe.difficulty === "easy" || recipe.difficulty === "medium" || recipe.difficulty === "hard" ? t(`difficulty.${recipe.difficulty}`) : recipe.difficulty; return (
{recipe.coverPhotoKey ? ( {recipe.title} ) : (
)}
{ e.preventDefault(); e.stopPropagation(); }}> { if (!favorited) onUnfavorited?.(recipe.id); }} />

{recipe.title}

{recipe.difficulty && ( {difficultyLabel} )}
{totalMins > 0 && ( {t("total", { mins: totalMins })} )} {recipe.authorName && ( {recipe.authorName} )}
); }