Files
condado-newsletter/frontend/src/api/logsApi.ts

29 lines
889 B
TypeScript

import apiClient from './apiClient'
export type DispatchStatus = 'PENDING' | 'SENT' | 'FAILED'
export interface DispatchLogResponse {
id: string
entityId: string
entityName: string
promptSent: string
aiResponse: string
emailSubject: string
emailBody: string
status: DispatchStatus
errorMessage: string | null
dispatchedAt: string
}
/** GET /api/v1/dispatch-logs — list all dispatch logs. */
export async function getLogs(): Promise<DispatchLogResponse[]> {
const response = await apiClient.get<DispatchLogResponse[]>('/v1/dispatch-logs')
return response.data
}
/** GET /api/v1/dispatch-logs/entity/:id — list logs for a specific entity. */
export async function getLogsByEntity(entityId: string): Promise<DispatchLogResponse[]> {
const response = await apiClient.get<DispatchLogResponse[]>(`/v1/dispatch-logs/entity/${entityId}`)
return response.data
}