feat(drill): PayerPeekContent + usePayerSummary + api.getPayerSummary

This commit is contained in:
Tyler
2026-06-21 13:05:38 -06:00
parent e6ae364dad
commit 50dc0b2fb3
4 changed files with 256 additions and 0 deletions
+24
View File
@@ -0,0 +1,24 @@
import { useQuery } from "@tanstack/react-query";
import { api, type PayerSummary } from "@/lib/api";
/**
* Fetch the aggregate payer stats shown in the payer peek modal
* (SP21 universal drill-down).
*
* Caches for 60s — the backend caches the same way, so re-asks inside
* that window are free. `retry: 1` because peek content is a low-stakes
* summary; one retry on transient failure is enough before falling back
* to the error UI.
*
* When `payerId` is `null` (the peek isn't open), the query is disabled
* and the hook returns the idle React-Query state — no fetch.
*/
export function usePayerSummary(payerId: string | null) {
return useQuery<PayerSummary>({
queryKey: ["payer-summary", payerId],
queryFn: () => api.getPayerSummary(payerId as string),
enabled: payerId !== null,
staleTime: 60 * 1000,
retry: 1,
});
}