Skip to content
Snippets Groups Projects
Commit e57e39ee authored by Andrei Cioromila's avatar Andrei Cioromila
Browse files

docs(email-template): update code example for using EmailTemplate class

parent a2c5e20f
No related branches found
No related tags found
3 merge requests!160Update staging with master features,!156Develop,!149Hin 1089
...@@ -56,13 +56,15 @@ The `Email` class also provides a `constructor` whose properties will be used wh ...@@ -56,13 +56,15 @@ The `Email` class also provides a `constructor` whose properties will be used wh
![notification](https://gitlab.coko.foundation/xpub/xpub-faraday/uploads/27cb6acc8ff4a07758f55e5ea0504d28/notification.png) ![notification](https://gitlab.coko.foundation/xpub/xpub-faraday/uploads/27cb6acc8ff4a07758f55e5ea0504d28/notification.png)
```javascript ```javascript
const emailTemplate = require('@pubsweet/component-email-template') const EmailTemplate = require('@pubsweet/component-email-template')
const config = require('config') const config = require('config')
const { name: journalName, fromEmail: staffEmail } = config.get('journal') const { name: journalName, fromEmail: staffEmail } = config.get('journal')
const paragraph = `We are please to inform you that the manuscript has passed the technical check process and is now submitted. Please click the link below to access the manuscript.`
const sendNotifications = ({ user, editor, collection, fragment }) => { const sendNotifications = ({ user, editor, collection, fragment }) => {
const email = new emailTemplate({ const email = new EmailTemplate({
type: 'user', type: 'user',
fromEmail, fromEmail,
toUser: { toUser: {
...@@ -74,18 +76,19 @@ The `Email` class also provides a `constructor` whose properties will be used wh ...@@ -74,18 +76,19 @@ The `Email` class also provides a `constructor` whose properties will be used wh
signatureJournal: journalName, signatureJournal: journalName,
signatureName: `${editor.name}`, signatureName: `${editor.name}`,
subject: `${collection.customId}: Manuscript Update`, subject: `${collection.customId}: Manuscript Update`,
paragraph,
unsubscribeLink: `http://localhost:3000/unsubscribe/${user.id}`, unsubscribeLink: `http://localhost:3000/unsubscribe/${user.id}`,
ctaLink: `http://localhost:3000/projects/${collection.id}/versions/${ ctaLink: `http://localhost:3000/projects/${collection.id}/versions/${
fragment.id fragment.id
}/details`, }/details`,
}, },
bodyProps: {
hasLink: true,
hasIntro: true,
hasSignature: true }
}) })
const paragraph = `We are please to inform you that the manuscript has passed the technical check process and is now submitted. Please click the link below to access the manuscript.` email.sendEmail()
const { html, text } = email.getNotificationBody({ emailBodyProps: { paragraph, hasLink: true, hasIntro: true, hasSignature: true }})
email.sendEmail({ html, text })
} }
``` ```
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment