add replacemailvaribles function to change varibale from custom mail

This commit is contained in:
prafull-opensignlabs
2024-02-08 20:03:15 +05:30
parent 9d431af0b9
commit b58c3fd467
+21
View File
@@ -17,3 +17,24 @@ export const color = [
'#66ccff',
'#ffffcc',
];
export function replaceMailVaribles(subject, body, variables) {
let replacedSubject = subject;
let replacedBody = body;
for (const variable in variables) {
const regex = new RegExp(`{{${variable}}}`, 'g');
if (subject) {
replacedSubject = replacedSubject.replace(regex, variables[variable]);
}
if (body) {
replacedBody = replacedBody.replace(regex, variables[variable]);
}
}
const result = {
subject: replacedSubject,
body: replacedBody,
};
return result;
}