fix: move mail template to assets folder
parent
81a463e761
commit
e7abc7db13
|
@ -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);
|
||||||
|
|
Loading…
Reference in New Issue