SPB Git

Repository Public

StatsView.tsx 6.5 KB 152 lines tsx

1/**2 * =============================================================================3 *                  SP BOUCHER | SOFTWARE & RESEARCH4 *             ARTIFICIAL INTELLIGENCE • FINANCE • ENGINEERING5 * =============================================================================6 *7 * Project          : Vrai-Prix8 * File             : src/components/StatsView.tsx9 * Module           : components10 * Repository       : https://git.spboucher.ai/vrai-prix11 * Created          : 2026-08-0912 * Last Modified    : 2026-08-2513 *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/**43 * /stats — bandeau « LE CHIFFRE » (valeur totale du parc immobilier44 * québécois, comparaisons vulgarisées). Les sections analytiques45 * (KPI, jauges, séries, répartitions, tableaux, records, rapports PDF)46 * sont servies par <StatsDashboard/>.47 */48"use client";49import { CountUp } from "./MetricViz";50import { useLang } from "./LangContext";5152export interface ProvStats {53  generated: string;54  unites: number;55  valeur_totale_2026: number;56  valeur_role_totale: number;57  valeur_mediane_2026: number;58  croissance_2021_2026_pct: number;59  logements: number;60  aire_etages_km2: number;61  terrain_km2: number;62  municipalites: number;63  totaux_annee: { year: number; total: number; n: number }[];64  par_type: { type: string; n: number; total: number; mediane: number | null }[];65  par_ville: { ville: string; n: number; total: number; mediane: number | null }[];66}6768const POP_QC = 9_111_000; // population du Québec (2026, ISQ)69const BUDGET_QC = 165_800_000_000; // dépenses budget QC 2026-2027 (approx.)70const PIB_QC = 640_000_000_000; // PIB nominal QC (approx. 2025)7172const money = (v: number, lang: string, frac = 0) =>73  new Intl.NumberFormat(lang === "fr" ? "fr-CA" : "en-CA", {74    style: "currency",75    currency: "CAD",76    maximumFractionDigits: frac,77  }).format(v);7879const compact = (v: number, lang: string) => {80  const fr = lang === "fr";81  if (v >= 1e12) return `${(v / 1e12).toLocaleString(fr ? "fr-CA" : "en-CA", { maximumFractionDigits: 2 })} ${fr ? "billions $" : "T$"}`;82  if (v >= 1e9) return `${(v / 1e9).toLocaleString(fr ? "fr-CA" : "en-CA", { maximumFractionDigits: 1 })} G$`;83  if (v >= 1e6) return `${(v / 1e6).toLocaleString(fr ? "fr-CA" : "en-CA", { maximumFractionDigits: 1 })} M$`;84  return money(v, lang);85};8687const num = (v: number, lang: string) =>88  v.toLocaleString(lang === "fr" ? "fr-CA" : "en-CA");8990export default function StatsView({ s }: { s: ProvStats }) {91  const { lang } = useLang();92  const fr = lang === "fr";9394  return (95    <div className="pt-10 sm:pt-14">96      {/* ---- LE CHIFFRE ---- */}97      <section>98        <span className="kicker">{fr ? "Juste pour le show" : "Just for the show"}</span>99        <h1 className="vp-display mt-3 text-[clamp(26px,4.6vw,46px)] font-bold uppercase leading-[1.02] tracking-[-0.03em]">100          {fr ? (101            <>102              Tout l&apos;immobilier du Québec vaut,103              <br />104              <span className="hl">au dollar près</span>…105            </>106          ) : (107            <>108              All Québec real estate is worth,109              <br />110              <span className="hl">to the dollar</span>…111            </>112          )}113        </h1>114        <div className="rise mt-6 rounded-[2px] bg-[var(--ink-deep)] p-6 sm:p-10">115          <p className="vp-display break-all text-[clamp(30px,6.2vw,76px)] font-bold leading-none tracking-[-0.03em] text-[var(--accent-bright)]">116            <CountUp117              value={s.valeur_totale_2026}118              duration={2600}119              format={(v) => money(v, lang)}120            />121          </p>122          <p className="vp-mono mt-4 text-[11.5px] uppercase tracking-[0.1em] text-[rgba(255,81,72,0.75)]">123            {fr124              ? `≈ ${compact(s.valeur_totale_2026, lang)} · ${num(s.unites, lang)} propriétés · ${num(s.municipalites, lang)} municipalités · millésime 2026`125              : `≈ ${compact(s.valeur_totale_2026, lang)} · ${num(s.unites, lang)} properties · ${num(s.municipalites, lang)} municipalities · 2026 vintage`}126          </p>127          <div className="mt-6 flex flex-wrap gap-2.5">128            {(129              [130                [fr ? "par Québécois·e" : "per Quebecer", money(s.valeur_totale_2026 / POP_QC, lang)],131                [fr ? "budgets annuels du Québec" : "annual Québec budgets", `× ${(s.valeur_totale_2026 / BUDGET_QC).toFixed(1)}`],132                [fr ? "fois le PIB du Québec" : "× Québec GDP", `× ${(s.valeur_totale_2026 / PIB_QC).toFixed(1)}`],133                [fr ? "depuis 2021 (périmètre constant)" : "since 2021 (constant perimeter)", `+${s.croissance_2021_2026_pct.toLocaleString(fr ? "fr-CA" : "en-CA")} %`],134              ] as [string, string][]135            ).map(([k, v]) => (136              <span key={k} className="stat-chip max-w-full !whitespace-normal !border-[rgba(245,243,238,0.25)] !text-[rgba(245,243,238,0.85)]">137                <b className="!text-[var(--accent-bright)]">{v}</b> {k}138              </span>139            ))}140          </div>141        </div>142        <p className="vp-mono mt-3 text-[10.5px] uppercase tracking-[0.06em] text-ink-3">143          {fr144            ? "Somme des 3 747 008 estimations Vrai-Prix (modèle hédonique, rôle 2026). Évaluation municipale totale correspondante : "145            : "Sum of 3,747,008 Vrai-Prix estimates (hedonic model, 2026 roll). Corresponding total municipal assessment: "}146          {compact(s.valeur_role_totale, lang)}.147        </p>148      </section>149    </div>150  );151}152
Files main
Menu

Theme