UNPKG

@tmlmobilidade/emails

Version:
36 lines (35 loc) 1.56 kB
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime"; /* * */ import { DebugCode } from '../components/DebugCode/index.js'; import { MainButton } from '../components/MainButton/index.js'; import { Paragraph } from '../components/Paragraph/index.js'; import { Wrapper } from '../components/Wrapper/index.js'; import { emailProvider } from '../email.provider.js'; import { render } from 'react-email'; /* * */ export const genericNotificationSubject = 'Nova Notificação'; /* * */ export default function GenericNotificationTemplate({ body, notificationId, notificationUrl, title }) { return (_jsxs(Wrapper, { previewMessage: "Nova notifica\u00E7\u00E3o", children: [_jsx(Paragraph, { bold: true, children: title }), _jsx(Paragraph, { children: body }), _jsx(MainButton, { href: notificationUrl, label: "Ver Notifica\u00E7\u00E3o" }), _jsx(DebugCode, { label: "Notification ID", value: notificationId })] })); // } ; /* * */ GenericNotificationTemplate.PreviewProps = { body: 'Foi publicado um novo alerta para a linha 1234.', notificationId: 'I81NT1', notificationUrl: 'https://www.tmlmobilidade.pt', title: 'Alerta de Trânsito', }; /* * */ export const renderGenericNotificationTemplate = async (props) => { return await render(_jsx(GenericNotificationTemplate, { ...props })); }; /* * */ export const sendGenericNotificationEmail = async ({ data, to }) => { await emailProvider.send({ html: await renderGenericNotificationTemplate(data), subject: genericNotificationSubject, to: to, }); };