feature/implementacion de SSE
This commit is contained in:
@@ -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();
|
||||
}
|
||||
Reference in New Issue
Block a user