/** * Source-of-truth: ticket-comment-added email template. * * Uses the shared email layout wrapper. Body content is built from * per-language translated strings so that only text differs between locales. */ const { wrapEmailLayout } = require('../../_shared/emailLayout.cjs'); const { BADGE_BG, BRAND_DARK, BRAND_PRIMARY, COMMENT_BOX_BG, COMMENT_BOX_BORDER, COMMENT_LABEL_COLOR, } = require('../../_shared/constants.cjs'); const TEMPLATE_NAME = 'ticket-comment-added'; const SUBTYPE_NAME = 'Ticket Comment Added'; const SUBJECTS = { en: 'New Comment • {{ticket.title}}', fr: 'Nouveau Commentaire • {{ticket.title}}', es: 'Nuevo Comentario • {{ticket.title}}', de: 'Neuer Kommentar • {{ticket.title}}', nl: 'Nieuwe Opmerking • {{ticket.title}}', it: 'Nuovo commento • {{ticket.title}}', pl: 'Nowy komentarz • {{ticket.title}}', }; /* eslint-disable max-len */ const COPY = { en: { headerLabel: 'New Comment Added', intro: 'A new comment has been added to a ticket for {{ticket.clientName}}.', badgePrefix: 'Ticket #', priority: 'Priority', status: 'Status', commentBy: 'Comment By', commentByVar: '{{comment.author}}', assignedTo: 'Assigned To', requester: 'Requester', board: 'Board', category: 'Category', location: 'Location', commentLabel: '💬 Comment', commentVar: '{{{comment.content}}}', viewButton: 'View Ticket', footer: 'Powered by Alga PSA · Keeping teams aligned', textHeader: 'New Comment Added', textCommentBy: 'Comment By', textAssigned: 'Assigned To', textRequester: 'Requester', textComment: 'Comment', textView: 'View ticket', }, fr: { headerLabel: 'Nouveau Commentaire Ajouté', intro: 'Un nouveau commentaire a été ajouté à un ticket pour {{ticket.clientName}}.', badgePrefix: 'Ticket #', priority: 'Priorité', status: 'Statut', commentBy: 'Commentaire de', commentByVar: '{{comment.author}}', assignedTo: 'Assigné à', requester: 'Demandeur', board: 'Tableau', category: 'Catégorie', location: 'Emplacement', commentLabel: '💬 Commentaire', commentVar: '{{comment.content}}', viewButton: 'Voir le Ticket', footer: 'Powered by Alga PSA · Gardons les équipes alignées', textHeader: 'Nouveau Commentaire Ajouté', textCommentBy: 'Commentaire de', textAssigned: 'Assigné à', textRequester: 'Demandeur', textComment: 'Commentaire', textView: 'Voir le ticket', }, es: { headerLabel: 'Nuevo Comentario Agregado', intro: 'Se ha agregado un nuevo comentario a un ticket para {{ticket.clientName}}.', badgePrefix: 'Ticket #', priority: 'Prioridad', status: 'Estado', commentBy: 'Comentario de', commentByVar: '{{comment.author}}', assignedTo: 'Asignado a', requester: 'Solicitante', board: 'Tablero', category: 'Categoría', location: 'Ubicación', commentLabel: '💬 Comentario', commentVar: '{{comment.content}}', viewButton: 'Ver Ticket', footer: 'Powered by Alga PSA · Manteniendo a los equipos alineados', textHeader: 'Nuevo Comentario Agregado', textCommentBy: 'Comentario de', textAssigned: 'Asignado a', textRequester: 'Solicitante', textComment: 'Comentario', textView: 'Ver ticket', }, de: { headerLabel: 'Neuer Kommentar Hinzugefügt', intro: 'Ein neuer Kommentar wurde zu einem Ticket für {{ticket.clientName}} hinzugefügt.', badgePrefix: 'Ticket #', priority: 'Priorität', status: 'Status', commentBy: 'Kommentar von', commentByVar: '{{comment.author}}', assignedTo: 'Zugewiesen an', requester: 'Anforderer', board: 'Board', category: 'Kategorie', location: 'Standort', commentLabel: '💬 Kommentar', commentVar: '{{comment.content}}', viewButton: 'Ticket Anzeigen', footer: 'Powered by Alga PSA · Teams auf Kurs halten', textHeader: 'Neuer Kommentar Hinzugefügt', textCommentBy: 'Kommentar von', textAssigned: 'Zugewiesen an', textRequester: 'Anforderer', textComment: 'Kommentar', textView: 'Ticket anzeigen', }, nl: { headerLabel: 'Nieuwe Opmerking Toegevoegd', intro: 'Een nieuwe opmerking is toegevoegd aan een ticket voor {{ticket.clientName}}.', badgePrefix: 'Ticket #', priority: 'Prioriteit', status: 'Status', commentBy: 'Opmerking van', commentByVar: '{{comment.author}}', assignedTo: 'Toegewezen aan', requester: 'Aanvrager', board: 'Bord', category: 'Categorie', location: 'Locatie', commentLabel: '💬 Opmerking', commentVar: '{{comment.content}}', viewButton: 'Ticket Bekijken', footer: 'Powered by Alga PSA · Teams op één lijn houden', textHeader: 'Nieuwe Opmerking Toegevoegd', textCommentBy: 'Opmerking van', textAssigned: 'Toegewezen aan', textRequester: 'Aanvrager', textComment: 'Opmerking', textView: 'Ticket bekijken', }, it: { headerLabel: 'Nuovo commento aggiunto', intro: 'È stato aggiunto un nuovo commento a un ticket per {{ticket.clientName}}.', badgePrefix: 'Ticket #', priority: 'Priorità', status: 'Stato', commentBy: 'Commento di', commentByVar: '{{comment.author}}', assignedTo: 'Assegnato a', requester: 'Richiedente', board: 'Board', category: 'Categoria', location: 'Sede', commentLabel: '💬 Commento', commentVar: '{{comment.content}}', viewButton: 'Apri ticket', footer: 'Powered by Alga PSA · Manteniamo i team allineati', textHeader: 'Nuovo commento aggiunto', textCommentBy: 'Commento di', textAssigned: 'Assegnato a', textRequester: 'Richiedente', textComment: 'Commento', textView: 'Apri ticket', }, pl: { headerLabel: 'Nowy komentarz', intro: '{{comment.authorName}} dodał(a) komentarz do zgłoszenia {{ticket.clientName}}.', badgePrefix: 'Zgłoszenie #', priority: 'Priorytet', status: 'Status', commentBy: null, /* PL omits the "Comment By" row; author is in intro */ commentByVar: null, assignedTo: null, /* PL omits Assigned To row */ requester: 'Zgłaszający', board: null, /* PL omits Board row */ category: null, /* PL omits Category row */ location: null, /* PL omits Location row */ commentLabel: 'Treść komentarza', commentVar: '{{comment.body}}', viewButton: 'Zobacz zgłoszenie', footer: 'Powered by Alga PSA', textHeader: 'Nowy komentarz', textCommentBy: null, textAssigned: null, textRequester: 'Zgłaszający', textComment: 'Komentarz', textView: 'Zobacz zgłoszenie', /* PL uses a simpler table layout */ isSimplified: true, }, }; /* eslint-enable max-len */ function buildBodyHtmlStandard(c) { return `

${c.intro}

${c.badgePrefix}{{ticket.id}}
${c.priority} {{ticket.priority}}
${c.status} {{ticket.status}}
${c.commentBy} ${c.commentByVar}
${c.assignedTo}
{{ticket.assignedToName}}
{{ticket.assignedToEmail}}
${c.requester}
{{ticket.requesterName}}
{{ticket.requesterContact}}
${c.board} {{ticket.board}}
${c.category} {{ticket.categoryDetails}}
${c.location} {{ticket.locationSummary}}
${c.commentLabel}
${c.commentVar}
${c.viewButton}`; } function buildBodyHtmlPl(c) { return `

${c.intro}

${c.badgePrefix}{{ticket.id}}
${c.priority} {{ticket.priority}}
${c.status} {{ticket.status}}
${c.requester}
{{ticket.requesterName}}
{{ticket.requesterContact}}
${c.commentLabel}
${c.commentVar}
${c.viewButton}`; } function buildBodyHtml(c) { return c.isSimplified ? buildBodyHtmlPl(c) : buildBodyHtmlStandard(c); } function buildTextStandard(c) { return `${c.textHeader} {{ticket.metaLine}} ${c.textCommentBy}: ${c.commentByVar} ${c.priority}: {{ticket.priority}} ${c.status}: {{ticket.status}} ${c.textAssigned}: {{ticket.assignedDetails}} ${c.textRequester}: {{ticket.requesterDetails}} ${c.board}: {{ticket.board}} ${c.category}: {{ticket.categoryDetails}} ${c.location}: {{ticket.locationSummary}} ${c.textComment}: ${c.commentVar} ${c.textView}: {{ticket.url}}`; } function buildTextPl(c) { return `${c.textHeader} {{comment.authorName}} dodał(a) komentarz do zgłoszenia {{ticket.clientName}}. Zgłoszenie #{{ticket.id}} • {{ticket.title}} ${c.priority}: {{ticket.priority}} ${c.status}: {{ticket.status}} ${c.textRequester}: {{ticket.requesterName}} ({{ticket.requesterContact}}) ${c.textComment}: ${c.commentVar} ${c.textView}: {{ticket.url}}`; } function buildText(c) { return c.isSimplified ? buildTextPl(c) : buildTextStandard(c); } function getTemplate() { return { templateName: TEMPLATE_NAME, subtypeName: SUBTYPE_NAME, translations: Object.entries(COPY).map(([lang, copy]) => ({ language: lang, subject: SUBJECTS[lang], htmlContent: wrapEmailLayout({ language: lang, headerLabel: copy.headerLabel, headerTitle: '{{ticket.title}}', headerMeta: '{{ticket.metaLine}}', bodyHtml: buildBodyHtml(copy), footerText: copy.footer, }), textContent: buildText(copy), })), }; } module.exports = { TEMPLATE_NAME, SUBTYPE_NAME, getTemplate };