Skip to content

Commit ed1f7d1

Browse files
close registration, submission, checkpoint submission after cancellation
1 parent 585c6fd commit ed1f7d1

File tree

2 files changed

+32
-2
lines changed

2 files changed

+32
-2
lines changed

src/common/phase-helper.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -170,6 +170,17 @@ class ChallengePhaseHelper {
170170
return updatedPhases;
171171
}
172172

173+
handlePhasesAfterCancelling(phases) {
174+
return _.map(phases, (phase) => {
175+
if (_.includes(["Registration", "Submission", "Checkpoint Submission"], phase.name)) {
176+
phase.isOpen = false;
177+
if (!_.isUndefined(phase.actualStartDate)) {
178+
phase.actualEndDate = moment().toDate().toISOString();
179+
}
180+
}
181+
});
182+
}
183+
173184
async validatePhases(phases) {
174185
if (!phases || phases.length === 0) {
175186
return;

src/services/ChallengeService.js

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1594,6 +1594,7 @@ async function updateChallenge(currentUser, challengeId, data) {
15941594
/* END self-service stuffs */
15951595

15961596
let isChallengeBeingActivated = false;
1597+
let isChallengeBeingCancelled = false;
15971598
if (data.status) {
15981599
if (data.status === constants.challengeStatuses.Active) {
15991600
if (
@@ -1619,6 +1620,20 @@ async function updateChallenge(currentUser, challengeId, data) {
16191620
}
16201621
}
16211622

1623+
if (_.includes([
1624+
constants.challengeStatuses.Cancelled,
1625+
constants.challengeStatuses.CancelledRequirementsInfeasible,
1626+
constants.challengeStatuses.CancelledPaymentFailed,
1627+
constants.challengeStatuses.CancelledFailedReview,
1628+
constants.challengeStatuses.CancelledFailedScreening,
1629+
constants.challengeStatuses.CancelledZeroSubmissions,
1630+
constants.challengeStatuses.CancelledWinnerUnresponsive,
1631+
constants.challengeStatuses.CancelledClientRequest,
1632+
constants.challengeStatuses.CancelledZeroRegistrations,
1633+
], data.status)) {
1634+
isChallengeBeingCancelled = true;
1635+
}
1636+
16221637
if (
16231638
data.status === constants.challengeStatuses.CancelledRequirementsInfeasible ||
16241639
data.status === constants.challengeStatuses.CancelledPaymentFailed
@@ -1723,9 +1738,9 @@ async function updateChallenge(currentUser, challengeId, data) {
17231738

17241739
let phasesUpdated = false;
17251740
if (
1726-
(data.phases && data.phases.length > 0) ||
1741+
((data.phases && data.phases.length > 0) ||
17271742
isChallengeBeingActivated ||
1728-
timelineTemplateChanged
1743+
timelineTemplateChanged) && !isChallengeBeingCancelled
17291744
) {
17301745
if (
17311746
challenge.status === constants.challengeStatuses.Completed ||
@@ -1754,6 +1769,10 @@ async function updateChallenge(currentUser, challengeId, data) {
17541769
phasesUpdated = true;
17551770
data.phases = newPhases;
17561771
}
1772+
if (isChallengeBeingCancelled) {
1773+
data.phases = await phaseHelper.handlePhasesAfterCancelling(challenge.phases);
1774+
phasesUpdated = true;
1775+
}
17571776
if (phasesUpdated || data.startDate) {
17581777
data.startDate = convertToISOString(_.min(_.map(data.phases, "scheduledStartDate")));
17591778
}

0 commit comments

Comments
 (0)