From 59a43f43e8653c0a3cc72bdb0c9d6681b447df2f Mon Sep 17 00:00:00 2001
From: Sebastian Mihalache <sebastian.mihalache@gmail.con>
Date: Thu, 27 Sep 2018 14:56:52 +0300
Subject: [PATCH] feat(email-templating): update all existing component to use
 the new email templating

---
 .../fragments/notifications/emailCopy.js      |  3 ---
 .../fragments/notifications/notifications.js  | 18 ++++++++---------
 .../notifications/helpers.js                  | 20 +++++++++----------
 .../notifications/notifications.js            |  6 +++---
 .../notifications/notifications.js            | 19 ++++++++++--------
 .../fragmentsUsers/emails/notifications.js    |  4 ++--
 .../src/routes/users/emails/notifications.js  |  4 ++--
 7 files changed, 37 insertions(+), 37 deletions(-)

diff --git a/packages/component-manuscript-manager/src/routes/fragments/notifications/emailCopy.js b/packages/component-manuscript-manager/src/routes/fragments/notifications/emailCopy.js
index b48925f98..64f10e4fc 100644
--- a/packages/component-manuscript-manager/src/routes/fragments/notifications/emailCopy.js
+++ b/packages/component-manuscript-manager/src/routes/fragments/notifications/emailCopy.js
@@ -18,9 +18,6 @@ const getEmailCopy = ({ emailType, titleText, expectedDate, customId }) => {
         To download the updated PDF and proceed with the review process, please visit the manuscript details page.<br/><br/>
         Thank you again for reviewing for ${journalName}.`
       break
-    // case 'eic-manuscript-submitted':
-    //   paragraph = `A new manuscript has been submitted. You can view ${titleText} and take further actions by clicking on the following link:`
-    //   break
     case 'eqs-manuscript-submitted':
       paragraph = `Manuscript ID ${customId} has been submitted and a package has been sent. Please click on the link below to either approve or reject the manuscript:`
       break
diff --git a/packages/component-manuscript-manager/src/routes/fragments/notifications/notifications.js b/packages/component-manuscript-manager/src/routes/fragments/notifications/notifications.js
index bd78d0169..6bc45b44d 100644
--- a/packages/component-manuscript-manager/src/routes/fragments/notifications/notifications.js
+++ b/packages/component-manuscript-manager/src/routes/fragments/notifications/notifications.js
@@ -1,9 +1,9 @@
 const config = require('config')
 const { get } = require('lodash')
+const Email = require('@pubsweet/component-email-templating')
 
 const {
   User,
-  Email,
   services,
   Fragment,
 } = require('pubsweet-component-helper-service')
@@ -122,8 +122,8 @@ const sendHandlingEditorEmail = ({
   email.content.signatureName = eicName
   email.content.subject = `${customId}: Revision submitted`
 
-  const { html, text } = email.getBody({
-    body: getEmailCopy({
+  const { html, text } = email.getNotificationBody({
+    emailBodyProps: getEmailCopy({
       emailType,
       titleText: `the manuscript titled ${title}`,
     }),
@@ -162,8 +162,8 @@ const sendReviewersEmail = async ({
       },
     )
 
-    const { html, text } = email.getBody({
-      body: getEmailCopy({
+    const { html, text } = email.getNotificationBody({
+      emailBodyProps: getEmailCopy({
         emailType,
         titleText: `the manuscript titled ${title}`,
         expectedDate: services.getExpectedDate({ daysExpected: 14 }),
@@ -196,8 +196,8 @@ const sendEQSEmail = ({ email, eicName, baseUrl, collection }) => {
   )
   email.content.ctaText = 'MAKE DECISION'
 
-  const { html, text } = email.getBody({
-    body: getEmailCopy({
+  const { html, text } = email.getNotificationBody({
+    emailBodyProps: getEmailCopy({
       emailType,
       customId: collection.customId,
     }),
@@ -273,8 +273,8 @@ const sendAuthorsEmail = async ({
       email.content.ctaText = 'CONFIRM ACCOUNT'
     }
 
-    const { html, text } = email.getBody({
-      body: {
+    const { html, text } = email.getNotificationBody({
+      emailBodyProps: {
         paragraph: author.paragraph,
         hasLink: author.hasLink,
         hasIntro: author.hasIntro,
diff --git a/packages/component-manuscript-manager/src/routes/fragmentsRecommendations/notifications/helpers.js b/packages/component-manuscript-manager/src/routes/fragmentsRecommendations/notifications/helpers.js
index 3dc8b8d77..c03dedb12 100644
--- a/packages/component-manuscript-manager/src/routes/fragmentsRecommendations/notifications/helpers.js
+++ b/packages/component-manuscript-manager/src/routes/fragmentsRecommendations/notifications/helpers.js
@@ -22,8 +22,8 @@ module.exports = {
           token: reviewer.accessTokens.unsubscribe,
         },
       )
-      const { html, text } = email.getBody({
-        body: {
+      const { html, text } = email.getNotificationBody({
+        emailBodyProps: {
           paragraph: reviewer.paragraph,
           hasLink: reviewer.hasLink,
           hasIntro: reviewer.hasIntro,
@@ -108,8 +108,8 @@ module.exports = {
     titleText,
     targetUserName,
   }) => {
-    const { html, text } = email.getBody({
-      body: getEmailCopy({
+    const { html, text } = email.getNotificationBody({
+      emailBodyProps: getEmailCopy({
         emailType,
         titleText,
         comments,
@@ -246,8 +246,8 @@ module.exports = {
         email: eic.email,
         name: `${eic.firstName} ${eic.lastName}`,
       }
-      const { html, text } = email.getBody({
-        body: {
+      const { html, text } = email.getNotificationBody({
+        emailBodyProps: {
           paragraph: eic.paragraph,
           hasLink: eic.hasLink,
           hasIntro: eic.hasIntro,
@@ -271,8 +271,8 @@ module.exports = {
           token: author.accessTokens.unsubscribe,
         },
       )
-      const { html, text } = email.getBody({
-        body: {
+      const { html, text } = email.getNotificationBody({
+        emailBodyProps: {
           paragraph: author.paragraph,
           hasLink: author.hasLink,
           hasIntro: author.hasIntro,
@@ -353,8 +353,8 @@ module.exports = {
         token: author.accessTokens.unsubscribe,
       },
     )
-    const { html, text } = email.getBody({
-      body: {
+    const { html, text } = email.getNotificationBody({
+      emailBodyProps: {
         paragraph: author.paragraph,
         hasLink: author.hasLink,
         hasIntro: author.hasIntro,
diff --git a/packages/component-manuscript-manager/src/routes/fragmentsRecommendations/notifications/notifications.js b/packages/component-manuscript-manager/src/routes/fragmentsRecommendations/notifications/notifications.js
index c930744e7..671d197e9 100644
--- a/packages/component-manuscript-manager/src/routes/fragmentsRecommendations/notifications/notifications.js
+++ b/packages/component-manuscript-manager/src/routes/fragmentsRecommendations/notifications/notifications.js
@@ -1,9 +1,9 @@
 const config = require('config')
 const { get, isEmpty } = require('lodash')
+const Email = require('@pubsweet/component-email-templating')
 
 const {
   User,
-  Email,
   services,
   Fragment,
   Collection,
@@ -254,8 +254,8 @@ const sendEQAEmail = ({
   email.content.unsubscribeLink = baseUrl
   email.content.signatureName = eicName
 
-  const { html, text } = email.getBody({
-    body: getEmailCopy({
+  const { html, text } = email.getNotificationBody({
+    emailBodyProps: getEmailCopy({
       eicName,
       titleText,
       emailType,
diff --git a/packages/component-manuscript-manager/src/routes/technicalChecks/notifications/notifications.js b/packages/component-manuscript-manager/src/routes/technicalChecks/notifications/notifications.js
index a51cf5e2b..282602932 100644
--- a/packages/component-manuscript-manager/src/routes/technicalChecks/notifications/notifications.js
+++ b/packages/component-manuscript-manager/src/routes/technicalChecks/notifications/notifications.js
@@ -126,8 +126,8 @@ const sendEditorsEmail = async ({
       email: eic.email,
       name: `${eic.firstName} ${eic.lastName}`,
     }
-    const { html, text } = email.getBody({
-      body: {
+    const { html, text } = email.getNotificationBody({
+      emailBodyProps: {
         paragraph: eic.paragraph,
         hasLink: eic.hasLink,
         hasIntro: eic.hasIntro,
@@ -156,8 +156,8 @@ const sendHandlingEditorEmail = ({
     id: handlingEditor.id,
   })
 
-  const { html, text } = email.getBody({
-    body: getEmailCopy({
+  const { html, text } = email.getNotificationBody({
+    emailBodyProps: getEmailCopy({
       emailType,
       titleText,
     }),
@@ -198,8 +198,11 @@ const sendSubmittedReviewersEmail = async ({
         id: reviewer.id,
       },
     )
-    const { html, text } = email.getBody({
-      body: { paragraph: reviewer.paragraph, hasLink: reviewer.hasLink },
+    const { html, text } = email.getNotificationBody({
+      emailBodyProps: {
+        paragraph: reviewer.paragraph,
+        hasLink: reviewer.hasLink,
+      },
     })
     email.sendEmail({ html, text })
   })
@@ -235,8 +238,8 @@ const sendAuthorsEmail = ({
         id: author.id,
       },
     )
-    const { html, text } = email.getBody({
-      body: {
+    const { html, text } = email.getNotificationBody({
+      emailBodyProps: {
         paragraph: author.paragraph,
         hasLink: author.hasLink,
       },
diff --git a/packages/component-user-manager/src/routes/fragmentsUsers/emails/notifications.js b/packages/component-user-manager/src/routes/fragmentsUsers/emails/notifications.js
index 26bf63b94..70fc4ac92 100644
--- a/packages/component-user-manager/src/routes/fragmentsUsers/emails/notifications.js
+++ b/packages/component-user-manager/src/routes/fragmentsUsers/emails/notifications.js
@@ -62,8 +62,8 @@ module.exports = {
       email.content.ctaText = 'CONFIRM ACCOUNT'
     }
 
-    const { html, text } = email.getBody({
-      body: getEmailCopy({
+    const { html, text } = email.getNotificationBody({
+      emailBodyProps: getEmailCopy({
         emailType: 'submitting-author-added-by-admin',
         titleText,
       }),
diff --git a/packages/component-user-manager/src/routes/users/emails/notifications.js b/packages/component-user-manager/src/routes/users/emails/notifications.js
index 461584e19..c68f35f2b 100644
--- a/packages/component-user-manager/src/routes/users/emails/notifications.js
+++ b/packages/component-user-manager/src/routes/users/emails/notifications.js
@@ -36,8 +36,8 @@ const sendForgotPasswordEmail = ({ email, baseUrl, user }) => {
     token: user.accessTokens.unsubscribe,
   })
 
-  const { html, text } = email.getBody({
-    body: getEmailCopy({
+  const { html, text } = email.getNotificationBody({
+    emailBodyProps: getEmailCopy({
       emailType: 'user-forgot-password',
     }),
   })
-- 
GitLab