SPB Git

Repository Public

Stats.tsx 25.2 KB 515 lines tsx

1// Marché locatif : l'offre affichée au Québec, lue comme un rapport.2// Chaque chiffre vient des annonces en ligne ; ce qui est estimé est dit estimé.34import { useMemo, useState } from "react";5import { Link } from "react-router";6import { useQuery } from "@tanstack/react-query";7import { ArrowDownRight, ArrowRight, ArrowUpRight, Download } from "lucide-react";8import { fetchDetailedStats, type DetailedStats } from "@/lib/api";9import { fmtAgo, fmtInt, fmtMoney, slugify } from "@/lib/format";10import { prettySource, useInView, useSourceNames, useTitle } from "@/lib/hooks";11import { doorClick } from "@/brand/transition";12import { BarList, Donut, Histogram, PctMeter, TrendChart, type Pt } from "@/components/marche/charts";13import { Chapter, ErrorNote, Nature, PageHero, Panel } from "@/components/marche/PageHero";14import { ButtonLink, buttonClass, Segmented, Skeleton } from "@/ui/primitives";1516// --- Tableau de bord temporel (/api/stats/dashboard) --------------------------------17interface Dashboard {18  period: { from: string; to: string; label: string };19  kpis: { id: string; label: string; value: number; delta_pct?: number; unit?: string }[];20  series: { id: string; title: string; unit: string; kind: string; points: Pt[]; compare?: Pt[] }[];21  breakdowns: { id: string; title: string; items: { label: string; value: number }[] }[];22  gauges: { id: string; label: string; value: number; unit: string }[];23}2425type Period = "7j" | "30j" | "3m" | "12m";26const PERIODS: { value: Period; label: string }[] = [27  { value: "7j", label: "7 jours" },28  { value: "30j", label: "30 jours" },29  { value: "3m", label: "3 mois" },30  { value: "12m", label: "12 mois" },31];3233async function fetchDashboard(period: Period): Promise<Dashboard> {34  const res = await fetch(`/api/stats/dashboard?period=${period}`);35  if (!res.ok) throw new Error(`API ${res.status}`);36  return (await res.json()) as Dashboard;37}3839// villes hors Québec parfois présentes dans les agrégats (sources pancanadiennes)40const HORS_QC = new Set(["Toronto", "Ottawa", "London", "Mississauga", "Hamilton", "Kitchener", "Waterloo", "Brampton", "Windsor", "Kingston", "Guelph", "Burlington", "Oakville", "Barrie", "Sarnia", "Etobicoke", "Scarborough", "North York", "Markham", "Vaughan", "Oshawa", "Cambridge", "St. Catharines", "Niagara Falls", "Peterborough", "Sudbury", "Thunder Bay", "Halifax", "Calgary", "Edmonton", "Vancouver", "Winnipeg", "Québec City"]);4142// grandeurs reconnues : certaines sources publient des libellés fantaisistes43const TYPE_ORDER = ["Chambre", "Studio", "1½", "2½", "3½", "4½", "5½", "6½+", "Loft", "Condo", "Maison"];4445function Delta({ pct }: { pct: number | undefined }) {46  if (pct == null) return null;47  const Icon = pct > 0 ? ArrowUpRight : ArrowDownRight;48  return (49    <span className="num inline-flex items-center gap-0.5 text-[0.84rem] text-ink-2" title="Variation par rapport à la période précédente">50      <Icon className="size-3.5" />51      {Math.abs(pct).toLocaleString("fr-CA", { maximumFractionDigits: 1 })} %52    </span>53  );54}5556/** Écart d'un loyer moyen à la moyenne provinciale. */57function Gap({ value, base }: { value: number; base: number | null }) {58  if (!base) return <span className="text-ink-3">—</span>;59  const g = Math.round(((value - base) / base) * 100);60  return (61    <span className={g === 0 ? "text-ink-3" : "text-ink-2"}>62      {g > 0 ? "+" : g < 0 ? "−" : ""}63      {Math.abs(g)} %64    </span>65  );66}6768// --- Chiffres clés --------------------------------------------------------------------69function KeyFigures({ d }: { d: DetailedStats }) {70  const t = d.totals;71  const items: [string, string, string][] = [72    ["Loyer médian affiché", fmtMoney(t.median), `moyenne ${fmtMoney(t.avg)}`],73    ["Logements en ligne", fmtInt(t.total), `${fmtInt(t.with_price)} avec un loyer affiché`],74    ["Disponibles maintenant", fmtInt(t.dispo_now), "selon la date indiquée dans l'annonce"],75    ["Villes couvertes", fmtInt(t.cities), `${fmtInt(t.regions)} régions · ${fmtInt(t.sources)} sources`],76  ];77  return (78    <section className="container-x">79      <dl className="grid grid-cols-2 gap-x-8 gap-y-7 border-t border-line pt-7 lg:grid-cols-4">80        {items.map(([label, value, hint]) => (81          <div key={label}>82            <dt className="text-[0.84rem] text-ink-3">{label}</dt>83            <dd className="num mt-1.5 text-[1.6rem] font-semibold leading-none sm:text-[1.85rem]">{value}</dd>84            <dd className="num mt-1.5 text-[0.8rem] text-ink-3">{hint}</dd>85          </div>86        ))}87      </dl>88    </section>89  );90}9192// --- Évolution -------------------------------------------------------------------------93function Trends() {94  const [period, setPeriod] = useState<Period>("30j");95  const [ref, inView] = useInView<HTMLElement>("300px");96  const q = useQuery({97    queryKey: ["stats-dashboard", period],98    queryFn: () => fetchDashboard(period),99    enabled: inView,100    staleTime: 10 * 60_000,101    placeholderData: (prev) => prev,102  });103  const serie = (id: string) => q.data?.series.find((s) => s.id === id);104  const kpi = (id: string) => q.data?.kpis.find((k) => k.id === id);105  const fv = q.data?.breakdowns.find((b) => b.id === "fairvalue");106  const actives = serie("actives_jour");107  const nouvelles = serie("nouvelles_jour");108  const loyer = serie("loyer_entree_jour");109  const fvTotal = Math.max(1, fv?.items.reduce((s, i) => s + i.value, 0) ?? 1);110111  return (112    <section ref={ref} className="container-x pt-14">113      <Chapter114        id="evolution"115        title="Évolution"116        text="Ce que nos connecteurs observent jour après jour : annonces en ligne, nouvelles publications et loyer demandé à l'entrée sur le marché."117        action={<Segmented value={period} onChange={setPeriod} options={PERIODS} label="Période" />}118      />119      {q.isError ? (120        <div className="mt-8">121          <ErrorNote onRetry={() => q.refetch()} text="Les tendances n'ont pas pu être chargées." />122        </div>123      ) : !q.data ? (124        <div className="mt-8 grid grid-cols-1 gap-8 lg:grid-cols-2">125          <Skeleton className="h-72" />126          <Skeleton className="h-72" />127        </div>128      ) : (129        <div key={q.data.period.label} className={`lk-rise mt-8 grid grid-cols-1 gap-x-12 gap-y-10 transition-opacity duration-200 lg:grid-cols-6 ${q.isPlaceholderData ? "opacity-55" : ""}`}>130          <Panel131            className="lg:col-span-4"132            title="Annonces en ligne"133            hint={`${q.data.period.label}, comparées à la période précédente (pointillé).`}134            action={<Delta pct={kpi("actives")?.delta_pct} />}135          >136            {actives && <TrendChart points={actives.points} compare={actives.compare} label={actives.title} />}137          </Panel>138          <Panel139            className="lg:col-span-2"140            title="Écart au marché"141            hint={142              <>143                Annonces actives dont la juste valeur est fiable. <Nature kind="estime" />144              </>145            }146          >147            {fv && (148              <Donut149                size={150}150                items={fv.items.map((it, i) => ({151                  label: ["Bon prix", "Prix juste", "Élevé"][i] ?? it.label,152                  value: it.value,153                  color: ["var(--good)", "color-mix(in srgb, var(--ink-3) 55%, transparent)", "var(--high)"][i] ?? "var(--brand)",154                }))}155                center={156                  <div>157                    <div className="num text-[1.25rem] font-semibold">{Math.round(((fv.items[0]?.value ?? 0) / fvTotal) * 100)} %</div>158                    <div className="text-[0.66rem] text-ink-3">sous le marché</div>159                  </div>160                }161              />162            )}163            <p className="mt-4 text-[0.8rem] text-ink-3">164              <Link to="/juste-valeur" className="underline decoration-line-2 underline-offset-[3px] hover:text-ink">165                Comment la juste valeur est estimée166              </Link>167            </p>168          </Panel>169          <Panel170            className="lg:col-span-3"171            title="Nouvelles annonces par jour"172            hint={kpi("nouvelles") ? `${fmtInt(kpi("nouvelles")!.value)} sur la période.` : undefined}173            action={<Delta pct={kpi("nouvelles")?.delta_pct} />}174          >175            {nouvelles && <TrendChart points={nouvelles.points} kind="bar" height={190} label={nouvelles.title} />}176          </Panel>177          <Panel className="lg:col-span-3" title="Loyer moyen des nouvelles annonces" hint="Loyer demandé le jour de la publication.">178            {loyer && <TrendChart points={loyer.points} format={fmtMoney} height={190} label={loyer.title} />}179          </Panel>180        </div>181      )}182    </section>183  );184}185186// --- Rapport ---------------------------------------------------------------------------187function Report({ d }: { d: DetailedStats }) {188  const names = useSourceNames();189  const t = d.totals;190191  const bins = useMemo(192    () =>193      d.histogram.map((h) => ({194        label: h.hi == null ? `${fmtMoney(h.lo)} et plus` : h.lo === 0 ? `moins de ${fmtMoney(h.hi)}` : `${fmtInt(h.lo)} à ${fmtMoney(h.hi)}`,195        short: h.hi == null ? `${(h.lo / 1000).toLocaleString("fr-CA")}k+` : h.lo < 1000 ? String(h.lo) : `${(h.lo / 1000).toLocaleString("fr-CA")}k`,196        count: h.count,197      })),198    [d.histogram],199  );200  const medianBin = t.median == null ? undefined : d.histogram.findIndex((h) => t.median! >= h.lo && (h.hi == null || t.median! < h.hi));201202  const types = useMemo(203    () => TYPE_ORDER.map((k) => d.by_type.find((x) => x.key === k)).filter((x): x is NonNullable<typeof x> => !!x && x.count >= 50 && x.avg_price != null),204    [d.by_type],205  );206  const cities = d.by_city.filter((c) => c.avg_price != null && !HORS_QC.has(c.key)).slice(0, 15);207  const regions = d.by_region.filter((r) => r.avg_price != null);208  // une seule ligne par immeuble (la plus forte baisse) et par source en alerte209  const baisses = useMemo(() => {210    const seen = new Set<string>();211    return d.baisses.filter((b) => {212      const k = `${b.title}|${b.city}`;213      if (seen.has(k)) return false;214      seen.add(k);215      return true;216    });217  }, [d.baisses]);218  const alertes = useMemo(() => {219    const seen = new Set<string>();220    return d.sante.alertes_24h.filter((a) => (seen.has(a.source) ? false : (seen.add(a.source), true)));221  }, [d.sante.alertes_24h]);222  const pi2 = TYPE_ORDER.map((k) => d.offre.prix_pi2.find((x) => x.key === k)).filter((x): x is NonNullable<typeof x> => !!x && x.count >= 100);223  const dispoTotal = d.offre.dispo_now + d.offre.dispo_date + d.offre.dispo_inconnue || 1;224225  const inclus: [string, number | null][] = [226    ["Stationnement", d.offre.stationnement_pct],227    ["Balcon", d.offre.balcon_pct],228    ["Climatisation", d.offre.clim_pct],229    ["Chauffage inclus", d.offre.chauffage_pct],230    ["Eau chaude incluse", d.offre.eau_chaude_pct],231    ["Électricité incluse", d.offre.electricite_pct],232    ["Internet inclus", d.offre.internet_pct],233    ["Meublé", d.offre.furnished_pct],234  ];235  const th = "border-b border-line-2 pb-2 text-left text-[0.76rem] font-medium text-ink-3";236  const td = "border-b border-line py-2.5 align-baseline";237238  return (239    <>240      <KeyFigures d={d} />241242      {/* --- Loyers --- */}243      <section className="container-x pt-14">244        <Chapter245          id="loyers"246          title="Loyers"247          text="Loyers demandés dans les annonces en ligne. Ce sont des prix affichés, pas les loyers payés par les locataires en place."248          action={<Nature kind="observe" />}249        />250        <div className="mt-8 grid grid-cols-1 gap-x-12 gap-y-10 lg:grid-cols-6">251          <Panel className="lg:col-span-4" title="Distribution des loyers" hint="Nombre d'annonces par tranche de 200 $.">252            <Histogram height={260} bins={bins} marker={medianBin != null && medianBin >= 0 ? medianBin : undefined} unit="annonces" />253            <p className="mt-4 text-[0.8rem] text-ink-3">254              La tranche en vert contient le loyer médian ({fmtMoney(t.median)}). Survolez ou touchez une barre pour lire une tranche.255            </p>256          </Panel>257          <Panel className="lg:col-span-2" title="Par grandeur" hint="Loyer moyen affiché.">258            <BarList format={fmtMoney} items={types.map((x) => ({ key: x.key, label: x.key, value: x.avg_price!, hint: fmtInt(x.count) }))} />259          </Panel>260        </div>261      </section>262263      {/* --- Comparaisons géographiques --- */}264      <section className="container-x pt-14">265        <Chapter id="territoire" title="Par ville et par région" text="Loyer moyen affiché, nombre d'annonces et écart à la moyenne provinciale." action={<Nature kind="observe" />} />266        <div className="mt-8 grid grid-cols-1 gap-x-12 gap-y-10 lg:grid-cols-6">267          <div className="lg:col-span-4">268            <h3 className="mb-4 border-t border-line pt-6 text-[1.25rem]">Les 15 villes les plus actives</h3>269            <table className="num w-full border-collapse text-[0.9rem]">270              <thead>271                <tr>272                  <th className={th}>Ville</th>273                  <th className={`${th} text-right max-sm:hidden`}>Annonces</th>274                  <th className={`${th} text-right max-sm:hidden`}>Sources</th>275                  <th className={`${th} text-right`}>Loyer moyen</th>276                  <th className={`${th} w-16 text-right`}>Écart</th>277                </tr>278              </thead>279              <tbody>280                {cities.map((c) => (281                  <tr key={c.key} className="group">282                    <td className={td}>283                      <Link to={`/ville/${slugify(c.key)}`} className="font-sans text-ink underline-offset-[3px] group-hover:text-brand group-hover:underline">284                        {c.key}285                      </Link>286                      <span className="block text-[0.76rem] text-ink-3 sm:hidden">{fmtInt(c.count)} annonces</span>287                    </td>288                    <td className={`${td} text-right text-ink-2 max-sm:hidden`}>{fmtInt(c.count)}</td>289                    <td className={`${td} text-right text-ink-3 max-sm:hidden`}>{fmtInt(c.sources ?? 0)}</td>290                    <td className={`${td} text-right font-medium text-ink`}>{fmtMoney(c.avg_price)}</td>291                    <td className={`${td} text-right`}>292                      <Gap value={c.avg_price!} base={t.avg} />293                    </td>294                  </tr>295                ))}296              </tbody>297            </table>298            <p className="mt-3 text-[0.8rem] text-ink-3">Écart : loyer moyen de la ville comparé à la moyenne de toutes les annonces ({fmtMoney(t.avg)}).</p>299          </div>300          <div className="space-y-10 lg:col-span-2">301            <Panel title="Par région" hint="Loyer moyen affiché.">302              <BarList format={fmtMoney} items={regions.map((r) => ({ key: r.key, label: r.key, value: r.avg_price!, hint: fmtInt(r.count) }))} />303            </Panel>304            <Panel title="Prix au pied carré" hint={`Loyer mensuel par pi², sur ${fmtInt(d.offre.superficie_connue)} annonces qui indiquent la superficie.`}>305              <BarList306                color="color-mix(in srgb, var(--ink-3) 70%, transparent)"307                format={(n) => `${n.toLocaleString("fr-CA", { minimumFractionDigits: 2, maximumFractionDigits: 2 })} $`}308                items={pi2.map((x) => ({ key: x.key, label: x.key, value: x.val, hint: fmtInt(x.count) }))}309              />310            </Panel>311          </div>312        </div>313      </section>314315      <Trends />316317      {/* --- L'offre --- */}318      <section className="container-x pt-14">319        <Chapter320          id="offre"321          title="L'offre disponible"322          text="Part des annonces qui mentionnent chaque caractéristique. Une annonce qui n'en dit rien n'est pas comptée comme un refus."323          action={<Nature kind="observe" />}324        />325        <div className="mt-8 grid grid-cols-1 gap-x-12 gap-y-10 lg:grid-cols-3">326          <Panel className="lg:col-span-2" title="Inclusions et commodités" hint="Parmi les annonces dont la fiche détaille les caractéristiques.">327            <div className="grid grid-cols-1 gap-x-12 gap-y-5 sm:grid-cols-2">328              {inclus.map(([label, v]) => (329                <PctMeter key={label} label={label} value={v} />330              ))}331            </div>332          </Panel>333          <div className="space-y-10">334            <Panel title="Animaux">335              <p className="num text-[1.85rem] font-semibold leading-none">{d.offre.pets_oui_pct == null ? "—" : `${Math.round(d.offre.pets_oui_pct)} %`}</p>336              <p className="mt-2 text-[0.86rem] leading-relaxed text-ink-3">337                des {fmtInt(d.offre.pets_connu)} annonces qui se prononcent acceptent les animaux, parfois sous conditions.338              </p>339            </Panel>340            <Panel title="Disponibilité">341              <div className="flex h-1.5 overflow-hidden rounded-full bg-surface-3">342                <div style={{ width: `${(d.offre.dispo_now / dispoTotal) * 100}%`, background: "var(--brand)" }} />343                <div style={{ width: `${(d.offre.dispo_date / dispoTotal) * 100}%`, background: "color-mix(in srgb, var(--ink-3) 60%, transparent)" }} />344              </div>345              <ul className="num mt-4 text-[0.9rem]">346                {(347                  [348                    ["Maintenant", d.offre.dispo_now, "var(--brand)"],349                    ["À une date annoncée", d.offre.dispo_date, "color-mix(in srgb, var(--ink-3) 60%, transparent)"],350                    ["Non précisée", d.offre.dispo_inconnue, "var(--surface-3)"],351                  ] as const352                ).map(([l, n, c]) => (353                  <li key={l} className="flex items-center justify-between gap-3 border-b border-line py-2 last:border-0">354                    <span className="inline-flex items-center gap-2.5 font-sans text-ink-2">355                      <span className="size-2 rounded-[2px]" style={{ background: c }} />356                      {l}357                    </span>358                    <span className="font-medium">{fmtInt(n)}</span>359                  </li>360                ))}361              </ul>362            </Panel>363          </div>364        </div>365      </section>366367      {/* --- Mouvements et sources --- */}368      <section className="container-x pt-14">369        <Chapter id="mouvements" title="Mouvements récents" text="Les loyers revus à la baisse par l'annonceur, et l'état de la collecte." />370        <div className="mt-8 grid grid-cols-1 gap-x-12 gap-y-10 lg:grid-cols-2">371          <Panel title="Baisses de prix" hint="Une baisse très forte peut aussi être la correction d'une coquille dans l'annonce d'origine." action={<Nature kind="observe" />}>372            {baisses.length === 0 ? (373              <p className="text-[0.9rem] text-ink-3">Aucune baisse observée récemment.</p>374            ) : (375              <ul>376                {baisses.slice(0, 8).map((b) => (377                  <li key={b.uid}>378                    <Link379                      to={`/logement/${encodeURIComponent(b.uid)}`}380                      onClick={(e) => doorClick(e, { uid: b.uid, image: null, context: "favorite" })}381                      className="group flex items-baseline gap-4 border-b border-line py-2.5"382                    >383                      <span className="min-w-0 flex-1">384                        <span className="block truncate text-[0.94rem] text-ink group-hover:text-brand">{b.title || "Logement"}</span>385                        <span className="num block text-[0.8rem] text-ink-3">386                          {b.city ? `${b.city} · ` : ""}387                          <span className="line-through">{fmtMoney(b.avant)}</span> <span className="text-ink-2">{fmtMoney(b.apres)}</span>388                        </span>389                      </span>390                      <span className="num shrink-0 text-[0.9rem] font-medium text-good">−{Math.abs(Math.round(b.pct))} %</span>391                    </Link>392                  </li>393                ))}394              </ul>395            )}396          </Panel>397          <Panel title="État de la collecte" hint="Synchronisation des dernières 24 heures.">398            <dl className="num grid grid-cols-3 gap-x-6 border-b border-line pb-5">399              <div>400                <dt className="font-sans text-[0.8rem] text-ink-3">Sources à jour</dt>401                <dd className="mt-1 text-[1.35rem] font-semibold leading-none">{fmtInt(d.sante.sources_sync_24h)}</dd>402              </div>403              <div>404                <dt className="font-sans text-[0.8rem] text-ink-3">Géolocalisées</dt>405                <dd className="mt-1 text-[1.35rem] font-semibold leading-none">{t.gps_pct == null ? "—" : `${Math.round(t.gps_pct)} %`}</dd>406              </div>407              <div>408                <dt className="font-sans text-[0.8rem] text-ink-3">Superficie moyenne</dt>409                <dd className="mt-1 text-[1.35rem] font-semibold leading-none">{t.superficie_moyenne ? `${fmtInt(t.superficie_moyenne)} pi²` : "—"}</dd>410              </div>411            </dl>412            {alertes.length > 0 && (413              <>414                <p className="eyebrow mb-1 mt-5">À surveiller ({alertes.length})</p>415                <ul>416                  {alertes.slice(0, 6).map((a) => (417                    <li key={a.source + a.ts} className="flex items-baseline justify-between gap-3 border-b border-line py-2 text-[0.9rem]">418                      <Link to={`/g/${a.source}`} className="min-w-0 truncate text-ink hover:text-brand">419                        {prettySource(a.source, names)}420                      </Link>421                      <span className="num shrink-0 text-[0.8rem] text-ink-3">{fmtAgo(a.ts)}</span>422                    </li>423                  ))}424                </ul>425                <p className="mt-3 text-[0.8rem] leading-relaxed text-ink-3">426                  Quand une source ne répond plus, ses annonces restent affichées telles quelles plutôt que d'être retirées à tort.427                </p>428              </>429            )}430            <Link to="/sources" className="group mt-5 inline-flex items-center gap-1.5 text-[0.9rem] font-medium text-brand">431              Toutes les sources <ArrowRight className="size-4 transition-transform duration-150 group-hover:translate-x-0.5" />432            </Link>433          </Panel>434        </div>435      </section>436437      {/* --- Méthode --- */}438      <section className="container-x pt-14">439        <Chapter id="methode" title="Méthode et limites" />440        <div className="mt-6 grid gap-x-12 gap-y-6 lg:grid-cols-3">441          <div>442            <p className="mb-2">443              <Nature kind="observe" />444            </p>445            <p className="text-[0.9rem] leading-relaxed text-ink-2">446              Les loyers, les grandeurs, les villes, les inclusions et les disponibilités sont lus tels quels dans les annonces en ligne, après retrait des447              doublons et des annonces mises en quarantaine. Seuls les loyers plausibles (de 195 $ à 15 000 $ par mois) entrent dans les moyennes.448            </p>449          </div>450          <div>451            <p className="mb-2">452              <Nature kind="estime" />453            </p>454            <p className="text-[0.9rem] leading-relaxed text-ink-2">455              L'écart au marché repose sur la juste valeur, une estimation calculée par Lou-Ka à partir de logements comparables. Elle est indicative et ne456              remplace pas une évaluation.457            </p>458          </div>459          <div>460            <p className="mb-2">461              <Nature kind="indisponible" />462            </p>463            <p className="text-[0.9rem] leading-relaxed text-ink-2">464              Lou-Ka ne connaît ni les loyers réellement payés, ni les logements loués sans annonce, ni le taux d'inoccupation. Une caractéristique absente465              d'une annonce est comptée comme non précisée, jamais comme un refus.466            </p>467          </div>468        </div>469      </section>470    </>471  );472}473474export default function Stats() {475  useTitle("Marché locatif du Québec : loyers, tendances et disponibilités");476  const q = useQuery({ queryKey: ["stats-detailed"], queryFn: fetchDetailedStats, staleTime: 5 * 60_000 });477  return (478    <>479      <PageHero480        eyebrow="Marché locatif"481        title="Les loyers au Québec, tels qu'ils sont affichés"482        text="Loyers demandés, comparaisons par ville et par grandeur, évolution et offre disponible, calculés en continu à partir des annonces que Lou-Ka agrège."483      >484        <div className="flex flex-wrap gap-2.5">485          <a href="/api/stats/rapport.pdf" className={buttonClass("primary")}>486            <Download className="size-4" /> Rapport PDF487          </a>488          <ButtonLink to="/recherche" variant="outline">489            Explorer la carte490          </ButtonLink>491        </div>492      </PageHero>493      {q.isError ? (494        <div className="container-x">495          <ErrorNote onRetry={() => q.refetch()} text="Les statistiques du marché n'ont pas pu être chargées." />496        </div>497      ) : !q.data ? (498        <div className="container-x space-y-10">499          <div className="grid grid-cols-2 gap-8 border-t border-line pt-7 lg:grid-cols-4">500            {Array.from({ length: 4 }, (_, i) => (501              <Skeleton key={i} className="h-16" />502            ))}503          </div>504          <div className="grid grid-cols-1 gap-12 lg:grid-cols-2">505            <Skeleton className="h-72" />506            <Skeleton className="h-72" />507          </div>508        </div>509      ) : (510        <Report d={q.data} />511      )}512    </>513  );514}515
Files main
Menu

Theme