import Link from "next/link"; import Image from "next/image"; import { Badge } from "@/components/ui/badge"; import { Card, CardContent } from "@/components/ui/card"; type NeedCardData = { id: string; title: string; city: string; region: string | null; budget_min: number | null; budget_max: number | null; categories: { name: string } | { name: string }[] | null; need_images: { storage_path: string; position: number }[] | null; }; export function NeedCard({ need, getImageUrl, }: { need: NeedCardData; getImageUrl: (path: string) => string; }) { const category = Array.isArray(need.categories) ? need.categories[0] : need.categories; const images = [...(need.need_images ?? [])].sort( (a, b) => a.position - b.position ); const cover = images[0]; return ( {cover && (
{need.title}
)} {category?.name && ( {category.name} )}

{need.title}

{need.city} {need.region ? `, ${need.region}` : ""}

{(need.budget_min || need.budget_max) && (

{need.budget_min ?? "?"}€ – {need.budget_max ?? "?"}€

)}
); }