feat(alertas): add alerts CRUD with stats and management UI

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
Consultoria AS
2026-01-22 03:00:14 +00:00
parent 6d59c8d842
commit 9b8aaea7eb
31 changed files with 4892 additions and 0 deletions

View File

@@ -0,0 +1,33 @@
import { apiClient } from './client';
import type { AlertaFull, AlertaCreate, AlertaUpdate, AlertasStats } from '@horux/shared';
export async function getAlertas(filters?: { leida?: boolean; resuelta?: boolean }): Promise<AlertaFull[]> {
const params = new URLSearchParams();
if (filters?.leida !== undefined) params.set('leida', String(filters.leida));
if (filters?.resuelta !== undefined) params.set('resuelta', String(filters.resuelta));
const response = await apiClient.get<AlertaFull[]>(`/alertas?${params}`);
return response.data;
}
export async function getStats(): Promise<AlertasStats> {
const response = await apiClient.get<AlertasStats>('/alertas/stats');
return response.data;
}
export async function createAlerta(data: AlertaCreate): Promise<AlertaFull> {
const response = await apiClient.post<AlertaFull>('/alertas', data);
return response.data;
}
export async function updateAlerta(id: number, data: AlertaUpdate): Promise<AlertaFull> {
const response = await apiClient.patch<AlertaFull>(`/alertas/${id}`, data);
return response.data;
}
export async function deleteAlerta(id: number): Promise<void> {
await apiClient.delete(`/alertas/${id}`);
}
export async function markAllAsRead(): Promise<void> {
await apiClient.post('/alertas/mark-all-read');
}

View File

@@ -0,0 +1,28 @@
import { apiClient } from './client';
import type { EventoFiscal, EventoCreate, EventoUpdate } from '@horux/shared';
export async function getEventos(año: number, mes?: number): Promise<EventoFiscal[]> {
const params = new URLSearchParams({ año: año.toString() });
if (mes) params.set('mes', mes.toString());
const response = await apiClient.get<EventoFiscal[]>(`/calendario?${params}`);
return response.data;
}
export async function getProximos(dias = 30): Promise<EventoFiscal[]> {
const response = await apiClient.get<EventoFiscal[]>(`/calendario/proximos?dias=${dias}`);
return response.data;
}
export async function createEvento(data: EventoCreate): Promise<EventoFiscal> {
const response = await apiClient.post<EventoFiscal>('/calendario', data);
return response.data;
}
export async function updateEvento(id: number, data: EventoUpdate): Promise<EventoFiscal> {
const response = await apiClient.patch<EventoFiscal>(`/calendario/${id}`, data);
return response.data;
}
export async function deleteEvento(id: number): Promise<void> {
await apiClient.delete(`/calendario/${id}`);
}

View File

@@ -0,0 +1,36 @@
import { apiClient } from './client';
import type { EstadoResultados, FlujoEfectivo, ComparativoPeriodos, ConcentradoRfc } from '@horux/shared';
export async function getEstadoResultados(fechaInicio?: string, fechaFin?: string): Promise<EstadoResultados> {
const params = new URLSearchParams();
if (fechaInicio) params.set('fechaInicio', fechaInicio);
if (fechaFin) params.set('fechaFin', fechaFin);
const response = await apiClient.get<EstadoResultados>(`/reportes/estado-resultados?${params}`);
return response.data;
}
export async function getFlujoEfectivo(fechaInicio?: string, fechaFin?: string): Promise<FlujoEfectivo> {
const params = new URLSearchParams();
if (fechaInicio) params.set('fechaInicio', fechaInicio);
if (fechaFin) params.set('fechaFin', fechaFin);
const response = await apiClient.get<FlujoEfectivo>(`/reportes/flujo-efectivo?${params}`);
return response.data;
}
export async function getComparativo(año?: number): Promise<ComparativoPeriodos> {
const params = año ? `?año=${año}` : '';
const response = await apiClient.get<ComparativoPeriodos>(`/reportes/comparativo${params}`);
return response.data;
}
export async function getConcentradoRfc(
tipo: 'cliente' | 'proveedor',
fechaInicio?: string,
fechaFin?: string
): Promise<ConcentradoRfc[]> {
const params = new URLSearchParams({ tipo });
if (fechaInicio) params.set('fechaInicio', fechaInicio);
if (fechaFin) params.set('fechaFin', fechaFin);
const response = await apiClient.get<ConcentradoRfc[]>(`/reportes/concentrado-rfc?${params}`);
return response.data;
}

View File

@@ -0,0 +1,21 @@
import { apiClient } from './client';
import type { UserListItem, UserInvite, UserUpdate } from '@horux/shared';
export async function getUsuarios(): Promise<UserListItem[]> {
const response = await apiClient.get<UserListItem[]>('/usuarios');
return response.data;
}
export async function inviteUsuario(data: UserInvite): Promise<UserListItem> {
const response = await apiClient.post<UserListItem>('/usuarios/invite', data);
return response.data;
}
export async function updateUsuario(id: string, data: UserUpdate): Promise<UserListItem> {
const response = await apiClient.patch<UserListItem>(`/usuarios/${id}`, data);
return response.data;
}
export async function deleteUsuario(id: string): Promise<void> {
await apiClient.delete(`/usuarios/${id}`);
}