fix: move mail template to assets folder

pull/53/head
shancheas 2024-08-06 06:13:13 +07:00
parent 81a463e761
commit e7abc7db13
8 changed files with 412 additions and 417 deletions

View File

@ -1,6 +1,5 @@
import * as nodemailer from 'nodemailer'; import * as nodemailer from 'nodemailer';
import * as handlebars from 'handlebars'; import * as handlebars from 'handlebars';
import * as path from 'path';
import * as fs from 'fs'; import * as fs from 'fs';
import { TransactionPaymentType } from 'src/modules/transaction/transaction/constants'; import { TransactionPaymentType } from 'src/modules/transaction/transaction/constants';
import { InvoiceType } from 'src/modules/configuration/export/constants'; import { InvoiceType } from 'src/modules/configuration/export/constants';
@ -18,11 +17,7 @@ export async function sendEmail(receivers, invoiceType, attachment?) {
for (const receiver of receivers) { for (const receiver of receivers) {
try { try {
const templateName = getTemplate(receiver.payment_type, invoiceType); const templateName = getTemplate(receiver.payment_type, invoiceType);
let templatePath = path.join( const templatePath = `./assets/email-template/${templateName}.html`;
__dirname,
`../email-template/${templateName}.html`,
);
templatePath = templatePath.replace(/dist/g, 'src');
const templateSource = fs.readFileSync(templatePath, 'utf8'); const templateSource = fs.readFileSync(templatePath, 'utf8');
const template = handlebars.compile(templateSource); const template = handlebars.compile(templateSource);