"use client"; import Link from "next/link"; import { useState } from "react"; import type { ListingCard as Card } from "@/lib/types"; import { fmtPrice, fmtArea, fmtInt } from "@/lib/format"; import { CATEGORY_LABEL } from "@/lib/normalize"; import { useCompare, useFavorites } from "@/lib/favorites"; import { IconHeart, IconCompare } from "./icons"; import { VerdictPill } from "./verdict-pill"; export function listingHref(c: { uid: string }) { return `/annonce/${encodeURIComponent(c.uid)}`; } export function ListingCardView({ c, compact = false, priority = false }: { c: Card; compact?: boolean; priority?: boolean }) { const fav = useFavorites(); const cmp = useCompare(); const [imgOk, setImgOk] = useState(true); const rent = c.market === "rent"; const sub = [c.typeLabel && !rent ? CATEGORY_LABEL[c.category] ?? c.typeLabel : c.typeLabel ?? CATEGORY_LABEL[c.category], c.bedrooms != null ? `${fmtInt(c.bedrooms)} ch.` : null, c.bathrooms != null ? `${fmtInt(c.bathrooms)} sdb` : null, c.areaSqft ? fmtArea(c.areaSqft) : null].filter(Boolean).join(" · "); return (
{c.image && imgOk ? ( // eslint-disable-next-line @next/next/no-img-element setImgOk(false)} /> ) : (
Photo non disponible
)} {!compact && c.imageCount > 1 && {c.imageCount} photos} {!compact && {rent ? "À louer" : "À vendre"}} {!compact && (
)}

{fmtPrice(c.price, { rent })}

{!compact && }
{c.address ?? "Adresse non précisée"}

{c.city}{c.region && c.region !== c.city ? `, ${c.region}` : ""}

{sub}

); }