From 16d9eb4f864fe8c29a9dee57ec47f77b34ae0df4 Mon Sep 17 00:00:00 2001 From: Tyler Hoang Date: Mon, 18 May 2026 22:18:20 -0700 Subject: feat: wire Ratios subtab into FinancialsPage, move tab strip up from FinancialsCard --- frontend/components/prism/FinancialsPage.tsx | 68 ++++++++++++++++++++-------- 1 file changed, 50 insertions(+), 18 deletions(-) (limited to 'frontend/components/prism/FinancialsPage.tsx') diff --git a/frontend/components/prism/FinancialsPage.tsx b/frontend/components/prism/FinancialsPage.tsx index fcd2763..9a56f2c 100644 --- a/frontend/components/prism/FinancialsPage.tsx +++ b/frontend/components/prism/FinancialsPage.tsx @@ -4,10 +4,12 @@ import { api } from "@/lib/api"; import { buildKpis } from "@/lib/overview"; import { FinancialsCard } from "@/components/prism/FinancialsCard"; import { KPIStrip } from "@/components/prism/KPIStrip"; +import { RatiosPage } from "@/components/prism/RatiosPage"; import { TickerHeader } from "@/components/prism/TickerHeader"; import type { FinancialsResponse, TickerOverview } from "@/types/api"; -type StatementKey = "income" | "balance" | "cash_flow"; +type StatementKey = "income" | "balance" | "cash_flow" | "ratios"; +type FinancialStatementKey = Exclude; type PeriodKey = "annual" | "quarterly"; type FinState = "loading" | "ready" | "error"; @@ -18,6 +20,13 @@ type Props = { onToggleWatchlist: () => void; }; +const STATEMENT_LABELS: Record = { + income: "INCOME", + balance: "BALANCE", + cash_flow: "CASH FLOW", + ratios: "RATIOS", +}; + export function FinancialsPage({ ticker, overview, isSaved, onToggleWatchlist }: Props) { const [statement, setStatement] = useState("income"); const [period, setPeriod] = useState("annual"); @@ -26,6 +35,10 @@ export function FinancialsPage({ ticker, overview, isSaved, onToggleWatchlist }: const kpis = buildKpis(overview); useEffect(() => { + if (statement === "ratios") { + return; + } + let cancelled = false; setFinState("loading"); setData(null); @@ -45,28 +58,47 @@ export function FinancialsPage({ ticker, overview, isSaved, onToggleWatchlist }: return () => { cancelled = true; }; - }, [ticker, period]); + }, [ticker, period, statement]); return ( <> - {finState === "loading" && ( -
- )} - {finState === "error" && ( -
-

Financial statements unavailable for {ticker}.

-
- )} - {finState === "ready" && data && ( - +
+
+ {(["income", "balance", "cash_flow", "ratios"] as StatementKey[]).map((key) => ( + + ))} +
+
+ {statement === "ratios" ? ( + + ) : ( + <> + {finState === "loading" && ( +
+ )} + {finState === "error" && ( +
+

Financial statements unavailable for {ticker}.

+
+ )} + {finState === "ready" && data && ( + + )} + )} ); -- cgit v1.3-2-g0d8e