dak.c2s/frontend/src/hooks/useDashboard.ts
CCS Admin 42fd1808c4 feat: add admin-only billing status donut and top gutachter charts to Dashboard
Extends DashboardKPIs with total_abgerechnet/pending_abrechnung. Adds
new GET /reports/dashboard/top-gutachter endpoint (admin-only). Frontend
shows Abrechnungsstatus donut + Gutachter-Verteilung progress bars in a
new third row, visible only to admins.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-28 15:55:30 +00:00

40 lines
1.4 KiB
TypeScript

import { useQuery } from '@tanstack/react-query'
import api from '@/services/api'
import type { DashboardResponse, YearlyComparisonResponse, TopIcdResponse, TopGutachterResponse, GutachtenStatistikResponse } from '@/types'
export function useDashboard(jahr: number) {
return useQuery({
queryKey: ['dashboard', jahr],
queryFn: () => api.get<DashboardResponse>('/reports/dashboard', { params: { jahr } }).then(r => r.data),
})
}
export function useYearlyComparison() {
return useQuery({
queryKey: ['dashboard', 'yearly-comparison'],
queryFn: () => api.get<YearlyComparisonResponse>('/reports/dashboard/yearly-comparison').then(r => r.data),
staleTime: 60_000,
})
}
export function useTopIcd(jahr: number) {
return useQuery({
queryKey: ['dashboard', 'top-icd', jahr],
queryFn: () => api.get<TopIcdResponse>('/reports/dashboard/top-icd', { params: { jahr } }).then(r => r.data),
})
}
export function useTopGutachter(jahr: number, enabled = true) {
return useQuery({
queryKey: ['dashboard', 'top-gutachter', jahr],
queryFn: () => api.get<TopGutachterResponse>('/reports/dashboard/top-gutachter', { params: { jahr } }).then(r => r.data),
enabled,
})
}
export function useGutachtenStatistik(jahr: number) {
return useQuery({
queryKey: ['gutachten-statistik', jahr],
queryFn: () => api.get<GutachtenStatistikResponse>('/reports/gutachten-statistik', { params: { jahr } }).then(r => r.data),
})
}