From 3ca117ed7f811e695861a03f25afad5aea790829 Mon Sep 17 00:00:00 2001
From: Tyler Hoang <tyler@tylerhoang.xyz>
Date: Mon, 18 May 2026 01:35:43 -0700
Subject: feat: add ValuationPage data-fetch wrapper

---
 frontend/components/prism/ValuationPage.tsx | 61 +++++++++++++++++++++++++++++
 1 file changed, 61 insertions(+)
 create mode 100644 frontend/components/prism/ValuationPage.tsx

(limited to 'frontend/components/prism/ValuationPage.tsx')

diff --git a/frontend/components/prism/ValuationPage.tsx b/frontend/components/prism/ValuationPage.tsx
new file mode 100644
index 0000000..3a3ba27
--- /dev/null
+++ b/frontend/components/prism/ValuationPage.tsx
@@ -0,0 +1,61 @@
+"use client";
+import { useEffect, useState } from "react";
+import { api } from "@/lib/api";
+import { buildKpis } from "@/lib/overview";
+import { ValuationCard } from "@/components/prism/ValuationCard";
+import { KPIStrip } from "@/components/prism/KPIStrip";
+import { TickerHeader } from "@/components/prism/TickerHeader";
+import type { TickerOverview, ValuationResponse } from "@/types/api";
+
+type ValState = "loading" | "ready" | "error";
+
+type Props = {
+  ticker: string;
+  overview: TickerOverview;
+  isSaved: boolean;
+  onToggleWatchlist: () => void;
+};
+
+export function ValuationPage({ ticker, overview, isSaved, onToggleWatchlist }: Props) {
+  const [data, setData] = useState<ValuationResponse | null>(null);
+  const [valState, setValState] = useState<ValState>("loading");
+  const kpis = buildKpis(overview);
+
+  useEffect(() => {
+    let cancelled = false;
+    setValState("loading");
+    setData(null);
+
+    api
+      .valuation(ticker)
+      .then((res) => {
+        if (!cancelled) {
+          setData(res);
+          setValState("ready");
+        }
+      })
+      .catch(() => {
+        if (!cancelled) setValState("error");
+      });
+
+    return () => {
+      cancelled = true;
+    };
+  }, [ticker]);
+
+  return (
+    <>
+      <TickerHeader overview={overview} isSaved={isSaved} onToggleWatchlist={onToggleWatchlist} />
+      <KPIStrip items={kpis} />
+      {valState === "loading" && (
+        <section className="psm-card psm-skeleton" style={{ minHeight: 320 }} />
+      )}
+      {valState === "error" && (
+        <section className="psm-card">
+          <p className="psm-muted-copy">Valuation data unavailable for {ticker}.</p>
+        </section>
+      )}
+      {valState === "ready" && data && <ValuationCard data={data} />}
+    </>
+  );
+}
-- 
cgit v1.3-2-g0d8e

