import { apiClient } from './client'; import type { AlertaFull, AlertaCreate, AlertaUpdate, AlertasStats } from '@horux/shared'; export async function getAlertas(filters?: { leida?: boolean; resuelta?: boolean }): Promise { 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(`/alertas?${params}`); return response.data; } export async function getStats(): Promise { const response = await apiClient.get('/alertas/stats'); return response.data; } export async function createAlerta(data: AlertaCreate): Promise { const response = await apiClient.post('/alertas', data); return response.data; } export async function updateAlerta(id: number, data: AlertaUpdate): Promise { const response = await apiClient.patch(`/alertas/${id}`, data); return response.data; } export async function deleteAlerta(id: number): Promise { await apiClient.delete(`/alertas/${id}`); } export async function markAllAsRead(): Promise { await apiClient.post('/alertas/mark-all-read'); }