34 lines
1.3 KiB
TypeScript
34 lines
1.3 KiB
TypeScript
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;
|
|
}
|