-
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 #795 from OneCommunityGlobal/shengwei_add_stop_blu…
…e_sqaure_added_to_new_user Shengwei add stop blue sqaure added to new user
- Loading branch information
Showing
18 changed files
with
939 additions
and
386 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
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 |
---|---|---|
@@ -1,7 +1,12 @@ | ||
const eventtypes = { | ||
ActionCreated: 'Action Created', | ||
ActionEdited: 'Action Edited', | ||
ActionDeleted: 'Action Deleted', | ||
}; | ||
/** | ||
* Unused legacy code. Commented out to avoid confusion. | ||
* Commented by: Shengwei Peng | ||
* Date: 2024-03-22 | ||
*/ | ||
// const eventtypes = { | ||
// ActionCreated: 'Action Created', | ||
// ActionEdited: 'Action Edited', | ||
// ActionDeleted: 'Action Deleted', | ||
// }; | ||
|
||
module.exports = eventtypes; | ||
// module.exports = eventtypes; |
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 |
---|---|---|
@@ -0,0 +1,18 @@ | ||
export const URL_TO_BLUE_SQUARE_PAGE = 'https://www.onecommunityglobal.org/hands-off-administration-policy' | ||
|
||
// Since the notification banner is blue background, added white color for hyperlink style. | ||
export const NEW_USER_BLUE_SQUARE_NOTIFICATION_MESSAGE = ` | ||
<p> Welcome as one of our newest members to the One Community team and family! | ||
Heads up we’ve removed a <a href=${URL_TO_BLUE_SQUARE_PAGE}>“blue square”</a> that | ||
was issued due to not completing your hours and/or summary this past week. The reason we removed | ||
this blue square is because you didn’t have the full week available to complete your volunteer | ||
time with us. </p> | ||
<p> If you’d like to learn more about this policy and/or blue squares, click here: | ||
<a href=${URL_TO_BLUE_SQUARE_PAGE}> “Blue Square FAQ”</a> | ||
</p> | ||
<p>Welcome again, we’re glad to have you joining us! </p> | ||
<p>With Gratitude,</br>One Community </p> | ||
`; |
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 |
---|---|---|
@@ -1,126 +1,128 @@ | ||
const mongoose = require('mongoose'); | ||
const closure = require('../helpers/notificationhelper'); | ||
|
||
const actionItemController = function (ActionItem) { | ||
const notificationhelper = closure(); | ||
|
||
const getactionItem = async function (req, res) { | ||
const userid = req.params.userId; | ||
|
||
try { | ||
const actionItems = await ActionItem.find( | ||
{ | ||
assignedTo: userid, | ||
}, | ||
'-createdDateTime -__v', | ||
).populate('createdBy', 'firstName lastName'); | ||
const actionitems = []; | ||
|
||
actionItems.forEach((element) => { | ||
const actionitem = {}; | ||
|
||
actionitem._id = element._id; | ||
actionitem.description = element.description; | ||
actionitem.createdBy = `${element.createdBy.firstName} ${element.createdBy.lastName}`; | ||
actionitem.assignedTo = element.assignedTo; | ||
|
||
actionitems.push(actionitem); | ||
}); | ||
|
||
res.status(200).send(actionitems); | ||
} catch (error) { | ||
res.status(400).send(error); | ||
} | ||
}; | ||
const postactionItem = async function (req, res) { | ||
const { requestorId, assignedTo } = req.body.requestor; | ||
const _actionItem = new ActionItem(); | ||
|
||
_actionItem.description = req.body.description; | ||
_actionItem.assignedTo = req.body.assignedTo; | ||
_actionItem.createdBy = req.body.requestor.requestorId; | ||
|
||
try { | ||
const savedItem = await _actionItem.save(); | ||
notificationhelper.notificationcreated(requestorId, assignedTo, _actionItem.description); | ||
|
||
const actionitem = {}; | ||
|
||
actionitem.createdBy = 'You'; | ||
actionitem.description = _actionItem.description; | ||
actionitem._id = savedItem._id; | ||
actionitem.assignedTo = _actionItem.assignedTo; | ||
|
||
res.status(200).send(actionitem); | ||
} catch (err) { | ||
res.status(400).send(err); | ||
} | ||
}; | ||
|
||
const deleteactionItem = async function (req, res) { | ||
const actionItemId = mongoose.Types.ObjectId(req.params.actionItemId); | ||
|
||
try { | ||
const _actionItem = await ActionItem.findById(actionItemId); | ||
|
||
if (!_actionItem) { | ||
res.status(400).send({ | ||
message: 'No valid records found', | ||
}); | ||
return; | ||
} | ||
|
||
const { requestorId, assignedTo } = req.body.requestor; | ||
|
||
notificationhelper.notificationdeleted(requestorId, assignedTo, _actionItem.description); | ||
|
||
await _actionItem.remove(); | ||
res.status(200).send({ | ||
message: 'removed', | ||
}); | ||
} catch (error) { | ||
res.status(400).send(error); | ||
} | ||
}; | ||
|
||
const editactionItem = async function (req, res) { | ||
const actionItemId = mongoose.Types.ObjectId(req.params.actionItemId); | ||
|
||
const { requestorId, assignedTo } = req.body.requestor; | ||
|
||
try { | ||
const _actionItem = await ActionItem.findById(actionItemId); | ||
|
||
if (!_actionItem) { | ||
res.status(400).send({ | ||
message: 'No valid records found', | ||
}); | ||
return; | ||
} | ||
|
||
notificationhelper.notificationedited( | ||
requestorId, | ||
assignedTo, | ||
_actionItem.description, | ||
req.body.description, | ||
); | ||
|
||
_actionItem.description = req.body.description; | ||
_actionItem.assignedTo = req.body.assignedTo; | ||
|
||
await _actionItem.save(); | ||
res.status(200).send({ message: 'Saved' }); | ||
} catch (error) { | ||
res.status(400).send(error); | ||
} | ||
}; | ||
|
||
return { | ||
getactionItem, | ||
postactionItem, | ||
deleteactionItem, | ||
editactionItem, | ||
}; | ||
}; | ||
|
||
module.exports = actionItemController; | ||
/** | ||
* Unused legacy code. Commented out to avoid confusion. Will delete in the next cycle. | ||
* Commented by: Shengwei Peng | ||
* Date: 2024-03-22 | ||
*/ | ||
|
||
// const mongoose = require('mongoose'); | ||
// const notificationhelper = require('../helpers/notificationhelper')(); | ||
|
||
// const actionItemController = function (ActionItem) { | ||
// const getactionItem = function (req, res) { | ||
// const userid = req.params.userId; | ||
// ActionItem.find({ | ||
// assignedTo: userid, | ||
// }, ('-createdDateTime -__v')) | ||
// .populate('createdBy', 'firstName lastName') | ||
// .then((results) => { | ||
// const actionitems = []; | ||
|
||
// results.forEach((element) => { | ||
// const actionitem = {}; | ||
|
||
// actionitem._id = element._id; | ||
// actionitem.description = element.description; | ||
// actionitem.createdBy = `${element.createdBy.firstName} ${element.createdBy.lastName}`; | ||
// actionitem.assignedTo = element.assignedTo; | ||
|
||
// actionitems.push(actionitem); | ||
// }); | ||
|
||
// res.status(200).send(actionitems); | ||
// }) | ||
// .catch((error) => { | ||
// res.status(400).send(error); | ||
// }); | ||
// }; | ||
// const postactionItem = function (req, res) { | ||
// const { requestorId, assignedTo } = req.body.requestor; | ||
// const _actionItem = new ActionItem(); | ||
|
||
// _actionItem.description = req.body.description; | ||
// _actionItem.assignedTo = req.body.assignedTo; | ||
// _actionItem.createdBy = req.body.requestor.requestorId; | ||
|
||
// _actionItem.save() | ||
// .then((result) => { | ||
// notificationhelper.notificationcreated(requestorId, assignedTo, _actionItem.description); | ||
|
||
// const actionitem = {}; | ||
|
||
// actionitem.createdBy = 'You'; | ||
// actionitem.description = _actionItem.description; | ||
// actionitem._id = result._id; | ||
// actionitem.assignedTo = _actionItem.assignedTo; | ||
|
||
// res.status(200).send(actionitem); | ||
// }) | ||
// .catch((error) => { | ||
// res.status(400).send(error); | ||
// }); | ||
// }; | ||
|
||
// const deleteactionItem = async function (req, res) { | ||
// const actionItemId = mongoose.Types.ObjectId(req.params.actionItemId); | ||
|
||
// const _actionItem = await ActionItem.findById(actionItemId) | ||
// .catch((error) => { | ||
// res.status(400).send(error); | ||
// }); | ||
|
||
// if (!_actionItem) { | ||
// res.status(400).send({ | ||
// message: 'No valid records found', | ||
// }); | ||
// return; | ||
// } | ||
|
||
// const { requestorId, assignedTo } = req.body.requestor; | ||
|
||
// notificationhelper.notificationdeleted(requestorId, assignedTo, _actionItem.description); | ||
|
||
// _actionItem.remove() | ||
// .then(() => { | ||
// res.status(200).send({ | ||
// message: 'removed', | ||
// }); | ||
// }) | ||
// .catch((error) => { | ||
// res.status(400).send(error); | ||
// }); | ||
// }; | ||
|
||
// const editactionItem = async function (req, res) { | ||
// const actionItemId = mongoose.Types.ObjectId(req.params.actionItemId); | ||
|
||
// const { requestorId, assignedTo } = req.body.requestor; | ||
|
||
// const _actionItem = await ActionItem.findById(actionItemId) | ||
// .catch((error) => { | ||
// res.status(400).send(error); | ||
// }); | ||
|
||
// if (!_actionItem) { | ||
// res.status(400).send({ | ||
// message: 'No valid records found', | ||
// }); | ||
// return; | ||
// } | ||
// notificationhelper.notificationedited(requestorId, assignedTo, _actionItem.description, req.body.description); | ||
|
||
// _actionItem.description = req.body.description; | ||
// _actionItem.assignedTo = req.body.assignedTo; | ||
|
||
// _actionItem.save() | ||
// .then(res.status(200).send('Saved')) | ||
// .catch((error) => res.status(400).send(error)); | ||
// }; | ||
|
||
// return { | ||
// getactionItem, | ||
// postactionItem, | ||
// deleteactionItem, | ||
// editactionItem, | ||
|
||
// }; | ||
// }; | ||
|
||
// module.exports = actionItemController; |
Oops, something went wrong.