import { apiClient } from '@/lib/api/client'; import { buildQuery, type PaginatedResult } from '@/lib/api/types'; import type { CanalTemplate, TipoTemplate } from '@/lib/api/alert-templates'; export const ALERT_LOG_STATUSES = ['enviado', 'falhou', 'entregue', 'lido'] as const; export type AlertLogStatus = (typeof ALERT_LOG_STATUSES)[number]; /** Espelha o model `alert_logs` + `include: { template: { tipo } }`. */ export interface AlertLog { id: string; tenant_id: string | null; destinatario_tipo: string; destinatario_id: string; canal: CanalTemplate; template_id: string | null; conteudo_enviado: string | null; status: AlertLogStatus; erro: string | null; enviado_em: string; template: { tipo: TipoTemplate } | null; } export interface ListAlertLogsParams { canal?: CanalTemplate; status?: AlertLogStatus; data_inicio?: string; data_fim?: string; tenant_id?: string; page?: number; limit?: number; } export function listAlertLogs(params: ListAlertLogsParams) { return apiClient.get>(`/master/alertas/logs${buildQuery(params)}`); }