Email Templates
This library is responsible for creating email templates
Installation
Use npm to install the package
npm install email-templates-approve
Usage
Basic example
import emailTemplates from "email-templates-approve/src/index";
const html = emailTemplates.generalNotification(data, lang);
Adding New Template
From the root directory, using the CLI you can run the following command
node new-template-script <templateName>
This command will generate the most of the boilerplate needed for the new template.
The console will print which files has been added to the project.
IMPORTANT! - Inside the main file (/src/index.js) a new function will be created by the CLI command. You need to add this function to the emailTemplates
object which exported from this file. This is the only boilerplate action that needed to be done manually.
Anyway, the console will tell you to do so after running the new-template-script
command.
Template Debugging
Run npm start
and an express server will be lunched.
In the browser, navigate into localhost:5020/?templateName=<templateName>
, replace the query variable with the desired template name (camel case, like how the template files names written).
To change the template data payload, just go to /src/constants/testingPayloads.constant.js
and change the relevant object.
Publish
In order to publish your changes run the following command from anywhere inside the project.
You should be member of the NPM repository package to be abele to do so.
npm version patch
npm publish
No need to increase the package version manually, its done by the prepublish
npm script.
Interface
All the exposed functions accepts two arguments - data: any
and lang: 'en' | 'he' (default 'en')
.
The type of data
depends on the function we use:
- singleContractExpirationNotification
data: {
logo: string,
name: string,
vendorName: string,
daysToExpire: string | number,
expirationDate: string,
actionUrl: string
}
- multiContractExpirationNotification
data: {
logo: string,
name: string,
contracts: {
vendorName: string,
daysToExpire: string | number,
expirationDate: string
}[],
actionUrl: string
}
data: {
addresseeName: string,
inviterName: string,
buttonUrl: string
}
- userInviteWithCredentials
data: {
addresseeName: string,
inviterName: string,
companyName: string,
username: string,
code: string,
buttonUrl: string,
}
data: {
items: {title: string, quantity: string | number},
buttonUrl: string,
linkUrl: string
}
data: {
addresseeName: string,
title: string,
approvalFlow?: string,
description?: string,
isRequestedForHidden?: boolean,
requestedForName?: string,
requestedForTitle?: string,
requestorName: string,
requestorTitle?: string,
swId?: string,
vendorName?: string,
vendorErpId?: string,
budgetItem?: string,
department?: string[],
usdAmount: string | number,
items?: {
description: string,
quantity: number,
amount: number,
currency: string,
timeFrame?: {
from: Date,
to: Date
}
}[],
approveUrl?: string,
rejectUrl?: string,
purchaseUrl: string,
isCC?: boolean,
}
data: {
addresseeName: string,
buttonUrl: string,
purchaseTitle: string,
approverName: string,
approverTitle: string,
note?: string
isCC?: boolean,
}
data: {
addresseeName: string,
buttonUrl: string,
purchaseTitle: string,
approverName: string,
approverTitle?: string,
poNumber: string,
note?: string
isCC?: boolean,
}
data: {
addresseeName: string,
buttonUrl: string,
purchaseTitle: string,
approverName: string,
approverTitle?: string,
note?: string
isCC?: boolean,
}
data: {
addresseeName: string,
title: string,
approverName: string,
approverTitle?: string,
note?: string,
buttonUrl: string
}
data: {
addresseeName: string,
approverName: string,
approverTitle?: string,
title: string,
note?: string,
approvalFlow?: string,
description: string,
isRequestedForHidden?: boolean,
requestedForName?: string,
requestedForTitle?: string,
requestorName: string,
requestorTitle?: string,
swId?: string,
vendorName?: string,
vendorErpId?: string,
budgetItem?: string,
department?: string[],
usdAmount: string | number,
items: {
description: string,
quantity: number,
amount: number,
currency: string,
timeFrame?: {
from: Date,
to: Date
}
}[],
replyUrl?: string,
purchaseUrl: string,
isCC?: boolean,
}
data: {
title: string,
addresseeName: string,
approverName: string,
approverNodeName: string,
note?: string
buttonUrl: string
}
data: {
companyName: string,
vendorName: string,,
isCC?: boolean,
}
data: {
vendorLogoUrl: string,
companyName: string,
isCC?: boolean,
}
data: {
logoUrl: string,
addresseeName: string,
buttonUrl: string,
vendorName: string,
approverName: string,
approverTitle?: string,
isCC?: boolean,
}
data: {
logoUrl: string,
companyName: string,
approverName: string,
note?: string,
isCC?: boolean,
}
data: {
logoUrl: string,
vendorName: string,
approverName: string,
companyName: string,
buttonUrl: string,
note?: string,
isCC?: boolean,
}
data: {
logoUrl: string,
inviterName: string,
companyName: string,
invitationNote?: string
buttonUrl: string,
isCC?: boolean,
}
data: {
logoUrl: string,
addresseeName: string,
vendorName: string,
vendorDescription: string,
vendorOwnerName: string,
goToVendorUrl: string
}
data: {
logoUrl: string,
addresseeName: string,
addressedName: string,
vendorName: string,
vendorDescription?: string,
vendorOwnerName: string,
vendorOwnerEmail: string,
buttonUrl: string,
enterApproveUrl: string,
}
data: {
logoUrl: string,
addresseeName: string,
approverName: string,
vendorName: string,
note?: string,
buttonUrl: string,
}
- contractrsExpirationReminder
data: {
addresseeName: string,
contracts: {
vendorName: string,
daysToExpire: string,
expirationDate: string,
}[],
actionUrl: string,
}
data: {
addresseeName: string,
items: {
description: string,
quantity: number | string,
}[],
buttonUrl: string,
}
data: {
addresseeName: string,
purchases: {
title: string,
url: string
}[],
daysCount: number | string,
buttonUrl: string,
}
data: {
title: string,
approverName: string,
approverTitle: string,
note: string,
contractUrl: string,
}
data: {
title: string,
description: string,
vendorName: string,
datesRange: '01/01/2021 - 31/12/20201',
contractTerm: string,
contractUrl: string,
contractsUrl: string,
}
data: {
addresseeName: string,
addresserName: string,
title: string,
note: string,
contractUrl: string,
}
data: {
addresseeName: string
addresserName: string,
title: string,
description: string,
vendorName: string,
datesRange: '01/01/20201 - 31/12/2021',
contractTerm: string,
replyUrl: string,
approveUrl: string,
}
data: {
title: string,
addresserName: string,
addresserTitle: string,
note: string,
contractUrl: string,
}
data: {
addresseeName: string,
title: string,
addresserName: string,
addresserTitle: string,
note: string,
contractUrl: string,
}
data: {
addresseeName: string,
code: string,
}
- vendor-register-externally
data: {
contactName: string,
requestorName: string,
description: string,
swId: string,
purchaseUrl: string,
vendorName: string
}