SPB Git

Repository Public

page.tsx 2.1 KB 38 lines tsx

1// Auteur : Simon-Pierre Boucher — contact@spboucher.ai2/**3 * /cout — Méthode du coût : landing « Coût aujourd'hui » ou atelier4 * (?property=<id_provinc> | ?mode=construction | ?estimate=<uuid>).5 * Les données de la landing sont lues côté serveur dans la base de coûts locale6 * (jamais de crawl dans le chemin utilisateur).7 */8import type { Metadata } from "next";9import Landing from "@/components/cout/Landing";10import Workbench from "@/components/cout/Workbench";11import { buildOverview, loadLocations } from "@/lib/cost/catalog";12import { cached } from "@/lib/cost/cache";13import type { CostOverview } from "@/lib/cost/types";1415export const dynamic = "force-dynamic";1617export const metadata: Metadata = {18  title: "Méthode du coût — combien coûterait ce bâtiment à reconstruire aujourd'hui ?",19  description:20    "Méthode du coût : coût de remplacement à neuf décomposé par assemblages (matériaux, main-d'œuvre APCHQ/CCQ, équipement), facteurs régionaux, frais indirects, dépréciation physique, fonctionnelle et externe, valeur du terrain, fourchette et indice de confiance. Chaque hypothèse et chaque source sont visibles.",21  alternates: { canonical: "/cout" },22};2324export default async function CoutPage({ searchParams }: { searchParams: Promise<Record<string, string | string[] | undefined>> }) {25  const sp = await searchParams;26  const property = typeof sp.property === "string" ? sp.property.replace(/\D/g, "") || null : null;27  const estimate = typeof sp.estimate === "string" && /^[0-9a-f-]{36}$/.test(sp.estimate) ? sp.estimate : null;28  const construction = sp.mode === "construction";29  if (property || estimate || construction) {30    let locations: CostOverview["locations"] = [];31    try { locations = loadLocations(); } catch { /* base indisponible */ }32    return <Workbench key={`${property ?? ""}|${estimate ?? ""}|${construction}`} propertyId={property} estimateId={estimate} locations={locations} />;33  }34  let overview: CostOverview | null = null;35  try { overview = cached("overview", 10 * 60_000, () => buildOverview()); } catch { overview = null; }36  return <Landing overview={overview} />;37}38
Files main
Menu

Theme