feat: página de plantillas de correo + prueba de envío + bitácora

This commit is contained in:
Nurfog committed 2026-09-10 15:51:03 -03:00
1 parent a68999eca7
commit ce008105c9
3 files changed
+402

No files matched your search

+45
View File
@@ -338,3 +338,48 @@ export async function updateSla(
body: JSON.stringify(data),
});
}
// ==================== Correo / plantillas ====================
export interface EmailTemplate {
key: string;
name: string;
subject: string;
bodyHtml: string;
isActive: boolean;
}
export interface EmailLogEntry {
id: number;
template: string;
ticketId?: number;
recipient: string;
subject: string;
status: string;
error?: string;
createdAt: string;
}
export async function getEmailTemplates() {
return fetchApi<EmailTemplate[]>("/api/helpdesk/email/templates");
}
export async function updateEmailTemplate(
key: string,
data: { subject?: string; bodyHtml?: string; isActive?: boolean }
) {
return fetchApi<void>(`/api/helpdesk/email/templates/${encodeURIComponent(key)}`, {
method: "PUT",
body: JSON.stringify(data),
});
}
export async function getEmailLog(limit = 50) {
return fetchApi<EmailLogEntry[]>(`/api/helpdesk/email/log?limit=${limit}`);
}
export async function sendTestEmail(to: string) {
return fetchApi<{ success: boolean; message?: string }>("/api/helpdesk/email/test", {
method: "POST",
body: JSON.stringify({ to }),
});
}