-
Notifications
You must be signed in to change notification settings - Fork 30
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1084 from OneCommunityGlobal/Ivy-isSet-issues
Ivy-set-final-day-emailTemplate
- Loading branch information
Showing
2 changed files
with
27 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2030,16 +2030,36 @@ const userHelper = function () { | |
}); | ||
}; | ||
|
||
const sendDeactivateEmailBody = function (firstName, lastName, endDate, email, recipients) { | ||
if (endDate) { | ||
const subject = `IMPORTANT:${firstName} ${lastName} has been deactivated in the Highest Good Network`; | ||
const sendDeactivateEmailBody = function ( | ||
firstName, | ||
lastName, | ||
endDate, | ||
email, | ||
recipients, | ||
isSet, | ||
) { | ||
if (endDate && !isSet) { | ||
const subject = `IMPORTANT: ${firstName} ${lastName} has been deactivated in the Highest Good Network`; | ||
const emailBody = `<p>Management, </p> | ||
<p>Please note that ${firstName} ${lastName} has been made inactive in the Highest Good Network as of ${endDate}. | ||
Please confirm all your work with this individual has been wrapped up and nothing further is needed on their part. </p> | ||
<p>With Gratitude, </p> | ||
<p>One Community</p>`; | ||
recipients.push('[email protected]'); | ||
recipients = recipients.toString(); | ||
emailSender(recipients, subject, emailBody, null, null, email); | ||
} else if (isSet) { | ||
const subject = `IMPORTANT: ${firstName} ${lastName} has been deactivated in the Highest Good Network`; | ||
const emailBody = `<p>Management, </p> | ||
<p>Please note that the final day for ${firstName} ${lastName} has been set in the Highest Good Network ${endDate}. | ||
For a smooth transition, please confirm all your work is being wrapped up with this individual and nothing further will be needed on their part after this date. </p> | ||
<p>With Gratitude, </p> | ||
<p>One Community</p>`; | ||
recipients.push('[email protected]'); | ||
recipients = recipients.toString(); | ||
|
@@ -2056,7 +2076,7 @@ const userHelper = function () { | |
const recipients = emailReceivers.map((receiver) => receiver.email); | ||
const users = await userProfile.find( | ||
{ isActive: true, endDate: { $exists: true } }, | ||
'_id isActive endDate', | ||
'_id isActive endDate isSet', | ||
); | ||
for (let i = 0; i < users.length; i += 1) { | ||
const user = users[i]; | ||
|
@@ -2079,7 +2099,7 @@ const userHelper = function () { | |
const id = user._id; | ||
const person = await userProfile.findById(id); | ||
const lastDay = moment(person.endDate).format('YYYY-MM-DD'); | ||
logger.logInfo(`User with id: ${user._id} was de-acticated at ${moment().format()}.`); | ||
logger.logInfo(`User with id: ${user._id} was de-activated at ${moment().format()}.`); | ||
person.teams.map(async (teamId) => { | ||
const managementEmails = await userHelper.getTeamManagementEmail(teamId); | ||
if (Array.isArray(managementEmails) && managementEmails.length > 0) { | ||
|
@@ -2094,6 +2114,7 @@ const userHelper = function () { | |
lastDay, | ||
person.email, | ||
recipients, | ||
person.isSet, | ||
); | ||
} | ||
} | ||
|