// ----------------------------------------------------------------------------- // Auto-Ka — Agrégateur de voitures usagées à vendre (province de Québec) // Auteur : Simon-Pierre Boucher — contact@spboucher.ai // fiche/VehicleFacts.tsx : « Le véhicule » — grille icône/valeur (année, km, // transmission, carburant, motricité, carrosserie, moteur, portes, places, // consommation), rangées (couleurs, NIV, stock, concessionnaire), description // du concessionnaire (tronquée), équipements (12 + « Voir les N »), fiche // constructeur décodée du NIV en accordéon. // ----------------------------------------------------------------------------- import { ReactNode, useState } from "react"; import { VehicleDetail, fmtKm } from "../api"; import { Ico } from "../components/Icons"; import { Accordion, MoreButton, SectionCard, NBSP } from "./ui"; export default function VehicleFacts({ v }: { v: VehicleDetail }) { const [descOpen, setDescOpen] = useState(false); const [allFeat, setAllFeat] = useState(false); const d = (v.details ?? {}) as Record; const facts: { ico: ReactNode; v: string; l: string }[] = []; if (v.year) facts.push({ ico: , v: String(v.year), l: "Année" }); if (v.mileage_km != null) facts.push({ ico: , v: fmtKm(v.mileage_km), l: "Kilométrage" }); if (v.transmission) facts.push({ ico: , v: v.transmission, l: "Transmission" }); if (v.fuel) facts.push({ ico: , v: v.fuel, l: "Carburant" }); if (v.drivetrain) facts.push({ ico: , v: v.drivetrain, l: "Motricité" }); if (v.body_type) facts.push({ ico: , v: v.body_type, l: "Carrosserie" }); if (v.engine) facts.push({ ico: , v: v.engine, l: "Moteur" }); if (v.doors) facts.push({ ico: , v: String(v.doors), l: "Portes" }); if (v.seats) facts.push({ ico: , v: String(v.seats), l: "Places" }); const city = d.fuel_city_l_100km, hwy = d.fuel_hwy_l_100km; if (city || hwy) facts.push({ ico: , v: `${city ?? "—"} / ${hwy ?? "—"}`, l: "L/100 km ville / route" }); const rows: [string, ReactNode][] = []; if (v.trim) rows.push(["Version", v.trim]); if (v.exterior_color) rows.push(["Couleur extérieure", v.exterior_color]); if (v.interior_color) rows.push(["Couleur intérieure", v.interior_color]); if (v.vin) rows.push(["NIV (VIN)", {v.vin}]); if (v.stock_number) rows.push(["Nº de stock", v.stock_number]); rows.push(["Concessionnaire", `${v.dealer_name || v.source}${v.city ? ` · ${v.city}` : ""}`]); const texte = (v.description || "").trim(); const long = texte.length > 420; const feats = v.features ?? []; const LIMIT = 12; const vin = v.vin_info && Object.keys(v.vin_info).length > 0 ? Object.entries(v.vin_info) : []; return (
{facts.map((x) => (
{x.v}
{x.l}
))}
{rows.map(([k, val]) =>
{k}{val}
)}

Description du concessionnaire

{texte ? ( <>

{texte}

{long && setDescOpen(!descOpen)} expanded={descOpen}>{descOpen ? "Réduire" : "Lire la suite"}} ) :

Le concessionnaire ne fournit pas de description pour cette annonce.

} {feats.length > 0 && ( <>

Équipements · {feats.length}

{(allFeat ? feats : feats.slice(0, LIMIT)).map((f) => (
{f}
))}
{feats.length > LIMIT && setAllFeat(!allFeat)} expanded={allFeat}>{allFeat ? "Réduire" : `Voir les ${feats.length} équipements`}} )} {vin.length > 0 && (
{vin.map(([k, val]) =>
{k}{val}
)}

Décodé du NIV — base vPIC (NHTSA). Les données constructeur peuvent différer de la version canadienne.{NBSP}

)}
); }