UNPKG

@tmlmobilidade/emails

Version:
34 lines (33 loc) 1.83 kB
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime"; /* * */ import { Paragraph } from '../components/Paragraph/index.js'; import { Span } from '../components/Span/index.js'; import { Wrapper } from '../components/Wrapper/index.js'; import { emailProvider } from '../email.provider.js'; import { Dates } from '@tmlmobilidade/dates'; import { render } from 'react-email'; /* * */ export const failedBackupSubject = '🚨 Erro de Sistema'; /* * */ export default function SystemErrorTemplate({ errorMessage, serviceName, timestamp }) { return (_jsxs(Wrapper, { previewMessage: "Por favor verifica o que se passou.", children: [_jsx(Paragraph, { bold: true, color: "danger", children: "Ocorreu um erro de sistema." }), _jsxs(Paragraph, { bold: true, size: "md", children: ["Servi\u00E7o:", _jsx(Span, { spaceBefore: true, weight: "normal", children: serviceName })] }), _jsxs(Paragraph, { bold: true, size: "md", children: ["Mensagem:", _jsx(Span, { spaceBefore: true, weight: "normal", children: errorMessage ?? 'N/A' })] }), _jsxs(Paragraph, { bold: true, size: "md", children: ["Timestamp:", _jsx(Span, { spaceBefore: true, weight: "normal", children: Dates.fromUnixTimestamp(timestamp).toLocaleString(Dates.FORMATS.DATETIME_FULL_WITH_SECONDS) })] })] })); } ; /* * */ SystemErrorTemplate.PreviewProps = { errorMessage: 'Conexão com a base de dados falhou após 3 tentativas', serviceName: 'MongoDB - Produção', timestamp: 1772279176000, }; /* * */ export const renderSystemErrorTemplate = async (props) => { return await render(_jsx(SystemErrorTemplate, { ...props })); }; /* * */ export const sendSystemErrorEmail = async ({ data, to }) => { await emailProvider.send({ html: await renderSystemErrorTemplate(data), subject: failedBackupSubject, to: to, }); };