Skip to content
Snippets Groups Projects
Commit 0e96a3ca authored by Sebastian Mihalache's avatar Sebastian Mihalache
Browse files

fix(component-manuscript-manager): add emails for eic

parent abb8644e
No related branches found
No related tags found
1 merge request!21Sprint #16 features
...@@ -8,8 +8,8 @@ const getEmailCopy = ({ ...@@ -8,8 +8,8 @@ const getEmailCopy = ({
let hasLink = true let hasLink = true
switch (emailType) { switch (emailType) {
case 'author-request-to-revision': case 'author-request-to-revision':
paragraph = `In order for ${titleText} to proceed to publication, there needs to be a revision. <br/><br/> paragraph = `In order for ${titleText} to proceed to publication, there needs to be a revision. <br/>
${comments}<br/><br/> ${comments}<br/>
For more information about what is required, please visit the manuscript details page.` For more information about what is required, please visit the manuscript details page.`
break break
case 'author-manuscript-rejected': case 'author-manuscript-rejected':
...@@ -41,8 +41,8 @@ const getEmailCopy = ({ ...@@ -41,8 +41,8 @@ const getEmailCopy = ({
case 'accepted-reviewers-after-recommendation': case 'accepted-reviewers-after-recommendation':
hasLink = false hasLink = false
paragraph = `I appreciate any time you may have spent reviewing ${titleText}. However, an editorial decision has been made and the review of this manuscript is now complete. I apologize for any inconvenience. <br/> paragraph = `I appreciate any time you may have spent reviewing ${titleText}. However, an editorial decision has been made and the review of this manuscript is now complete. I apologize for any inconvenience. <br/>
If you have comments on this manuscript you believe the Editor should see, please email them to Hindawi as soon as possible. <br/> If you have comments on this manuscript you believe the Editor should see, please email them to Hindawi as soon as possible. <br/>
Thank you for your interest and I hope you will consider reviewing for Hindawi again.` Thank you for your interest and I hope you will consider reviewing for Hindawi again.`
break break
case 'pending-reviewers-after-recommendation': case 'pending-reviewers-after-recommendation':
hasLink = false hasLink = false
...@@ -60,7 +60,22 @@ const getEmailCopy = ({ ...@@ -60,7 +60,22 @@ const getEmailCopy = ({
If you have any queries about this decision, then please email them to Hindawi as soon as possible.` If you have any queries about this decision, then please email them to Hindawi as soon as possible.`
break break
case 'he-review-submitted': case 'he-review-submitted':
paragraph = `We are pleased to inform you that Dr. ${targetUserName} has submitted a review for ${titleText}.` paragraph = `We are pleased to inform you that Dr. ${targetUserName} has submitted a review for ${titleText}.<br/>
Please visit the manuscript details page to see the full review.`
break
case 'eic-recommend-to-publish-from-he':
paragraph = `It is my recommendation, based on the reviews I have received for ${titleText} that we should proceed to publication.<br/>
${comments}<br/>
For more information, and to see the full review, please visit the manuscript details page.`
break
case 'eic-recommend-to-reject-from-he':
paragraph = `It is my recommendation, based on the reviews I have received for ${titleText} that we should reject it for publication.<br/>
${comments}<br/>
For more information, and to see the full review, please visit the manuscript details page.`
break
case 'eic-request-revision-from-he':
paragraph = `In order for ${titleText} to proceed to publication, there needs to be a revision. <br/><br/>
For more information about what is required, please visit the manuscript details page.`
break break
default: default:
throw new Error(`The ${emailType} email type is not defined.`) throw new Error(`The ${emailType} email type is not defined.`)
......
...@@ -36,17 +36,22 @@ module.exports = { ...@@ -36,17 +36,22 @@ module.exports = {
const email = new Email({ const email = new Email({
type: 'user', type: 'user',
content: { content: {
signatureName: get(collection, 'handlingEditor.name', 'Hindawi'), unsubscribeLink: baseUrl,
ctaText: 'MANUSCRIPT DETAILS',
signatureName: get(collection, 'handlingEditor.name', 'N/A'),
ctaLink: services.createUrl( ctaLink: services.createUrl(
baseUrl, baseUrl,
`/projects/${collection.id}/versions/${fragment.id}/details`, `/projects/${collection.id}/versions/${fragment.id}/details`,
), ),
ctaText: 'MANUSCRIPT DETAILS',
}, },
}) })
const userHelper = new User({ UserModel }) const userHelper = new User({ UserModel })
const { firstName, lastName } = await userHelper.getEditorInChief() const {
email: eicEmail,
firstName,
lastName,
} = await userHelper.getEditorInChief()
const eicName = `${firstName} ${lastName}` const eicName = `${firstName} ${lastName}`
let comments let comments
...@@ -61,6 +66,7 @@ module.exports = { ...@@ -61,6 +66,7 @@ module.exports = {
} }
if (isEditorInChief || newRecommendation.recommendationType === 'review') { if (isEditorInChief || newRecommendation.recommendationType === 'review') {
// the request came from either the Editor in Chief or a reviewer, so the HE needs to be notified
sendHandlingEditorEmail({ sendHandlingEditorEmail({
email, email,
eicName, eicName,
...@@ -99,7 +105,17 @@ module.exports = { ...@@ -99,7 +105,17 @@ module.exports = {
isEditorInChief, isEditorInChief,
subjectBaseText, subjectBaseText,
recommendation: newRecommendation.recommendation, recommendation: newRecommendation.recommendation,
handlingEditorName: get(collection, 'handlingEditor.name', 'Faraday'), handlingEditorName: get(collection, 'handlingEditor.name', 'N/A'),
})
sendEiCEmail({
email,
baseUrl,
eicName,
eicEmail,
titleText,
subjectBaseText,
recommendation: newRecommendation,
}) })
} }
}, },
...@@ -319,6 +335,50 @@ const sendReviewersEmail = async ({ ...@@ -319,6 +335,50 @@ const sendReviewersEmail = async ({
}) })
} }
const sendEiCEmail = ({
email,
eicName,
eicEmail,
titleText,
recommendation,
subjectBaseText,
}) => {
let emailType
email.content.subject = `${subjectBaseText} Recommendation`
switch (recommendation.recommendation) {
case 'minor':
case 'major':
emailType = 'eic-request-revision-from-he'
break
case 'publish':
emailType = 'eic-recommend-to-publish-from-he'
break
case 'reject':
emailType = 'eic-recommend-to-reject-from-he'
break
default:
throw new Error(`undefined recommendation: ${recommendation} `)
}
email.toUser = {
email: eicEmail,
name: eicName,
}
const privateNote = recommendation.comments.find(comm => comm.private)
const content = get(privateNote, 'content')
const comments = content ? `Note to Editor: "${content}"` : ''
const { html, text } = email.getBody({
body: getEmailCopy({
emailType,
titleText,
comments,
}),
})
email.sendEmail({ html, text })
}
const getSubjectByRecommendation = recommendation => const getSubjectByRecommendation = recommendation =>
['minor', 'major'].includes(recommendation) ['minor', 'major'].includes(recommendation)
? 'Revision Requested' ? 'Revision Requested'
......
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