diff --git a/src/pages/Dashboard.tsx b/src/pages/Dashboard.tsx index 1d6e9da..255f8be 100644 --- a/src/pages/Dashboard.tsx +++ b/src/pages/Dashboard.tsx @@ -17,13 +17,16 @@ import { AnimatedNumber } from "@/components/AnimatedNumber"; import { DrillableCell } from "@/components/drill/DrillableCell"; import { fmt } from "@/lib/format"; import { eventKindToUrl } from "@/lib/event-routing"; -import { useAppStore } from "@/store"; import { useAuth } from "@/auth/useAuth"; +import { useClaims } from "@/hooks/useClaims"; +import { useProviders } from "@/hooks/useProviders"; +import { useActivity } from "@/hooks/useActivity"; +import type { Claim } from "@/types"; import { toast } from "sonner"; const MONTHS_BACK = 6; -function buildMonthly(claims: ReturnType["claims"]) { +function buildMonthly(claims: Claim[]) { const now = new Date(); const months: { key: string; @@ -71,9 +74,16 @@ function buildMonthly(claims: ReturnType["claims"]) } export function Dashboard() { - const claims = useAppStore((s) => s.claims); - const providers = useAppStore((s) => s.providers); - const activity = useAppStore((s) => s.activity); + // Live data: hooks fetch from /api/* when api.isConfigured; otherwise + // they fall back to the in-memory store. Pulling from the hooks (not + // the store directly) is what wires the Dashboard to the backend. + const claimsQuery = useClaims({ limit: 100 }); + const providersQuery = useProviders(); + const activityQuery = useActivity({ limit: 10 }); + + const claims = claimsQuery.data?.items ?? []; + const providers = providersQuery.data?.items ?? []; + const activity = activityQuery.data?.items ?? []; const navigate = useNavigate(); // Time-of-day greeting + live operator name from the auth context.