feat(web): add dashboard API client and hooks
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
33
apps/web/lib/api/dashboard.ts
Normal file
33
apps/web/lib/api/dashboard.ts
Normal file
@@ -0,0 +1,33 @@
|
||||
import { apiClient } from './client';
|
||||
import type { KpiData, IngresosEgresosData, ResumenFiscal, Alerta } from '@horux/shared';
|
||||
|
||||
export async function getKpis(año?: number, mes?: number): Promise<KpiData> {
|
||||
const params = new URLSearchParams();
|
||||
if (año) params.set('año', año.toString());
|
||||
if (mes) params.set('mes', mes.toString());
|
||||
|
||||
const response = await apiClient.get<KpiData>(`/dashboard/kpis?${params}`);
|
||||
return response.data;
|
||||
}
|
||||
|
||||
export async function getIngresosEgresos(año?: number): Promise<IngresosEgresosData[]> {
|
||||
const params = new URLSearchParams();
|
||||
if (año) params.set('año', año.toString());
|
||||
|
||||
const response = await apiClient.get<IngresosEgresosData[]>(`/dashboard/ingresos-egresos?${params}`);
|
||||
return response.data;
|
||||
}
|
||||
|
||||
export async function getResumenFiscal(año?: number, mes?: number): Promise<ResumenFiscal> {
|
||||
const params = new URLSearchParams();
|
||||
if (año) params.set('año', año.toString());
|
||||
if (mes) params.set('mes', mes.toString());
|
||||
|
||||
const response = await apiClient.get<ResumenFiscal>(`/dashboard/resumen-fiscal?${params}`);
|
||||
return response.data;
|
||||
}
|
||||
|
||||
export async function getAlertas(limit = 5): Promise<Alerta[]> {
|
||||
const response = await apiClient.get<Alerta[]>(`/dashboard/alertas?limit=${limit}`);
|
||||
return response.data;
|
||||
}
|
||||
Reference in New Issue
Block a user