diff --git a/app/executive-overview/page.tsx b/app/executive-overview/page.tsx index 20c22a8..194f1f7 100644 --- a/app/executive-overview/page.tsx +++ b/app/executive-overview/page.tsx @@ -5,6 +5,8 @@ import Link from "next/link"; import { AreaChart, Area, + BarChart, + Bar, XAxis, YAxis, Tooltip, @@ -16,6 +18,7 @@ import { useTheme } from "@/components/layout/ThemeContext"; import { apiFetch } from "@/lib/api"; import type { ExecutiveOverviewResponse, TopicClustersResponse, TopicCluster } from "@/lib/types/executive-overview"; import type { ClaimListResponse, ClaimItem } from "@/lib/types/claim"; +import type { SentimentShiftResponse } from "@/lib/types/sentiment"; type TopicTrend = Record; @@ -50,10 +53,6 @@ function formatClaimStatus(status: string) { return status.replace(/_/g, " "); } -function isVerifiedClaimStatus(status: string) { - const normalized = status.trim().toLowerCase(); - return normalized === "verified" || normalized === "verified_true"; -} type MetricKey = | "total_videos_scoped" @@ -235,10 +234,11 @@ function BubbleChart({ clusters }: { clusters: TopicCluster[] }) { } export default function ExecutiveOverviewPage() { + const { isDark } = useTheme(); const [data, setData] = useState(null); const [clusters, setClusters] = useState([]); const [claims, setClaims] = useState([]); - const [allClaims, setAllClaims] = useState([]); + const [sentiment, setSentiment] = useState(null); const [error, setError] = useState(null); const [claimStatusFilter, setClaimStatusFilter] = useState<"all" | "verified" | "unverifiable">("all"); const [claimsLoading, setClaimsLoading] = useState(true); @@ -247,12 +247,12 @@ export default function ExecutiveOverviewPage() { Promise.all([ apiFetch("/overview/executive"), apiFetch("/overview/topic-clusters"), - apiFetch("/claims"), + apiFetch("/overview/sentiment-shift", { range: "30d" }), ]) - .then(([execData, clusterData, allClaimData]) => { + .then(([execData, clusterData, sentimentData]) => { setData(execData); setClusters(clusterData.clusters); - setAllClaims(allClaimData.data); + setSentiment(sentimentData); }) .catch((err) => setError(err instanceof Error ? err.message : String(err))); }, []); @@ -276,8 +276,6 @@ export default function ExecutiveOverviewPage() { if (error) return
Failed to load: {error}
; if (!data) return
Loading...
; - const verifiedClaimsCount = allClaims.filter((claim) => isVerifiedClaimStatus(claim.status)).length; - const meta = data.overview_metrics_meta; const overviewMetrics: OverviewMetricCard[] = [ { @@ -297,7 +295,7 @@ export default function ExecutiveOverviewPage() { { key: "verified_claims", title: "Verified Claims", - value: verifiedClaimsCount, + value: data.verified_claims, subLabel: `${meta.verified_claims.accuracy_pct}% ${meta.verified_claims.accuracy_label}`, icon: "claims", }, @@ -456,12 +454,56 @@ export default function ExecutiveOverviewPage() { -
+

Sentiment Analysis

-

Health domain overview

-
-

Sentiment analysis endpoint coming soon.

-

See docs/MISSING_APIS.md for details.

+

Last 30 days · health domain

+ {sentiment && ( +
+ + + {sentiment.totals.positive} positive + + + + {sentiment.totals.neutral} neutral + + + + {sentiment.totals.negative} negative + +
+ )} +
+ {!sentiment ? ( +
+ Loading… +
+ ) : sentiment.buckets.length === 0 ? ( +
+ No sentiment data available. +
+ ) : ( + + + + + + + + + + + + + )}
diff --git a/app/trend-analytics/page.tsx b/app/trend-analytics/page.tsx index 3c41e06..d5a7799 100644 --- a/app/trend-analytics/page.tsx +++ b/app/trend-analytics/page.tsx @@ -41,7 +41,6 @@ export default function TrendAnalyticsPage() { const [error, setError] = useState(null); const [range, setRange] = useState("6m"); const [sentimentData, setSentimentData] = useState(null); - const [sentimentLoading, setSentimentLoading] = useState(false); useEffect(() => { Promise.all([ @@ -57,11 +56,9 @@ export default function TrendAnalyticsPage() { }, []); useEffect(() => { - setSentimentLoading(true); apiFetch("/overview/sentiment-shift", { range }) .then((data) => setSentimentData(data)) - .catch(() => setSentimentData(null)) - .finally(() => setSentimentLoading(false)); + .catch(() => setSentimentData(null)); }, [range]); const filteredTrends = useMemo(() => { @@ -178,11 +175,11 @@ export default function TrendAnalyticsPage() {
)}
- {sentimentLoading ? ( + {!sentimentData ? (
Loading…
- ) : sentimentData && sentimentData.buckets.length > 0 ? ( + ) : sentimentData.buckets.length > 0 ? (