feat(web): add dashboard API client and hooks
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
30
apps/web/lib/hooks/use-dashboard.ts
Normal file
30
apps/web/lib/hooks/use-dashboard.ts
Normal file
@@ -0,0 +1,30 @@
|
||||
import { useQuery } from '@tanstack/react-query';
|
||||
import * as dashboardApi from '@/lib/api/dashboard';
|
||||
|
||||
export function useKpis(año?: number, mes?: number) {
|
||||
return useQuery({
|
||||
queryKey: ['kpis', año, mes],
|
||||
queryFn: () => dashboardApi.getKpis(año, mes),
|
||||
});
|
||||
}
|
||||
|
||||
export function useIngresosEgresos(año?: number) {
|
||||
return useQuery({
|
||||
queryKey: ['ingresos-egresos', año],
|
||||
queryFn: () => dashboardApi.getIngresosEgresos(año),
|
||||
});
|
||||
}
|
||||
|
||||
export function useResumenFiscal(año?: number, mes?: number) {
|
||||
return useQuery({
|
||||
queryKey: ['resumen-fiscal', año, mes],
|
||||
queryFn: () => dashboardApi.getResumenFiscal(año, mes),
|
||||
});
|
||||
}
|
||||
|
||||
export function useAlertas(limit = 5) {
|
||||
return useQuery({
|
||||
queryKey: ['alertas', limit],
|
||||
queryFn: () => dashboardApi.getAlertas(limit),
|
||||
});
|
||||
}
|
||||
Reference in New Issue
Block a user