// ----------------------------------------------------------------------------- // Auto-Ka — Agrégateur de voitures usagées à vendre (province de Québec) // Auteur : Simon-Pierre Boucher — contact@spboucher.ai // Vehicle.tsx : fiche véhicule — galerie, specs, historique de prix, similaires // ----------------------------------------------------------------------------- import { useEffect, useState } from "react"; import { Link, useParams } from "react-router-dom"; import { VehicleDetail, fetchVehicle, fmtDate, fmtKm, fmtPrice } from "../api"; import VehicleCard from "../components/VehicleCard"; export default function VehiclePage() { const { uid } = useParams<{ uid: string }>(); const [v, setV] = useState(null); const [error, setError] = useState(false); const [img, setImg] = useState(0); useEffect(() => { setV(null); setError(false); setImg(0); if (uid) fetchVehicle(uid).then(setV).catch(() => setError(true)); window.scrollTo(0, 0); }, [uid]); if (error) return (
🚗

Véhicule introuvable

Il a peut-être été vendu — l'inventaire évolue chaque jour.

← Retour à la recherche

); if (!v) return (
); const prevPrice = v.price_history.find( (h) => h.price != null && v.price != null && h.price !== v.price )?.price; const specs: [string, string][] = [ ["Année", v.year ? String(v.year) : "—"], ["Kilométrage", fmtKm(v.mileage_km)], ["Transmission", v.transmission || "—"], ["Carburant", v.fuel || "—"], ["Motricité", v.drivetrain || "—"], ["Carrosserie", v.body_type || "—"], ["Moteur", v.engine || "—"], ["Couleur ext.", v.exterior_color || "—"], ["Couleur int.", v.interior_color || "—"], ["Portes", v.doors ? String(v.doors) : "—"], ["Places", v.seats ? String(v.seats) : "—"], ["NIV (VIN)", v.vin || "—"], ["No de stock", v.stock_number || "—"], ].filter(([, val]) => val !== "—") as [string, string][]; return (

← Retour à la recherche

{v.dealer_name || v.source} — {v.city}{v.region ? ` · ${v.region}` : ""}

{v.title}

{fmtPrice(v.price)}
{prevPrice != null && v.price != null && prevPrice > v.price && (
{fmtPrice(prevPrice)}
)}
{v.images.length > 0 ? ( {v.title} ) : (
🚗
)}
{v.images.length > 1 && (
{v.images.map((u, i) => ( {`photo setImg(i)} /> ))}
)}
{v.description && (

📝 Description du concessionnaire

{v.description}
)}

🔧 Caractéristiques

{specs.map(([k, val]) => ( ))}
{k} {val}
Voir chez {v.dealer_name || "le concessionnaire"} → {v.carfax_url && ( 📋 Rapport Carfax )}
annonce originale — prix et disponibilité confirmés à la source
{v.features.length > 0 && (

✨ Équipements ({v.features.length})

{v.features.map((f) => ( {f} ))}
)} {v.price_history.length > 1 && (

📉 Historique de prix

{v.price_history.map((h, i) => { const next = v.price_history[i + 1]; const dir = next?.price != null && h.price != null ? h.price < next.price ? "down" : h.price > next.price ? "up" : "" : ""; return (
{fmtDate(h.ts)} {fmtPrice(h.price)}
); })}
)}

ℹ️ Suivi Auto-Ka

Repéré le{fmtDate(v.first_seen)}
Vérifié le{fmtDate(v.updated_at)}
Statut{v.active ? "En vente" : "Retiré / vendu"}
{v.similar.length > 0 && (
Comparer

{v.make} {v.model} similaires au Québec

{v.similar.map((s) => ( ))}
)}
); }