DRY Email Template #44
Unanswered
rathorevaibhav
asked this question in
Software Principles
Replies: 1 comment
-
@rathorevaibhav so here we can remove the switch statement and get the instance name from env. and email template used according to the instance name and If no matching instance is found, the default instance is used. const ReviewRejectEmailTemplate = ({
articleTitle,
authorName,
reviewerName,
receiverName,
shortId,
}) => {
const instances = {
aperture: {
cc: 'apertureadmin@aperture.domain.org',
sender: 'Aperture Neuro Team',
},
default: {
cc: '',
sender: 'Kotahi Dev',
},
};
const instanceName = process.env.INSTANCE_NAME || 'default';
const instance = instances[instanceName];
const result = {
cc: instance.cc,
subject: 'Reviewer has rejected review invitation',
content: `<p>
<p>Dear ${receiverName},</p>
<p>Reviewer ${reviewerName} has rejected your review invitation. Please log into the publishing platform and invite another reviewer to the submission:</p>
<p>“${shortId}; ${articleTitle}, ${authorName}”</p>
<p>Thank you,</p>
<p>${instance.sender}</p>
</p>`,
};
result.content = result.content.replace(/\n/g, '');
return result;
};
module.exports = ReviewRejectEmailTemplate; |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Description
The following is an email template that gets sent when a reviewer rejects an article. Can you refactor the code and remove duplication?
Beta Was this translation helpful? Give feedback.
All reactions