SPB Git

Repository Public

page.tsx 4.1 KB 76 lines tsx

1/**2 * =============================================================================3 *                  SP BOUCHER | SOFTWARE & RESEARCH4 *             ARTIFICIAL INTELLIGENCE • FINANCE • ENGINEERING5 * =============================================================================6 *7 * Project          : Vrai-Prix8 * File             : src/app/cout/assemblage/page.tsx9 * Module           : app10 * 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 — méthode du coût : catalogue des assemblages (+ fiche d'un article via ?item=CODE).43import type { Metadata } from "next";44import AssemblyCatalog, { type CatalogRow, type ItemCard } from "@/components/cout/AssemblyCatalog";45import { buildContext, getItem, priceHistory } from "@/lib/cost/catalog";46import { assemblyUnitCost } from "@/lib/cost/engine";47import { cached } from "@/lib/cost/cache";4849export const dynamic = "force-dynamic";5051export const metadata: Metadata = {52  title: "Catalogue des assemblages de construction — méthode du coût",53  description: "Plus de 70 assemblages résidentiels (fondations, structure, enveloppe, toiture, ouvertures, finitions, cuisine, salle de bain, mécanique, électricité, extérieur) décomposés en matériaux, heures de main-d'œuvre APCHQ/CCQ et équipement, avec provenance de chaque prix.",54  alternates: { canonical: "/cout/assemblage" },55};5657export default async function AssemblyCatalogPage({ searchParams }: { searchParams: Promise<Record<string, string | string[] | undefined>> }) {58  const sp = await searchParams;59  const itemCode = typeof sp.item === "string" ? sp.item.slice(0, 40) : null;60  let rows: CatalogRow[] = [];61  let asOf = "";62  let item: ItemCard | null = null;63  try {64    const data = cached("catalog:QC-MTL", 10 * 60_000, () => {65      const ctx = buildContext({ locationCode: "QC-MTL" });66      return { asOf: ctx.asOf, rows: [...ctx.assemblies.values()].map((a) => { const u = assemblyUnitCost(a, ctx); return { code: a.code, nameFr: a.nameFr, nameEn: a.nameEn, unit: a.unit, category: a.category, quality: a.quality, economicLife: a.economicLife, material: u.material, labour: u.labour, equipment: u.equipment, direct: u.direct, observedShare: u.observedShare, freshestObservation: u.freshestObservation, components: a.components.length } satisfies CatalogRow; }), ctx };67    });68    rows = data.rows; asOf = data.asOf;69    if (itemCode) {70      const it = getItem(itemCode);71      if (it) item = { item: it, price: data.ctx.prices.get(it.code) ?? null, history: priceHistory(it.code).map((h) => ({ date: h.date, price: h.price, source: h.source, url: h.url, regular: h.regular, kind: h.kind, outlier: h.outlier })), usedBy: [...data.ctx.assemblies.values()].filter((a) => a.components.some((c) => c.itemCode === it.code)).map((a) => ({ code: a.code, nameFr: a.nameFr, nameEn: a.nameEn, unit: a.unit, quantity: a.components.find((c) => c.itemCode === it.code)!.quantity })) };72    }73  } catch { /* base indisponible */ }74  return <AssemblyCatalog rows={rows} asOf={asOf} item={item} />;75}76
Files main
Menu

Theme