Repository Public
1/**2 * =============================================================================3 * SP BOUCHER | SOFTWARE & RESEARCH4 * ARTIFICIAL INTELLIGENCE • FINANCE • ENGINEERING5 * =============================================================================6 *7 * Project : Vrai-Prix8 * File : src/components/avendre/ListingView.tsx9 * Module : components10 * Repository : https://git.spboucher.ai/vrai-prix11 * Created : 2026-09-0812 * Last Modified : 2026-09-0813 *14 * Author : Simon-Pierre Boucher15 * Position : Professor of Finance16 * Institution : Université du Québec en Outaouais (UQO)17 * Organization : SP Boucher18 * Website : https://spboucher.ai19 * Git : https://git.spboucher.ai20 *21 * Preferred Contact: contact@spboucher.ai22 * Development : dev@spboucher.ai23 * Support : support@spboucher.ai24 * Security/Admin : admin@spboucher.ai25 *26 * Copyright (c) 202627 * Simon-Pierre Boucher28 * All rights reserved where applicable. This file is governed by the29 * applicable project license, copyright notices and relevant law.30 * Existing third-party rights and notices remain unaffected.31 *32 * License : None specified (no license file in this repository)33 *34 * Do not embed credentials, private keys, access tokens,35 * certificates or confidential personal information.36 *37 * =============================================================================38 * END OF SP BOUCHER SOURCE HEADER39 * =============================================================================40 */4142// Vrai-Prix — fiche d'une propriété à vendre : toute l'information de l'annonce,43// la mesure Vrai-Prix déjà calculée, le portrait du rôle et l'accès à l'atelier.44// Ordre du DOM = ordre visuel, identique mobile et desktop (standard du propriétaire) :45// galerie → prix/adresse/caractéristiques → description → inclusions → détails46// → analyses (Vrai-Prix, historique de prix) → registre → voisines.47"use client";48import { useEffect, useState } from "react";49import Link from "next/link";50import { useLang } from "@/components/LangContext";51import { RangeBar } from "@/components/MetricViz";52import ListingCardView, { groupLabel, RatioPill } from "./ListingCardView";53import { dateFr, epochDate, m2, money, num, pct, sqftToM2 } from "./fmt";54import type { EvalRow, ListingCard, PricePoint, TypeGroupKey } from "@/lib/immoka";5556export interface ListingPageData {57 listing: {58 uid: string;59 source: string;60 url: string | null;61 title: string | null;62 address: string | null;63 sector: string | null;64 city: string | null;65 region: string | null;66 propertyType: string | null;67 price: number;68 bedrooms: number | null;69 bathrooms: number | null;70 powderRooms: number | null;71 areaSqft: number | null;72 lotSqft: number | null;73 yearBuilt: number | null;74 mls: string | null;75 brokerName: string | null;76 agency: string | null;77 description: string | null;78 lat: number | null;79 lng: number | null;80 firstSeen: number | null;81 lastSeen: number | null;82 };83 group: TypeGroupKey;84 images: string[];85 features: string[];86 details: Record<string, unknown>;87 priceLog: PricePoint[];88 eval: EvalRow | null;89 unit: {90 id: string;91 adresse: string | null;92 apt: string | null;93 municipalite: string | null;94 typeProp: string;95 anneeConstruction: number | null;96 aireEtagesM2: number | null;97 superficieTerrainM2: number | null;98 nbEtages: number | null;99 nbLogements: number | null;100 genreConstruction: string | null;101 lienPhysique: string | null;102 valeurTerrain: number | null;103 valeurBatiment: number | null;104 valeurRole: number | null;105 est2026: number | null;106 p10: number | null;107 p90: number | null;108 history: { year: number; value: number | null }[];109 } | null;110 nearby: ListingCard[];111 /** analyse IA du bâtiment déjà complétée (chantier Coût) — null si aucune */112 aiSummary?: { analysisId: string; version: number; confidence: number | null; rcn: number | null; costValue: number | null; structure: string | null; foundation: string | null; roof: string | null; quality: string | null; condition: string | null; completedAt: string | null } | null;113}114115const SOURCE_LABELS: Record<string, string> = {116 remax_quebec: "RE/MAX Québec",117 duproprio: "DuProprio",118 kijiji: "Kijiji",119 via_capitale: "Via Capitale",120 sutton: "Sutton",121 lespac: "LesPAC",122 fb_marketplace: "Facebook Marketplace",123 proprio_direct: "Proprio Direct",124 royal_lepage: "Royal LePage",125 engel_volkers: "Engel & Völkers",126 sothebys_quebec: "Sotheby's",127 pmml: "PMML",128};129const sourceLabel = (s: string) => SOURCE_LABELS[s] ?? s.replace(/_/g, " ").replace(/\bag\b/g, "").trim();130131const HIDDEN_DETAIL_KEYS = new Set(["img_audited", "transaction", "pieces", "remarques_proprio", "prix_pi2", "prix_m2"]);132133function Sect({ num: n, kicker, title }: { num: string; kicker: string; title: string }) {134 return (135 <header className="sec">136 <span className="sec-num">137 {n} — {kicker}138 </span>139 <h2 className="vp-display mt-2 text-[clamp(20px,3vw,28px)] font-bold uppercase leading-[1.05] tracking-[-0.025em]">{title}</h2>140 </header>141 );142}143144function Chip({ k, v }: { k: string; v: string | number | null | undefined }) {145 return (146 <div className="kv-cell">147 <p className="k">{k}</p>148 <p className="v break-words">{v == null || v === "" ? "—" : v}</p>149 </div>150 );151}152153/* --------------------------------- galerie --------------------------------- */154function Gallery({ images, alt }: { images: string[]; alt: string }) {155 const [i, setI] = useState(0);156 const [open, setOpen] = useState(false);157 useEffect(() => {158 if (!open) return;159 const onKey = (e: KeyboardEvent) => {160 if (e.key === "Escape") setOpen(false);161 if (e.key === "ArrowRight") setI((x) => (x + 1) % images.length);162 if (e.key === "ArrowLeft") setI((x) => (x - 1 + images.length) % images.length);163 };164 window.addEventListener("keydown", onKey);165 document.body.style.overflow = "hidden";166 return () => {167 window.removeEventListener("keydown", onKey);168 document.body.style.overflow = "";169 };170 }, [open, images.length]);171172 if (!images.length)173 return (174 <div className="vp-mono flex aspect-[16/7] w-full items-center justify-center border border-[var(--line)] bg-surface-2 text-[11px] uppercase tracking-[0.1em] text-ink-3">175 Aucune photo176 </div>177 );178 const cur = images[Math.min(i, images.length - 1)];179 return (180 <div>181 <div className="grid gap-2 md:grid-cols-[3fr_1fr]">182 <button type="button" onClick={() => setOpen(true)} className="relative block aspect-[16/10] w-full overflow-hidden bg-surface-2 md:aspect-auto md:h-[440px]">183 {/* eslint-disable-next-line @next/next/no-img-element */}184 <img src={cur} alt={alt} referrerPolicy="no-referrer" className="h-full w-full object-cover" />185 <span className="vp-mono absolute bottom-2 right-2 bg-ink/80 px-2 py-1 text-[10px] text-paper">186 {i + 1} / {images.length}187 </span>188 </button>189 <div className="flex gap-2 overflow-x-auto md:h-[440px] md:flex-col md:overflow-y-auto">190 {images.slice(0, 40).map((src, k) => (191 <button192 key={src + k}193 type="button"194 onClick={() => setI(k)}195 className={`relative aspect-[4/3] w-24 shrink-0 overflow-hidden border-2 md:w-full ${k === i ? "border-accent" : "border-transparent"}`}196 >197 {/* eslint-disable-next-line @next/next/no-img-element */}198 <img src={src} alt="" loading="lazy" referrerPolicy="no-referrer" className="h-full w-full object-cover" />199 </button>200 ))}201 </div>202 </div>203 {open && (204 <div className="vp-dark fixed inset-0 z-[var(--z-modal,900)] flex flex-col" role="dialog" aria-modal="true">205 <div className="flex h-12 shrink-0 items-center justify-between px-4">206 <span className="vp-mono text-[11px] uppercase tracking-[0.1em]">207 {i + 1} / {images.length}208 </span>209 <button type="button" onClick={() => setOpen(false)} className="vp-mono h-10 w-10 text-[16px]" aria-label="Fermer">210 ✕211 </button>212 </div>213 <div className="relative flex flex-1 items-center justify-center overflow-hidden px-2 pb-4">214 {/* eslint-disable-next-line @next/next/no-img-element */}215 <img src={cur} alt={alt} referrerPolicy="no-referrer" className="max-h-full max-w-full object-contain" />216 <button type="button" onClick={() => setI((x) => (x - 1 + images.length) % images.length)} className="vp-mono absolute left-2 top-1/2 h-12 w-12 -translate-y-1/2 bg-ink/60 text-[20px]" aria-label="Précédente">217 ‹218 </button>219 <button type="button" onClick={() => setI((x) => (x + 1) % images.length)} className="vp-mono absolute right-2 top-1/2 h-12 w-12 -translate-y-1/2 bg-ink/60 text-[20px]" aria-label="Suivante">220 ›221 </button>222 </div>223 </div>224 )}225 </div>226 );227}228229/* ---------------------------- historique de prix ---------------------------- */230function PriceHistory({ log, current, lastSeen, fr, lang }: { log: PricePoint[]; current: number; lastSeen: number | null; fr: boolean; lang: string }) {231 const pts = [...log];232 if (!pts.length || pts[pts.length - 1].price !== current) pts.push({ ts: lastSeen ?? pts[pts.length - 1]?.ts ?? 0, price: current });233 // déduplique les prix consécutifs identiques234 const series = pts.filter((p, i) => i === 0 || p.price !== pts[i - 1].price);235 if (series.length < 2)236 return <p className="text-[13px] text-ink-3">{fr ? "Aucun changement de prix observé depuis la première capture." : "No price change observed since first capture."}</p>;237 const first = series[0].price;238 return (239 <ol className="space-y-1.5">240 {series.map((p, i) => {241 const prev = i > 0 ? series[i - 1].price : null;242 const d = prev ? ((p.price - prev) / prev) * 100 : null;243 return (244 <li key={p.ts} className="flex flex-wrap items-baseline gap-x-4 border-b border-[var(--line-soft)] py-1.5 text-[13.5px]">245 <span className="vp-mono w-28 text-[11px] uppercase tracking-[0.05em] text-ink-3">{epochDate(p.ts, lang)}</span>246 <span className="vp-display font-bold">{money(p.price, lang)}</span>247 {d != null && <span className={`vp-mono text-[11px] ${d < 0 ? "text-[var(--danger)]" : "text-ink-2"}`}>{pct(d, lang, 1)}</span>}248 </li>249 );250 })}251 <li className="vp-mono pt-1 text-[10.5px] uppercase tracking-[0.05em] text-ink-3">252 {fr ? "Cumul depuis la mise en marché" : "Since listing"} : {pct(((current - first) / first) * 100, lang, 1)}253 </li>254 </ol>255 );256}257258/* ------------------------------- composant -------------------------------- */259export default function ListingView({ data }: { data: ListingPageData }) {260 const { lang } = useLang();261 const fr = lang === "fr";262 const l = data.listing;263 const e = data.eval;264 const u = data.unit;265 const area = sqftToM2(l.areaSqft);266 const lot = sqftToM2(l.lotSqft);267 const ppm2 = area ? Math.round(l.price / area) : null;268 const where = [l.sector, l.city].filter(Boolean).join(" · ");269 const alt = [l.address, l.city].filter(Boolean).join(", ");270271 const detailEntries = Object.entries(data.details).filter(272 ([k, v]) => !HIDDEN_DETAIL_KEYS.has(k) && (typeof v === "string" || typeof v === "number") && String(v).trim() !== ""273 ) as [string, string | number][];274 const pieces = Array.isArray(data.details.pieces) ? (data.details.pieces as Record<string, string>[]) : [];275 const remarques = typeof data.details.remarques_proprio === "string" ? (data.details.remarques_proprio as string) : null;276277 const methods: { key: string; fr: string; en: string; v: number | null; main?: boolean }[] = e278 ? [279 { key: "est", fr: "Vrai-Prix — hybride 65/35 (mesure principale)", en: "Vrai-Prix — 65/35 hybrid (main measure)", v: e.est, main: true },280 { key: "model", fr: "Modèle hédonique (LightGBM)", en: "Hedonic model (LightGBM)", v: e.model_est },281 { key: "comps", fr: "Comparables ajustés (moteur)", en: "Adjusted comparables (engine)", v: e.comps_est },282 { key: "cost", fr: "Méthode du coût calibrée", en: "Calibrated cost approach", v: e.cost_est },283 { key: "role", fr: "Rôle indexé (ratios IAAO)", en: "Indexed assessment (IAAO ratios)", v: e.role_est },284 { key: "ens", fr: "Ensemble (médiane des méthodes)", en: "Ensemble (median of methods)", v: e.ens_est },285 ]286 : [];287288 return (289 <div className="space-y-12 py-8">290 {/* ================= fil d'Ariane ================= */}291 <nav className="vp-mono flex flex-wrap items-center gap-2 border-b-2 border-ink pb-2.5 text-[10.5px] uppercase tracking-[0.08em] text-ink-3">292 <Link href="/" className="text-ink-2 hover:text-accent-deep">293 Vrai Prix294 </Link>295 <span aria-hidden="true">/</span>296 <Link href="/a-vendre" className="text-ink-2 hover:text-accent-deep">297 {fr ? "À vendre" : "For sale"}298 </Link>299 <span aria-hidden="true">/</span>300 <span className="truncate">{l.uid}</span>301 </nav>302303 {/* ================= 1. galerie ================= */}304 <section className="rise">305 <Gallery images={data.images} alt={alt} />306 </section>307308 {/* ================= 2. prix + adresse + caractéristiques ================= */}309 <section className="grid gap-x-12 gap-y-8 lg:grid-cols-[1.5fr_1fr]">310 <div className="min-w-0">311 <p className="vp-mono text-[10.5px] uppercase tracking-[0.08em] text-ink-3">312 {groupLabel(data.group, fr)}313 {l.propertyType && l.propertyType !== groupLabel(data.group, fr) ? ` · ${l.propertyType}` : ""}314 {" · "}315 {sourceLabel(l.source)}316 {l.mls ? ` · MLS ${l.mls}` : ""}317 </p>318 <h1 className="vp-display mt-2 text-[clamp(20px,2.8vw,28px)] font-bold uppercase leading-tight tracking-[-0.02em]">319 {l.address || l.title || (fr ? "Propriété à vendre" : "Property for sale")}320 {where ? <span className="text-ink-3"> · {where}</span> : null}321 </h1>322 <p className="klabel mt-5">{fr ? "Prix demandé" : "Asking price"}</p>323 <p className="vp-display mt-1 text-[clamp(44px,8vw,84px)] font-bold leading-none tracking-[-0.045em]">{money(l.price, lang)}</p>324 <div className="mt-3 flex flex-wrap items-center gap-3">325 <RatioPill ratio={e?.ratio ?? null} fr={fr} size="md" />326 {e?.est != null && (327 <span className="vp-mono text-[11px] uppercase tracking-[0.06em] text-ink-2">328 {fr ? "Mesure Vrai-Prix" : "Vrai-Prix measure"} <b className="text-ink">{money(e.est, lang)}</b>329 {e.confidence ? ` · ${fr ? "confiance" : "confidence"} ${e.confidence}` : ""}330 </span>331 )}332 </div>333 <p className="vp-mono mt-4 text-[11px] uppercase tracking-[0.06em] text-ink-2">334 {[335 l.bedrooms != null ? `${l.bedrooms} ${fr ? "chambres" : "bedrooms"}` : null,336 l.bathrooms != null ? `${l.bathrooms} ${fr ? "salles de bain" : "bathrooms"}` : null,337 l.powderRooms ? `${l.powderRooms} ${fr ? "salle d'eau" : "powder room"}` : null,338 area ? `${num(area, lang)} m² (${num(l.areaSqft, lang)} pi²)` : null,339 ppm2 ? `${num(ppm2, lang)} $/m²` : null,340 lot ? `${fr ? "terrain" : "lot"} ${num(lot, lang)} m²` : null,341 l.yearBuilt ? `${fr ? "constr." : "built"} ${l.yearBuilt}` : null,342 ]343 .filter((x): x is string => x != null)344 .join(" · ")}345 </p>346 <div className="mt-7 flex flex-wrap gap-2.5">347 <Link href={`/a-vendre/${encodeURIComponent(l.uid)}/evaluer`} className="btn btn-accent">348 {fr ? "Faire mon évaluation" : "Build my valuation"} →349 </Link>350 {u && (351 <Link href={`/estimation/${encodeURIComponent(u.id)}`} className="btn btn-ghost">352 {fr ? "Rapport de valeur Vrai-Prix" : "Vrai-Prix value report"}353 </Link>354 )}355 <Link href={`/a-vendre/${encodeURIComponent(l.uid)}/analyse-cout`} className="btn btn-ghost" title={fr ? "Des photos à la méthode du coût — Claude Sonnet 5" : "From photos to the cost approach — Claude Sonnet 5"}>356 {data.aiSummary ? (fr ? "Coût IA disponible" : "AI cost available") : fr ? "Analyser le coût avec l'IA" : "Analyse the cost with AI"} →357 </Link>358 {u && (359 <Link href={`/cout?property=${encodeURIComponent(u.id)}`} className="btn btn-ghost">360 {fr ? "Voir la méthode du coût" : "See the cost approach"} →361 </Link>362 )}363 {l.url && (364 <a href={l.url} target="_blank" rel="noopener noreferrer nofollow" className="btn btn-ghost">365 {fr ? "Annonce originale" : "Original listing"} ↗366 </a>367 )}368 </div>369 </div>370 <aside className="lg:border-l lg:border-[var(--line)] lg:pl-10">371 <dl className="grid grid-cols-2 gap-x-6 lg:grid-cols-1">372 {e?.est != null && (373 <div className="border-t border-[var(--line)] py-3">374 <dt className="klabel">{fr ? "Estimation Vrai-Prix" : "Vrai-Prix estimate"}</dt>375 <dd className="vp-display mt-0.5 text-[22px] font-bold tracking-[-0.02em]">{money(e.est, lang)}</dd>376 <dd className="vp-mono text-[10.5px] uppercase tracking-[0.05em] text-ink-3">377 {money(e.low, lang)} – {money(e.high, lang)}378 </dd>379 </div>380 )}381 {e?.diff != null && (382 <div className="border-t border-[var(--line)] py-3">383 <dt className="klabel">{fr ? "Prix demandé − estimation" : "Asking − estimate"}</dt>384 <dd className={`vp-display mt-0.5 text-[22px] font-bold tracking-[-0.02em] ${e.diff > 0 ? "text-ink" : "text-[var(--danger)]"}`}>385 {e.diff >= 0 ? "+" : "−"}386 {money(Math.abs(e.diff), lang)}387 </dd>388 </div>389 )}390 {(u?.valeurRole ?? e?.valeur_role) != null && (391 <div className="border-t border-[var(--line)] py-3">392 <dt className="klabel">{fr ? "Évaluation municipale (rôle)" : "Municipal assessment (roll)"}</dt>393 <dd className="vp-display mt-0.5 text-[22px] font-bold tracking-[-0.02em] text-ink-2">{money(u?.valeurRole ?? e?.valeur_role, lang)}</dd>394 {(u?.valeurRole ?? e?.valeur_role)! > 0 && (395 <dd className="vp-mono text-[10.5px] uppercase tracking-[0.05em] text-ink-3">396 {fr ? "prix / rôle" : "price / roll"} {(l.price / (u?.valeurRole ?? e?.valeur_role)!).toLocaleString(fr ? "fr-CA" : "en-CA", { maximumFractionDigits: 2 })}397 </dd>398 )}399 </div>400 )}401 <div className="border-t border-[var(--line)] py-3">402 <dt className="klabel">{fr ? "En marché depuis" : "On market since"}</dt>403 <dd className="vp-display mt-0.5 text-[16px] font-bold tracking-[-0.02em]">{epochDate(l.firstSeen, lang)}</dd>404 <dd className="vp-mono text-[10.5px] uppercase tracking-[0.05em] text-ink-3">405 {fr ? "vu le" : "seen"} {epochDate(l.lastSeen, lang)}406 </dd>407 </div>408 {(l.brokerName || l.agency) && (409 <div className="border-t border-[var(--line)] py-3">410 <dt className="klabel">{fr ? "Courtier / vendeur" : "Broker / seller"}</dt>411 <dd className="mt-0.5 text-[13.5px] font-semibold">{l.brokerName || "—"}</dd>412 {l.agency && l.agency !== l.brokerName && <dd className="text-[12px] text-ink-2">{l.agency}</dd>}413 </div>414 )}415 </dl>416 </aside>417 </section>418419 {/* ================= 3. description ================= */}420 {(l.description || remarques) && (421 <section>422 <Sect num="01" kicker={fr ? "Annonce" : "Listing"} title={fr ? "Description" : "Description"} />423 <div className="mt-5 max-w-3xl whitespace-pre-line text-[14.5px] leading-relaxed text-ink-2">{l.description || remarques}</div>424 {l.description && remarques && remarques !== l.description && (425 <div className="mt-4 max-w-3xl whitespace-pre-line border-l-2 border-accent pl-4 text-[13.5px] leading-relaxed text-ink-2">{remarques}</div>426 )}427 </section>428 )}429430 {/* ================= 4. inclusions / caractéristiques ================= */}431 {data.features.length > 0 && (432 <section>433 <Sect num="02" kicker={fr ? "Annonce" : "Listing"} title={fr ? "Caractéristiques et inclusions" : "Features and inclusions"} />434 <ul className="mt-5 grid gap-x-8 gap-y-1.5 text-[13.5px] sm:grid-cols-2 lg:grid-cols-3">435 {data.features.map((f, i) => (436 <li key={i} className="flex gap-2 border-b border-[var(--line-soft)] py-1.5">437 <span aria-hidden="true" className="mt-[7px] inline-block h-[5px] w-[5px] shrink-0 bg-accent" />438 <span>{f}</span>439 </li>440 ))}441 </ul>442 </section>443 )}444445 {/* ================= 5. détails structurés ================= */}446 {(detailEntries.length > 0 || pieces.length > 0) && (447 <section>448 <Sect num="03" kicker={fr ? "Annonce" : "Listing"} title={fr ? "Détails pratiques" : "Practical details"} />449 {detailEntries.length > 0 && (450 <div className="mt-5 grid grid-cols-2 gap-x-6 gap-y-3 md:grid-cols-3 lg:grid-cols-4">451 {detailEntries.map(([k, v]) => (452 <Chip key={k} k={k.replace(/_/g, " ")} v={v} />453 ))}454 </div>455 )}456 {pieces.length > 0 && (457 <div className="src-wrap mt-6">458 <table className="src-table">459 <thead>460 <tr>461 <th>{fr ? "Pièce" : "Room"}</th>462 <th>{fr ? "Niveau" : "Level"}</th>463 <th>{fr ? "Dimensions" : "Dimensions"}</th>464 <th>{fr ? "Revêtement" : "Flooring"}</th>465 </tr>466 </thead>467 <tbody>468 {pieces.map((p, i) => (469 <tr key={i}>470 <td className="font-semibold">{p.nom ?? p.name ?? "—"}</td>471 <td>{p.niveau ?? p.level ?? "—"}</td>472 <td className="vp-mono text-[12px]">{p.dimensions ?? "—"}</td>473 <td>{p.revetement ?? p.flooring ?? "—"}</td>474 </tr>475 ))}476 </tbody>477 </table>478 </div>479 )}480 </section>481 )}482483 {/* ================= 6. analyses : mesure Vrai-Prix ================= */}484 <section>485 <Sect num="04" kicker={fr ? "Analyse" : "Analysis"} title={fr ? "La mesure Vrai-Prix face au prix demandé" : "The Vrai-Prix measure vs. the asking price"} />486 {e?.est ? (487 <div className="mt-6 grid gap-x-12 gap-y-8 lg:grid-cols-[1.4fr_1fr]">488 <div>489 <p className="klabel mb-1">{fr ? "Intervalle de confiance (P10-P90) et prix demandé" : "Confidence interval (P10-P90) and asking price"}</p>490 <RangeBar low={e.low ?? e.est} estimate={e.est} high={e.high ?? e.est} role={l.price} lang={lang} />491 <p className="vp-mono mt-2 text-[10px] uppercase tracking-[0.05em] text-ink-3">492 {fr ? "Le repère « rôle » de la barre marque ici le prix demandé." : "The “roll” marker on the bar shows the asking price here."}493 </p>494 <div className="src-wrap mt-6">495 <table className="src-table">496 <thead>497 <tr>498 <th>{fr ? "Méthode" : "Method"}</th>499 <th className="text-right">{fr ? "Valeur" : "Value"}</th>500 <th className="text-right">{fr ? "vs prix demandé" : "vs asking"}</th>501 </tr>502 </thead>503 <tbody>504 {methods.map((m) => (505 <tr key={m.key} className={m.main ? "font-bold" : ""}>506 <td>{fr ? m.fr : m.en}</td>507 <td className="vp-mono text-right">{money(m.v, lang)}</td>508 <td className={`vp-mono text-right ${m.v != null && m.v < l.price ? "text-[var(--danger)]" : ""}`}>509 {m.v != null ? pct((m.v / l.price - 1) * 100, lang, 1) : "—"}510 </td>511 </tr>512 ))}513 <tr className="bg-surface-2">514 <td>{fr ? "Prix demandé" : "Asking price"}</td>515 <td className="vp-mono text-right">{money(l.price, lang)}</td>516 <td className="vp-mono text-right">—</td>517 </tr>518 </tbody>519 </table>520 </div>521 <p className="mt-4 max-w-3xl text-[13px] leading-relaxed text-ink-2">522 {fr523 ? "Rappel : l'écart entre la mesure et le prix demandé additionne l'erreur du modèle ET la stratégie d'affichage du vendeur. Le prix demandé n'est pas la valeur marchande ; seule la vente la révèle."524 : "Reminder: the gap between the measure and the asking price adds up the model's error AND the seller's pricing strategy. The asking price is not market value; only the sale reveals it."}525 </p>526 </div>527 <div className="lg:border-l lg:border-[var(--line)] lg:pl-10">528 <p className="klabel">{fr ? "Historique du prix demandé" : "Asking price history"}</p>529 <div className="mt-3">530 <PriceHistory log={data.priceLog} current={l.price} lastSeen={l.lastSeen} fr={fr} lang={lang} />531 </div>532 <p className="klabel mt-8">{fr ? "Jumelage au rôle" : "Match to the roll"}</p>533 <p className="mt-1 text-[13px] text-ink-2">534 {u535 ? fr536 ? `Unité ${u.id} (${u.adresse ?? "—"}) jumelée à ${e.match_m != null ? `${num(e.match_m, lang, 1)} m` : "—"} de l'annonce · ${e.n_comps ?? 0} comparables du moteur · évaluée le ${e.evaluated_at ?? "—"}.`537 : `Unit ${u.id} (${u.adresse ?? "—"}) matched ${e.match_m != null ? `${num(e.match_m, lang, 1)} m` : "—"} from the listing · ${e.n_comps ?? 0} engine comparables · valued on ${e.evaluated_at ?? "—"}.`538 : fr539 ? "Aucune unité du rôle à moins de 250 m."540 : "No assessment unit within 250 m."}541 </p>542 <Link href={`/a-vendre/${encodeURIComponent(l.uid)}/evaluer`} className="btn btn-primary mt-6">543 {fr ? "Choisir mes comparables et comparer" : "Pick my comparables and compare"} →544 </Link>545 </div>546 </div>547 ) : (548 <div className="mt-6 max-w-3xl text-[14px] leading-relaxed text-ink-2">549 <p>550 {fr551 ? "Cette annonce n'a pas de mesure Vrai-Prix : aucune unité du rôle d'évaluation n'a pu être jumelée à moins de 250 m de ses coordonnées (ou l'annonce n'est pas géolocalisée)."552 : "This listing has no Vrai-Prix measure: no assessment unit could be matched within 250 m of its coordinates (or the listing is not geolocated)."}553 </p>554 {l.lat != null && (555 <Link href={`/a-vendre/${encodeURIComponent(l.uid)}/evaluer`} className="btn btn-primary mt-5">556 {fr ? "Faire quand même mon évaluation par comparables" : "Build my valuation from comparables anyway"} →557 </Link>558 )}559 </div>560 )}561 </section>562563 {/* ================= 6b. analyse technique IA (si déjà calculée) ================= */}564 {data.aiSummary && (565 <section>566 <Sect num="04b" kicker={fr ? "Analyse IA" : "AI analysis"} title={fr ? "Analyse technique IA du bâtiment" : "AI technical analysis of the building"} />567 <p className="vp-mono mt-3 text-[10.5px] uppercase tracking-[0.06em] text-ink-3">568 Claude Sonnet 5 · v{data.aiSummary.version}{data.aiSummary.confidence != null ? ` · ${fr ? "confiance" : "confidence"} ${Math.round(data.aiSummary.confidence)} %` : ""}{data.aiSummary.completedAt ? ` · ${dateFr(data.aiSummary.completedAt, lang)}` : ""}569 </p>570 <div className="mt-4 grid grid-cols-2 gap-x-6 gap-y-3 md:grid-cols-3 lg:grid-cols-6">571 <Chip k={fr ? "Structure" : "Structure"} v={data.aiSummary.structure?.replace(/_/g, " ")} />572 <Chip k={fr ? "Fondation" : "Foundation"} v={data.aiSummary.foundation?.replace(/_/g, " ")} />573 <Chip k={fr ? "Toiture" : "Roof"} v={data.aiSummary.roof?.replace(/_/g, " ")} />574 <Chip k={fr ? "Qualité" : "Quality"} v={data.aiSummary.quality} />575 <Chip k={fr ? "Condition" : "Condition"} v={data.aiSummary.condition?.replace(/_/g, " ")} />576 <Chip k={fr ? "RCN estimé" : "Estimated RCN"} v={money(data.aiSummary.rcn, lang)} />577 </div>578 <p className="mt-3 text-[13px] text-ink-2">579 {fr ? "Inféré par IA à partir des photos et de l'annonce, puis chiffré par le moteur déterministe de la méthode du coût — estimation indicative." : "AI-inferred from the photos and listing, then costed by the deterministic cost-approach engine — indicative estimate."}580 {data.aiSummary.costValue != null ? ` ${fr ? "Indication par le coût" : "Cost approach indication"} : ${money(data.aiSummary.costValue, lang)}.` : ""}581 </p>582 <Link href={`/a-vendre/${encodeURIComponent(l.uid)}/analyse-cout`} className="vp-mono mt-3 inline-block text-[11px] font-bold uppercase tracking-[0.08em] text-accent">583 {fr ? "Voir le profil complet" : "See the full profile"} →584 </Link>585 </section>586 )}587588 {/* ================= 7. registre (unité jumelée) ================= */}589 {u && (590 <section>591 <Sect num="05" kicker={fr ? "Registre officiel" : "Official record"} title={fr ? "Portrait au rôle d'évaluation" : "Assessment roll portrait"} />592 <div className="mt-5 grid grid-cols-2 gap-x-6 gap-y-3 md:grid-cols-4">593 <Chip k={fr ? "Adresse au rôle" : "Address on roll"} v={`${u.adresse ?? "—"}${u.apt ? ` app. ${u.apt}` : ""}`} />594 <Chip k={fr ? "Municipalité" : "Municipality"} v={u.municipalite} />595 <Chip k={fr ? "Type (rôle)" : "Type (roll)"} v={u.typeProp} />596 <Chip k={fr ? "Année de construction" : "Year built"} v={u.anneeConstruction} />597 <Chip k={fr ? "Aire d'étages" : "Floor area"} v={m2(u.aireEtagesM2, lang)} />598 <Chip k={fr ? "Terrain" : "Lot"} v={m2(u.superficieTerrainM2, lang)} />599 <Chip k={fr ? "Étages × logements" : "Storeys × dwellings"} v={`${u.nbEtages ?? "—"} × ${u.nbLogements ?? "—"}`} />600 <Chip k={fr ? "Genre / lien" : "Style / link"} v={[u.genreConstruction, u.lienPhysique].filter(Boolean).join(" · ")} />601 <Chip k={fr ? "Valeur terrain (rôle)" : "Land value (roll)"} v={money(u.valeurTerrain, lang)} />602 <Chip k={fr ? "Valeur bâtiment (rôle)" : "Building value (roll)"} v={money(u.valeurBatiment, lang)} />603 <Chip k={fr ? "Valeur au rôle" : "Assessed value"} v={money(u.valeurRole, lang)} />604 <Chip k={fr ? "Modèle hédonique 2026" : "Hedonic model 2026"} v={money(u.est2026, lang)} />605 </div>606 {area && u.aireEtagesM2 && Math.abs(area - u.aireEtagesM2) / u.aireEtagesM2 > 0.25 && (607 <p className="mt-4 max-w-3xl border-l-2 border-[var(--amber,#c98a1b)] pl-4 text-[13px] leading-relaxed text-ink-2">608 {fr609 ? `Attention : la superficie annoncée (${num(area, lang)} m²) s'écarte de plus de 25 % de l'aire d'étages au rôle (${num(u.aireEtagesM2, lang)} m²). Le rôle mesure l'aire brute des étages hors sous-sol ; l'annonce peut inclure le sous-sol aménagé ou le terrain — ou le jumelage peut être imparfait (condos empilés).`610 : `Note: the advertised area (${num(area, lang)} m²) differs by more than 25% from the roll's floor area (${num(u.aireEtagesM2, lang)} m²). The roll measures gross floor area excluding basement; the listing may include a finished basement or the lot — or the match may be imperfect (stacked condos).`}611 </p>612 )}613 <Link href={`/estimation/${encodeURIComponent(u.id)}`} className="vp-mono mt-4 inline-block text-[11px] font-bold uppercase tracking-[0.08em] text-accent">614 {fr ? "Voir le rapport de valeur complet de cette unité" : "See this unit's full value report"} →615 </Link>616 </section>617 )}618619 {/* ================= 8. voisines à vendre ================= */}620 {data.nearby.length > 0 && (621 <section>622 <Sect num={u ? "06" : "05"} kicker={fr ? "Marché actif" : "Active market"} title={fr ? "À vendre à proximité (même catégorie)" : "For sale nearby (same category)"} />623 <div className="mt-5 grid gap-4 sm:grid-cols-2 lg:grid-cols-3">624 {data.nearby.map((c) => (625 <ListingCardView key={c.uid} c={c} fr={fr} compact />626 ))}627 </div>628 </section>629 )}630631 <p className="vp-mono border-t border-[var(--line)] pt-3 text-[10px] uppercase tracking-[0.05em] text-ink-3">632 {fr633 ? `Annonce ${l.uid} — annonce publique, capturée le ${epochDate(l.lastSeen, lang)}. Photos, textes et prix appartiennent au vendeur ou au courtier ; ils sont reproduits à titre informatif. Estimations Vrai-Prix : statistiques, non certifiées (OEAQ).`634 : `Listing ${l.uid} — public listing, captured ${epochDate(l.lastSeen, lang)}. Photos, texts and prices belong to the seller or broker; reproduced for information purposes. Vrai-Prix estimates: statistical, not certified (OEAQ).`}635 {e?.evaluated_at ? ` · ${fr ? "évaluée le" : "valued on"} ${dateFr(e.evaluated_at, lang)}` : ""}636 </p>637 </div>638 );639}640