From dbf57d7724940e7f4d7648fde79a97707e02e68f Mon Sep 17 00:00:00 2001 From: Sebastian <sebastian.mihalache@thinslices.com> Date: Wed, 25 Apr 2018 13:47:03 +0300 Subject: [PATCH] feat(component-mail-service): add agreed reviewer email --- packages/component-mail-service/src/Mail.js | 57 +++-- .../src/templates/reviewer-agreed.html | 224 ++++++++++++++++++ .../src/templates/reviewer-agreed.txt | 6 + 3 files changed, 258 insertions(+), 29 deletions(-) create mode 100644 packages/component-mail-service/src/templates/reviewer-agreed.html create mode 100644 packages/component-mail-service/src/templates/reviewer-agreed.txt diff --git a/packages/component-mail-service/src/Mail.js b/packages/component-mail-service/src/Mail.js index dc5282a44..0dc86ce4d 100644 --- a/packages/component-mail-service/src/Mail.js +++ b/packages/component-mail-service/src/Mail.js @@ -170,16 +170,6 @@ module.exports = { } const daysExpected = resend ? 0 : 14 - - const date = new Date(timestamp) - let expectedDate = date.getDate() + daysExpected - date.setDate(expectedDate) - expectedDate = date.toLocaleDateString('en-US', { - day: 'numeric', - month: 'long', - year: 'numeric', - }) - const replacements = { reviewerName: `${invitedUser.firstName} ${invitedUser.lastName}`, agreeUrl, @@ -188,7 +178,7 @@ module.exports = { title, editorName: handlingEditor.name, submittingAuthorName: authorName, - expectedDate, + expectedDate: getExpectedDate(timestamp, daysExpected), abstract, editorEmail: handlingEditor.email, authors, @@ -233,33 +223,30 @@ module.exports = { } return Email.send(mailData) }, - setupReviewerDeclinedEmail: async ( + setupReviewerDecisionEmail: async ({ toEmail, - invitedUser, - collection, - title, - authorName, - fragmentId, + reviewerName, + collection: { customId, id: collectionId, handlingEditor }, eicName, baseUrl, - ) => { - const subject = `${collection.customId}: Manuscript Reviews` - const manuscriptUrl = `${baseUrl}/projects/${ - collection.id - }/versions/${fragmentId}/details` + fragment: { id: fragmentId, title, authorName }, + agree, + timestamp = Date.now(), + }) => { + const subject = `${customId}: Manuscript Reviews` + const manuscriptUrl = `${baseUrl}/projects/${collectionId}/versions/${fragmentId}/details` + const replacements = { - reviewerName: `${invitedUser.firstName} ${invitedUser.lastName}`, + reviewerName, title, - editorName: collection.handlingEditor.name, + editorName: handlingEditor.name, authorName, manuscriptUrl, eicName, + expectedDate: getExpectedDate(timestamp, 14), } - - const { htmlBody, textBody } = getEmailBody( - 'reviewer-declined', - replacements, - ) + const emailType = agree ? 'reviewer-agreed' : 'reviewer-declined' + const { htmlBody, textBody } = getEmailBody(emailType, replacements) const mailData = { from: config.get('mailer.from'), to: toEmail, @@ -289,3 +276,15 @@ const readFile = path => return file } }) + +const getExpectedDate = (timestamp, daysExpected) => { + const date = new Date(timestamp) + let expectedDate = date.getDate() + daysExpected + date.setDate(expectedDate) + expectedDate = date.toLocaleDateString('en-US', { + day: 'numeric', + month: 'long', + year: 'numeric', + }) + return expectedDate +} diff --git a/packages/component-mail-service/src/templates/reviewer-agreed.html b/packages/component-mail-service/src/templates/reviewer-agreed.html new file mode 100644 index 000000000..00ebd7a6b --- /dev/null +++ b/packages/component-mail-service/src/templates/reviewer-agreed.html @@ -0,0 +1,224 @@ +<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> +<html data-editor-version="2" class="sg-campaigns" xmlns="http://www.w3.org/1999/xhtml"> + +<head> + <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> + <meta name="viewport" content="width=device-width, initial-scale=1, minimum-scale=1, maximum-scale=1" /> + <!--[if !mso]><!--> + <meta http-equiv="X-UA-Compatible" content="IE=Edge" /> + <!--<![endif]--> + <!--[if (gte mso 9)|(IE)]> + <xml> + <o:OfficeDocumentSettings> + <o:AllowPNG/> + <o:PixelsPerInch>96</o:PixelsPerInch> + </o:OfficeDocumentSettings> + </xml> + <![endif]--> + <!--[if (gte mso 9)|(IE)]> + <style type="text/css"> + body {width: 600px;margin: 0 auto;} + table {border-collapse: collapse;} + table, td {mso-table-lspace: 0pt;mso-table-rspace: 0pt;} + img {-ms-interpolation-mode: bicubic;} + </style> + <![endif]--> + + <style type="text/css"> + body, + p, + div { + font-family: helvetica, arial, sans-serif; + font-size: 14px; + } + + body { + color: #626262; + } + + body a { + color: #0D78F2; + text-decoration: none; + } + + p { + margin: 0; + padding: 0; + } + + table.wrapper { + width: 100% !important; + table-layout: fixed; + -webkit-font-smoothing: antialiased; + -webkit-text-size-adjust: 100%; + -moz-text-size-adjust: 100%; + -ms-text-size-adjust: 100%; + } + + img.max-width { + max-width: 100% !important; + } + + .column.of-2 { + width: 50%; + } + + .column.of-3 { + width: 33.333%; + } + + .column.of-4 { + width: 25%; + } + + @media screen and (max-width:480px) { + .preheader .rightColumnContent, + .footer .rightColumnContent { + text-align: left !important; + } + .preheader .rightColumnContent div, + .preheader .rightColumnContent span, + .footer .rightColumnContent div, + .footer .rightColumnContent span { + text-align: left !important; + } + .preheader .rightColumnContent, + .preheader .leftColumnContent { + font-size: 80% !important; + padding: 5px 0; + } + table.wrapper-mobile { + width: 100% !important; + table-layout: fixed; + } + img.max-width { + height: auto !important; + max-width: 480px !important; + } + a.bulletproof-button { + display: block !important; + width: auto !important; + font-size: 80%; + padding-left: 0 !important; + padding-right: 0 !important; + } + .columns { + width: 100% !important; + } + .column { + display: block !important; + width: 100% !important; + padding-left: 0 !important; + padding-right: 0 !important; + margin-left: 0 !important; + margin-right: 0 !important; + } + } + </style> + <!--user entered Head Start--> + + <!--End Head user entered--> +</head> + +<body> + <center class="wrapper" data-link-color="#0D78F2" data-body-style="font-size: 14px; font-family: helvetica,arial,sans-serif; color: #626262; background-color: #F4F4F4;"> + <div class="webkit"> + <table cellpadding="0" cellspacing="0" border="0" width="100%" class="wrapper" bgcolor="#F4F4F4"> + <tr> + <td valign="top" bgcolor="#F4F4F4" width="100%"> + <table width="100%" role="content-container" class="outer" align="center" cellpadding="0" cellspacing="0" border="0"> + <tr> + <td width="100%"> + <table width="100%" cellpadding="0" cellspacing="0" border="0"> + <tr> + <td> + <!--[if mso]> + <center> + <table><tr><td width="600"> + <![endif]--> + <table width="100%" cellpadding="0" cellspacing="0" border="0" style="width: 100%; max-width:600px;" align="center"> + <tr> + <td role="modules-container" style="padding: 0px 0px 0px 0px; color: #626262; text-align: left;" bgcolor="#F4F4F4" width="100%" + align="left"> + + <table class="module preheader preheader-hide" role="module" data-type="preheader" border="0" cellpadding="0" cellspacing="0" + width="100%" style="display: none !important; mso-hide: all; visibility: hidden; opacity: 0; color: transparent; height: 0; width: 0;"> + <tr> + <td role="module-content"> + <p>reviewer agreed</p> + </td> + </tr> + </table> + + <table class="wrapper" role="module" data-type="image" border="0" cellpadding="0" cellspacing="0" width="100%" style="table-layout: fixed;"> + <tr> + <td style="font-size:6px;line-height:10px;padding:20px 0px 20px 0px;" valign="top" align="center"> + <img class="max-width" border="0" style="display:block;color:#000000;text-decoration:none;font-family:Helvetica, arial, sans-serif;font-size:16px;max-width:10% !important;width:10%;height:auto !important;" + src="https://marketing-image-production.s3.amazonaws.com/uploads/bb39b20cf15e52c1c0933676e25f2b2402737c6560b8098c204ad6932b84eb2058804376dbc4db138c7a21dcaed9325bde36185648afac5bc97e3d73d4e12718.png" + alt="" width="60"> + </td> + </tr> + </table> + + <table class="module" role="module" data-type="text" border="0" cellpadding="0" cellspacing="0" width="100%" style="table-layout: fixed;"> + <tr> + <td style="padding:30px 23px 0px 23px;background-color:#ffffff;" height="100%" valign="top" bgcolor="#ffffff"> + <div> + <p data-pm-slice="1 1 []">Dear {{editorName}},</p> + + <p> </p> + <p>We are pleased to inform you that {{reviewerName}} has agreed to review the manuscript + titled "{{ title }}" by {{authorName}} + </p> + <p> </p> + <p>You should receive the report by {{reviewerName}} before {{expectedDate}}. If you have + any queries, or would like to send a reminder if you no report has been submitted, + then please visit the + <a href="{{manuscriptUrl}}">manuscript details page</a>.</p> + <p> </p> + <p>Best regards, + <br /> {{eicName}} + <br /> Hindawi + </p> + <p> </p> + </div> + + </td> + </tr> + </table> + <div data-role="module-unsubscribe" class="module unsubscribe-css__unsubscribe___2CDlR" role="module" data-type="unsubscribe" + style="color:#444444;font-size:12px;line-height:20px;padding:16px 16px 16px 16px;text-align:center"> + <div class="Unsubscribe--addressLine"> + <p class="Unsubscribe--senderName" style="font-family:Arial, Helvetica, sans-serif;font-size:12px;line-height:20px">Hindawi Publishing Corporation</p> + <p style="font-family:Arial, Helvetica, sans-serif;font-size:12px;line-height:20px"> + <span class="Unsubscribe--senderAddress">315 Madison Ave, Third Floor, Suite 3070</span>, + <span class="Unsubscribe--senderCity">NEW YORK</span>, + <span class="Unsubscribe--senderState">NY</span> + <span class="Unsubscribe--senderZip">10017</span> + </p> + </div> + <p style="font-family:Arial, Helvetica, sans-serif;font-size:12px;line-height:20px"> + <a class="Unsubscribe--unsubscribeLink" href="[Unsubscribe]">Unsubscribe</a> + </p> + </div> + </td> + </tr> + </table> + <!--[if mso]> + </td></tr></table> + </center> + <![endif]--> + </td> + </tr> + </table> + </td> + </tr> + </table> + </td> + </tr> + </table> + </div> + </center> +</body> + +</html> \ No newline at end of file diff --git a/packages/component-mail-service/src/templates/reviewer-agreed.txt b/packages/component-mail-service/src/templates/reviewer-agreed.txt new file mode 100644 index 000000000..a1aea9da6 --- /dev/null +++ b/packages/component-mail-service/src/templates/reviewer-agreed.txt @@ -0,0 +1,6 @@ +Dear {{ editorName }} +We are pleased to inform you that {{ reviewerName }} has agreed to review the manuscript titled "{{ title }}" by {{authorName}}. +You should receive the report by {{reviewerName}} before {{expectedDate}}. If you have any queries, or would like to send a reminder if you no report has been submitted, then please visit the {{manuscriptUrl}} manuscript details page +Best regards, +{{eicName}} +Hindawi -- GitLab