@tmlmobilidade/emails
Version:
39 lines (38 loc) • 3.41 kB
JavaScript
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
/* * */
import { Anchor } from '../components/Anchor/index.js';
import { DebugCode } from '../components/DebugCode/index.js';
import { Greeting } from '../components/Greeting/index.js';
import { MainButton } from '../components/MainButton/index.js';
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 { render } from 'react-email';
/* * */
export const unsuccessfulGtfsValidationSubject = 'Validação GTFS com erros';
/* * */
export default function UnsuccessfulGtfsValidationTemplate({ firstName, gtfsValidationId, gtfsValidationUrl, totalErrors = 0, totalWarnings = 0 }) {
return (_jsxs(Wrapper, { previewMessage: "O GTFS que enviaste cont\u00E9m erros.", children: [_jsx(Greeting, { text: `${firstName},` }), totalErrors === 1 && (_jsxs(Paragraph, { children: ["Foi encontrado", _jsxs(Span, { color: "danger", spaceAfter: true, spaceBefore: true, weight: "bold", children: [totalErrors, ' ', "erro"] }), "no GTFS que enviaste para valida\u00E7\u00E3o."] })), totalErrors > 1 && (_jsxs(Paragraph, { children: ["Foram encontrados", _jsxs(Span, { color: "danger", spaceAfter: true, spaceBefore: true, weight: "bold", children: [totalErrors, ' ', "erros"] }), "no GTFS que enviaste para valida\u00E7\u00E3o."] })), totalWarnings === 1 && (_jsxs(Paragraph, { children: ["Tamb\u00E9m foi encontrado", _jsxs(Span, { color: "warning", spaceAfter: true, spaceBefore: true, weight: "bold", children: [totalWarnings, ' ', "aviso"] }), "que deve ser corrigido o mais breve poss\u00EDvel, pois pode passar a ser considerado erro formal no futuro."] })), totalWarnings > 1 && (_jsxs(Paragraph, { children: ["Tamb\u00E9m foram encontrados", _jsxs(Span, { color: "warning", spaceAfter: true, spaceBefore: true, weight: "bold", children: [totalWarnings, ' ', "avisos"] }), "que devem ser corrigidos o mais breve poss\u00EDvel, pois podem passar a ser considerados erros formais no futuro."] })), _jsxs(Paragraph, { children: ["Se tiveres d\u00FAvidas sobre alguma regra", _jsx(Anchor, { href: "https://go.tmlmobilidade.pt/reference", spaceAfter: true, spaceBefore: true, text: "explora a documenta\u00E7\u00E3o" }), "ou entra em contacto connosco."] }), _jsx(Paragraph, { bold: true, size: "md", children: "Erros formais impedem a publica\u00E7\u00E3o do GTFS e devem ser corrigidos para prosseguir com a aprova\u00E7\u00E3o." }), _jsx(MainButton, { href: gtfsValidationUrl, label: "Ver resumo da valida\u00E7\u00E3o" }), _jsx(DebugCode, { label: "GTFS Validation ID", value: gtfsValidationId })] }));
}
;
/* * */
UnsuccessfulGtfsValidationTemplate.PreviewProps = {
firstName: 'Josué',
gtfsValidationId: 'TUH16N',
gtfsValidationUrl: 'https://go.tmlmobilidade.pt/gtfs-validations/TUH16N',
totalErrors: 2,
totalWarnings: 2,
};
/* * */
export const renderUnsuccessfulGtfsValidationTemplate = async (props) => {
return await render(_jsx(UnsuccessfulGtfsValidationTemplate, { ...props }));
};
/* * */
export const sendUnsuccessfulGtfsValidationEmail = async ({ data, to }) => {
await emailProvider.send({
html: await renderUnsuccessfulGtfsValidationTemplate(data),
subject: unsuccessfulGtfsValidationSubject,
to: to,
});
};