import { useEffect, useMemo, useState } from "react"; import { getFedFunds, getHistory, type FedFundsResponse, type HistoryResponse } from "../api"; import { computeTimeDomain } from "../lib/chartTime"; import { buildLede } from "../lib/narrative"; import Timeline from "./Timeline"; import FedFundsChart from "./FedFundsChart"; import DocumentDrilldown from "./DocumentDrilldown"; import HighlightsDashboard from "./HighlightsDashboard"; import RegimeLegend from "./RegimeLegend"; export default function HistoryView() { const [history, setHistory] = useState(null); const [historyError, setHistoryError] = useState(null); const [fedFunds, setFedFunds] = useState(null); const [selectedDocId, setSelectedDocId] = useState(null); useEffect(() => { getHistory() .then(setHistory) .catch((err) => setHistoryError(err instanceof Error ? err.message : String(err))); getFedFunds() .then(setFedFunds) .catch(() => setFedFunds(null)); // the rate chart is a nice-to-have, not core -- fail quietly }, []); const domain = useMemo<[number, number] | null>(() => { if (!history) return null; return computeTimeDomain( history.points.map((p) => p.date), history.regimes, ); }, [history]); if (historyError) { return

Couldn't load history: {historyError}

; } if (!history || !domain) { return

Loading historical data…

; } return (

{buildLede(history.highlights)}

Sentiment over time

{fedFunds && }
{selectedDocId && ( setSelectedDocId(null)} /> )}

Key highlights

Fed Chair eras & data notes

); }