feature/implementacion de SSE

This commit is contained in:
2026-05-28 07:15:26 -06:00
parent d45623c99a
commit cbbd34a91c
8 changed files with 1416 additions and 76 deletions

View File

@@ -15,11 +15,18 @@ export interface TipoNotificacion {
descripcion: string;
}
export interface NotificacionDatos {
task_id: string;
label: string;
resultado: Record<string, unknown>;
}
export interface Notificacion {
id: number;
tipo: TipoNotificacion;
dirigido: string;
mensaje: string;
datos: NotificacionDatos | null;
fecha_envio: string;
created_at: string;
visto: boolean;
@@ -47,4 +54,12 @@ export async function fetchAllNotifications({page = 1, page_size=10}): Promise<N
const res = await fetchWithAuth(url);
if (!res.ok) throw new Error('Error al obtener notificaciones');
return await res.json();
}
export async function fetchNotificacionByTaskId(taskId: string): Promise<Notificacion | null> {
const url = `${API_URL}/notificaciones/notificaciones/by-task/${taskId}/`;
const res = await fetchWithAuth(url);
if (res.status === 404) return null;
if (!res.ok) throw new Error('Error al obtener notificación por task_id');
return await res.json();
}