Skip to content

Commit

Permalink
Merge pull request #1098 from OneCommunityGlobal/Ivy-hotfix-isSet-Ina…
Browse files Browse the repository at this point in the history
…ctive

Ivy-hotfix-isSet-inactive
  • Loading branch information
one-community authored Sep 12, 2024
2 parents d43239c + 2f0d949 commit bdd1940
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions src/controllers/userProfileController.js
Original file line number Diff line number Diff line change
Expand Up @@ -1170,7 +1170,15 @@ const userProfileController = function (UserProfile, Project) {
const activationDate = req.body.reactivationDate;
const { endDate } = req.body;
const isSet = req.body.isSet === 'FinalDay';

let activeStatus = status;
if (endDate && status) {
const dateObject = new Date(endDate);
dateObject.setHours(dateObject.getHours() + 7);
const setEndDate = dateObject;
if (moment().isAfter(moment(setEndDate).add(1, 'days'))) {
activeStatus = false;
}
}
if (!mongoose.Types.ObjectId.isValid(userId)) {
res.status(400).send({
error: 'Bad Request',
Expand Down Expand Up @@ -1219,7 +1227,7 @@ const userProfileController = function (UserProfile, Project) {
UserProfile.findById(userId, 'isActive email firstName lastName')
.then((user) => {
user.set({
isActive: status,
isActive: activeStatus,
reactivationDate: activationDate,
endDate,
isSet,
Expand Down

0 comments on commit bdd1940

Please sign in to comment.