"use client"; import Link from "next/link"; import { useTranslations } from "next-intl"; import { Badge } from "@/components/ui/badge"; import { Clock, ChefHat, Star } from "lucide-react"; 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 SearchResultRecipe = { id: string; title: string; description?: string | null; difficulty: string | null; prepMins: number | null; cookMins: number | null; authorName: string | null; avgRating?: number | null; ratingCount?: number; }; /** * Shared card for lightweight recipe search results (no cover photo/visibility * data available) — used by the search and explore pages, which previously * each had their own near-identical inline copy of this component. */ export function SearchResultCard({ recipe, className }: { recipe: SearchResultRecipe; className?: string }) { 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.title}

{recipe.difficulty && ( {difficultyLabel} )} {recipe.description && (

{recipe.description}

)} {!!recipe.ratingCount && recipe.avgRating != null && (
{recipe.avgRating.toFixed(1)} ({recipe.ratingCount})
)}
{totalMins > 0 && ( {t("total", { mins: totalMins })} )} {recipe.authorName && ( {recipe.authorName} )}
); }