// ----------------------------------------------------------------------------- // Immo-Ka — Agrégateur de propriétés à vendre (province de Québec) // Auteur : Simon-Pierre Boucher — contact@spboucher.ai // fiche/PropertyHero.tsx : héro de la fiche — prix + capsule « vs estimation // Vrai-Prix », type de bien, prix au pi², adresse (H1) + secteur/ville, ligne // résumé, puis galerie, puis actions (favoris · partager · PDF · Voir // l'annonce). Ordre DOM = ordre visuel. // ----------------------------------------------------------------------------- import { Listing, fmtPrice, sourceName } from "../api"; import { Ico, IcoHeart } from "../components/Icons"; import PropertyGallery from "./PropertyGallery"; import { ComparaisonPrix, estLocation, ligneResume } from "./synthese"; import { NBSP } from "./ui"; export function PriceCapsule({ cmp, short = false }: { cmp: ComparaisonPrix | null; short?: boolean }) { if (!cmp) return null; return ( {short ? {cmp.court} : <>{cmp.label}{cmp.court}} ); } export default function PropertyHero({ l, cmp, fav, onFav, onShare, actionsRef }: { l: Listing; cmp: ComparaisonPrix | null; fav: boolean; onFav: () => void; onShare: () => void; actionsRef: React.RefObject; }) { const resume = ligneResume(l); const titre = l.address || l.title; const where = [l.sector, l.city, l.region].filter(Boolean).join(" · "); const hist = (l.price_history ?? []).filter((h) => h.price != null); const baisse = hist.length >= 2 && hist[0].price! < hist[1].price! ? hist[1].price! : null; const location = estLocation(l); const pi2 = l.price != null && l.area_sqft != null && l.area_sqft > 200 && !location ? Math.round(l.price / l.area_sqft) : null; const captions = Array.isArray(l.details?.photo_captions) ? (l.details!.photo_captions as string[]) : undefined; return (
{location ? "Loyer mensuel" : "Prix demandé"}{l.details?.price_from ? " · à partir de" : ""}
{fmtPrice(l.price, l.price_label)} {location && l.price != null && /{NBSP}mois} {baisse != null && {fmtPrice(baisse)}}
{pi2 != null && {pi2.toLocaleString("fr-CA")}{NBSP}$/pi²} {l.ka_reco && Recommandé pour vous}

{titre} {where && {where}}

{resume.length > 0 && (

{resume.map((r, i) => ( {i > 0 && }{r} ))}

)}
Voir l'annonce chez {sourceName(l.source)}
); }