/** * ============================================================================= * QWHPI — Quebec Weekly Housing Price Index * Author : Simon-Pierre Boucher * Contact : contact@spboucher.ai * File : web/components/Ticker.tsx * Purpose : Bloomberg-style infinite ticker tape — regions & cities YoY. * ============================================================================= */ "use client"; import { useEffect, useState } from "react"; import Link from "next/link"; import { fetchOverview, type OverviewRow } from "../lib/api"; export default function Ticker({ ptype = "all" }: { ptype?: string }) { const [rows, setRows] = useState([]); useEffect(() => { Promise.all([ fetchOverview("region", ptype), fetchOverview("municipality", ptype), ]) .then(([r, m]) => setRows([...m.rows, ...r.rows])) .catch(() => setRows([])); }, [ptype]); if (!rows.length) return
; const items = rows.map((r) => ( {r.geography_name} {r.index.toFixed(1)} {r.yoy_pct == null ? "—" : `${r.yoy_pct >= 0 ? "▲" : "▼"}${Math.abs(r.yoy_pct).toFixed(1)}%`} )); return (
{items}
{items}
); }