feat(email): adota React Email em notificações e automações

This commit is contained in:
esdrasrenan 2025-12-13 13:11:41 -03:00
parent 58a1ed6b36
commit 4306b0504d
18 changed files with 940 additions and 337 deletions

View file

@ -14,7 +14,8 @@ import {
} from "./automationsEngine"
import { getTemplateByKey, normalizeFormTemplateKey } from "./ticketFormTemplates"
import { TICKET_FORM_CONFIG } from "./ticketForms.config"
import { buildBaseUrl, renderAutomationEmail, type EmailTicketSummary } from "./emailTemplates"
import { renderAutomationEmailHtml, type AutomationEmailProps } from "./reactEmail"
import { buildBaseUrl } from "./url"
type AutomationEmailTarget = "AUTO" | "PORTAL" | "STAFF"
@ -932,7 +933,7 @@ async function applyActions(
const to = Array.from(recipientEmails).slice(0, 50)
if (to.length === 0) continue
const ticketSummary: EmailTicketSummary = {
const ticketSummary: AutomationEmailProps["ticket"] = {
reference: nextTicket.reference ?? 0,
subject: nextTicket.subject ?? "",
status: nextTicket.status ?? null,
@ -942,13 +943,14 @@ async function applyActions(
assigneeName: ((nextTicket.assigneeSnapshot as { name?: string } | undefined)?.name as string | undefined) ?? null,
}
const html = renderAutomationEmail({
const emailProps: AutomationEmailProps = {
title: subject,
message,
ticket: ticketSummary,
ctaLabel,
ctaUrl,
})
}
const html = await renderAutomationEmailHtml(emailProps)
await schedulerRunAfter(1, api.ticketNotifications.sendAutomationEmail, {
to,