SPB Git

Repository Public

CatalogueView.tsx 12.7 KB 115 lines tsx

1/**2 * =============================================================================3 *                  SP BOUCHER | ACADEMIC RESEARCH4 *             ARTIFICIAL INTELLIGENCE • FINANCE • ENGINEERING5 * =============================================================================6 *7 * PROJECT METADATA8 * -----------------------------------------------------------------------------9 * Project          : UQO Éval10 * File             : src/components/metre/CatalogueView.tsx11 * Module           : components12 * Repository       : https://git.spboucher.ai/uqo-eval13 * Project Website  : https://www.uqo-eval.app14 * Created          : 2026-10-2815 * Last Modified    : 2026-10-2816 *17 * =============================================================================18 * SOFTWARE MAINTAINER & AFFILIATION19 * =============================================================================20 *21 * Maintainer       : Simon-Pierre Boucher22 * Position         : Professor of Finance23 * Institution      : Université du Québec en Outaouais (UQO)24 * Department       : Département des sciences administratives25 * Website          : https://spboucher.ai26 * Git              : https://git.spboucher.ai27 *28 * Research Contact : research@spboucher.ai29 * Direct Contact   : simon@spboucher.ai30 * Security/Admin   : admin@spboucher.ai31 *32 * The affiliation is descriptive. It is not an institutional endorsement,33 * a license grant or a determination of ownership.34 *35 * =============================================================================36 * COPYRIGHT, AUTHORSHIP & DATA37 * =============================================================================38 *39 * Copyright (c) the author(s) of this work.40 * Ownership is not asserted by this notice; see the repository records.41 *42 * This header identifies the maintainer of the software. Scientific43 * authorship of any associated paper is stated in the paper itself and44 * is not changed by this notice. Datasets and third-party materials45 * remain the property of their respective owners and licensors.46 *47 * This file is governed by the applicable project license, copyright48 * notices, institutional agreements and relevant law.49 *50 * =============================================================================51 * LICENSE & MAINTENANCE52 * =============================================================================53 *54 * License          : None specified (no license file in this repository)55 * Classification   : Public56 *57 * =============================================================================58 * END OF SP BOUCHER SOURCE HEADER59 * =============================================================================60 */6162// UQO Éval — Métré : catalogue — recherche d'assemblages et d'articles (prix du jour, provenance), grille de main-d'œuvre, observations par classe d'évidence.63"use client";64import { useEffect, useState } from "react";65import RsmeansPanel from "./RsmeansPanel";66import Link from "next/link";67import { useLang } from "@/components/LangContext";68import { api, Block, Crumbs, Field, Input, Kicker, money, num, Prov, Select, useMe } from "./ui";69import { unitLabel } from "@/lib/metre/units";7071interface Cat { assemblies: { code: string; nameFr: string; nameEn: string; unit: string; category: string; source: string; direct: number | null; observedShare: number | null }[]; items: { code: string; nameFr: string; nameEn: string; unit: string; price: number | null; kind: string | null }[] }72interface Obs { id: string; sourceKey: string; evidenceClass: string; description: string; unit: string | null; amount: number | null; geography: string | null; buyer: string | null; scheme: string | null; code: string | null; label: string | null; dateBasis: string | null; license: string; verificationStatus: string; uncertaintyNote: string | null; sourceUrl: string | null }73const CLASSES = ["published_schedule", "awarded_contract_total", "awarded_unit_bid", "supplier_quote", "contractor_quote", "permit_declared_value", "modeled", "user_assumption"];7475export default function CatalogueView() {76  const { lang } = useLang(); const fr = lang === "fr";77  const me = useMe();78  const [q, setQ] = useState(""); const [date, setDate] = useState(new Date().toISOString().slice(0, 10)); const [region, setRegion] = useState("");79  const [cat, setCat] = useState<Cat | null>(null);80  const [labour, setLabour] = useState<{ tradeCode: string; tradeNameFr: string; tradeNameEn: string; totalEmployerCost: number; baseWage: number; effectiveFrom: string; source: string; sourceUrl: string | null }[]>([]);81  const [oq, setOq] = useState(""); const [ocls, setOcls] = useState(""); const [obs, setObs] = useState<Obs[]>([]);82  useEffect(() => { if (!me.user) return; const t = setTimeout(() => api<Cat>(`/catalogue?q=${encodeURIComponent(q)}&date=${date}${region ? `&region=${region}` : ""}&limit=60`).then(setCat).catch(() => setCat(null)), 250); return () => clearTimeout(t); }, [q, date, region, me.user]);83  useEffect(() => { if (me.user) api<{ labour: typeof labour }>(`/labour?date=${date}`).then((r) => setLabour(r.labour)).catch(() => undefined); }, [date, me.user]);84  useEffect(() => { if (!me.user) return; const t = setTimeout(() => api<{ observations: Obs[] }>(`/admin/observations?q=${encodeURIComponent(oq)}${ocls ? `&class=${ocls}` : ""}&limit=60`).then((r) => setObs(r.observations)).catch(() => setObs([])), 250); return () => clearTimeout(t); }, [oq, ocls, me.user]);85  if (me.loading) return null;86  if (!me.user) return <p className="py-16 text-ink-2">…</p>;87  return (88    <div className="py-8">89      <section className="rise"><div className="border-b-2 border-ink pb-2.5"><Crumbs items={[{ href: "/", label: "UQO Éval" }, { href: "/quantity-survey", label: "Quantity Survey" }, { label: fr ? "Catalogue" : "Catalogue" }]} /></div>90        <div className="mt-5"><Kicker>{fr ? "Catalogue de coûts" : "Cost catalogue"}</Kicker><h1 className="vp-display mt-2 text-[clamp(22px,3.4vw,34px)] font-bold uppercase leading-[1.02] tracking-[-0.03em]">{fr ? "RSMeans Québec, articles, assemblages, main-d'œuvre, observations" : "RSMeans Québec, items, assemblies, labour, observations"}</h1><p className="mt-2 max-w-2xl text-[14px] text-ink-2">{fr ? "Prix canoniques du catalogue UQO Éval (détaillants observés, grilles APCHQ, indices StatCan, références internes étiquetées « hypothèse ») et observations de prix du module par classe d'évidence. Un total de contrat SEAO ou une valeur de permis n'est jamais un prix unitaire." : "Canonical prices of the UQO Éval catalogue (observed retailers, APCHQ grids, StatCan indices, internal references labelled “assumption”) and the module's price observations by evidence class. A SEAO contract total or a permit value is never a unit price."} <Link href="/cout" className="text-accent">{fr ? "Détails des sources →" : "Source details →"}</Link></p></div>91      </section>92      <div className="mt-8 space-y-12">93        <Block num="01" title={fr ? "Recherche" : "Search"}>94          <div className="grid gap-4 sm:grid-cols-3"><Field label={fr ? "Mots-clés" : "Keywords"}><Input value={q} onChange={(e) => setQ(e.target.value)} placeholder={fr ? "mur, toiture, gypse, béton…" : "wall, roofing, drywall, concrete…"} /></Field><Field label={fr ? "Date des prix" : "Price date"}><Input type="date" value={date} onChange={(e) => setDate(e.target.value)} /></Field><Field label={fr ? "Région" : "Region"}><Select value={region} onChange={(e) => setRegion(e.target.value)}><option value="">{fr ? "Montréal (défaut)" : "Montréal (default)"}</option>{["QC-MTL", "QC-LAV", "QC-QUE", "QC-GAT", "QC-SHE", "QC-TRO", "QC-SAG", "QC-RIM", "QC-ROU", "QC-SEP", "QC-GAS", "QC-NOR", "QC-ABI", "QC-MAU", "QC-EST", "QC-LAU"].map((c) => <option key={c} value={c}>{c}</option>)}</Select></Field></div>95          <div className="grid gap-6 lg:grid-cols-2">96            <div><p className="klabel mb-2">{fr ? "Assemblages" : "Assemblies"} ({cat?.assemblies.length ?? 0})</p><div className="src-wrap"><table className="src-table"><thead><tr><th>Code</th><th>{fr ? "Nom" : "Name"}</th><th className="text-right">{fr ? "Direct / unité" : "Direct / unit"}</th><th>{fr ? "Obs." : "Obs."}</th></tr></thead><tbody>{cat?.assemblies.map((a) => <tr key={a.code}><td className="vp-mono text-[11.5px]">{a.source === "custom" ? "★ " : ""}{a.code}</td><td className="text-[13px]">{fr ? a.nameFr : a.nameEn}<div className="vp-mono text-[10px] text-ink-3">{a.category}</div></td><td className="vp-mono text-right">{a.direct != null ? `${money(a.direct, lang, 2)}/${unitLabel(a.unit, fr)}` : "—"}</td><td className="vp-mono text-[11px]">{a.observedShare != null ? `${Math.round(a.observedShare * 100)} %` : "—"}</td></tr>)}</tbody></table></div></div>97            <div><p className="klabel mb-2">{fr ? "Articles" : "Items"} ({cat?.items.length ?? 0})</p><div className="src-wrap"><table className="src-table"><thead><tr><th>Code</th><th>{fr ? "Nom" : "Name"}</th><th className="text-right">{fr ? "Prix" : "Price"}</th><th>Prov.</th></tr></thead><tbody>{cat?.items.map((it) => <tr key={it.code}><td className="vp-mono text-[11.5px]">{it.code}</td><td className="text-[13px]">{fr ? it.nameFr : it.nameEn}</td><td className="vp-mono text-right">{it.price != null ? `${money(it.price, lang, 2)}/${unitLabel(it.unit, fr)}` : "—"}</td><td><Prov kind={it.kind ?? "assumption"} fr={fr} /></td></tr>)}</tbody></table></div></div>98          </div>99        </Block>100        <Block num="01 bis" title={fr ? "RSMeans — coûts unitaires localisés pour le Québec" : "RSMeans — unit costs localized for Québec"} id="rsmeans"><RsmeansPanel fr={fr} lang={lang} /></Block>101        <Block num="02" title={fr ? "Main-d'œuvre — coût employeur (APCHQ / CCQ)" : "Labour — employer cost (APCHQ / CCQ)"}>102          <div className="src-wrap"><table className="src-table"><thead><tr><th>{fr ? "Métier" : "Trade"}</th><th className="text-right">{fr ? "Salaire de base" : "Base wage"}</th><th className="text-right">{fr ? "Coût employeur" : "Employer cost"}</th><th>{fr ? "En vigueur" : "Effective"}</th><th>Source</th></tr></thead><tbody>{labour.map((l) => <tr key={l.tradeCode}><td>{fr ? l.tradeNameFr : l.tradeNameEn} <span className="vp-mono text-[10px] text-ink-3">{l.tradeCode}</span></td><td className="vp-mono text-right">{num(l.baseWage, lang, 2)} $/h</td><td className="vp-mono text-right"><b>{num(l.totalEmployerCost, lang, 2)} $/h</b></td><td className="vp-mono text-[11px]">{l.effectiveFrom}</td><td className="text-[12px]">{l.sourceUrl ? <a className="text-accent" href={l.sourceUrl} target="_blank" rel="noreferrer">{l.source}</a> : l.source}</td></tr>)}{!labour.length && <tr><td colSpan={5} className="text-ink-2">—</td></tr>}</tbody></table></div>103        </Block>104        <Block num="03" title={fr ? "Observations de prix du module (classes d'évidence)" : "Module price observations (evidence classes)"}>105          <div className="grid gap-4 sm:grid-cols-2"><Field label={fr ? "Texte" : "Text"}><Input value={oq} onChange={(e) => setOq(e.target.value)} placeholder={fr ? "béton, toiture, Laval…" : "concrete, roofing, Laval…"} /></Field><Field label={fr ? "Classe" : "Class"}><Select value={ocls} onChange={(e) => setOcls(e.target.value)}><option value="">{fr ? "toutes" : "all"}</option>{CLASSES.map((c) => <option key={c} value={c}>{c}</option>)}</Select></Field></div>106          <div className="src-wrap"><table className="src-table"><thead><tr><th>{fr ? "Classe" : "Class"}</th><th>{fr ? "Description" : "Description"}</th><th className="text-right">{fr ? "Montant" : "Amount"}</th><th>{fr ? "Unité" : "Unit"}</th><th>{fr ? "Lieu / acheteur" : "Place / buyer"}</th><th>{fr ? "Date" : "Date"}</th><th>{fr ? "Licence" : "Licence"}</th></tr></thead><tbody>107            {obs.map((o) => <tr key={o.id}><td className="vp-mono text-[10.5px] uppercase">{o.evidenceClass}<div className="text-ink-3">{o.sourceKey} · {o.verificationStatus}</div></td><td className="text-[12.5px]">{o.sourceUrl ? <a className="text-accent" href={o.sourceUrl} target="_blank" rel="noreferrer">{o.description}</a> : o.description}{o.code && <div className="vp-mono text-[10px] text-ink-3">{o.scheme} {o.code} — {o.label}</div>}{o.uncertaintyNote && <div className="text-[10.5px] text-[var(--amber)]">{o.uncertaintyNote}</div>}</td><td className="vp-mono text-right">{money(o.amount, lang)}</td><td className="vp-mono text-[11px]">{o.unit}</td><td className="text-[12px]">{o.geography ?? "—"}{o.buyer ? <div className="text-ink-3">{o.buyer}</div> : null}</td><td className="vp-mono text-[11px]">{o.dateBasis ?? "—"}</td><td className="text-[11px]">{o.license}</td></tr>)}108            {!obs.length && <tr><td colSpan={7} className="text-ink-2">{fr ? "Aucune observation (l'administrateur doit lancer une ingestion SEAO/permis ou importer un barème)." : "No observation (an administrator must run a SEAO/permit ingestion or import a schedule)."}</td></tr>}109          </tbody></table></div>110        </Block>111      </div>112    </div>113  );114}115
Files main
Menu

Theme