"use client"; import Link from "next/link"; import Image from "next/image"; import { useTranslations } from "next-intl"; import { Clock, Users, Lock, Globe, Link2, ExternalLink } from "lucide-react"; import { Badge } from "@/components/ui/badge"; import { Card, CardContent, CardFooter, CardHeader } from "@/components/ui/card"; import { getPublicUrl } from "@/lib/storage"; type Recipe = { id: string; title: string; description: string | null; baseServings: number; prepMins: number | null; cookMins: number | null; difficulty: "easy" | "medium" | "hard" | null; visibility: "private" | "unlisted" | "public"; updatedAt: Date; photos?: Array<{ storageKey: string; isCover: boolean }>; sourceUrl?: string | null; recipeType?: "dish" | "drink"; }; const VISIBILITY_ICON = { private: Lock, unlisted: Link2, public: Globe, }; const DIFFICULTY_COLOR = { easy: "default", medium: "secondary", hard: "destructive", } as const; export function RecipeCard({ recipe }: { recipe: Recipe }) { const t = useTranslations("recipe"); const cover = recipe.photos?.find((p) => p.isCover) ?? recipe.photos?.[0]; const totalMins = (recipe.prepMins ?? 0) + (recipe.cookMins ?? 0); const VisibilityIcon = VISIBILITY_ICON[recipe.visibility]; return ( {cover ? (
{recipe.title}
) : (
{recipe.recipeType === "drink" ? "🍹" : "🍽️"}
)}

{recipe.title}

{recipe.description && (

{recipe.description}

)}
{recipe.baseServings} {totalMins > 0 && ( {t("total", { mins: totalMins })} )} {recipe.difficulty && ( {t(`difficulty.${recipe.difficulty}`)} )}
{recipe.sourceUrl && }
); }