Skip to content

Commit 71a7ac1

Browse files
authored
Merge pull request #7127 from topcoder-platform/PM-2525
PM-2525 Swap dates shown on challenge details page
2 parents 49bf7d1 + 2bfdd6d commit 71a7ac1

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

src/shared/utils/challenge-listing/helper.js

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@ import moment from 'moment';
66
* @return {Date}
77
*/
88
export function phaseEndDate(phase) {
9+
if (phase.actualEndDate) {
10+
return new Date(phase.actualEndDate);
11+
}
912
// Case 1: phase is still open. take the `scheduledEndDate`
1013
// Case 2: phase is not open but `scheduledStartDate` is a future date.
1114
// This means phase is not yet started. So take the `scheduledEndDate`
@@ -17,7 +20,7 @@ export function phaseEndDate(phase) {
1720
return new Date(phase.scheduledEndDate);
1821
}
1922
// for other cases, take the `actualEndDate` as phase is already closed
20-
return new Date(phase.scheduledEndDate || phase.actualEndDate);
23+
return new Date(phase.actualEndDate || phase.scheduledEndDate);
2124
}
2225

2326
/**
@@ -26,12 +29,15 @@ export function phaseEndDate(phase) {
2629
* @return {Date}
2730
*/
2831
export function phaseStartDate(phase) {
32+
if (phase.actualStartDate) {
33+
return new Date(phase.actualStartDate);
34+
}
2935
// Case 1: Phase is not yet started. take the `scheduledStartDate`
3036
if (phase.isOpen !== true && moment(phase.scheduledStartDate).isAfter()) {
3137
return new Date(phase.scheduledStartDate);
3238
}
3339
// For all other cases, take the `actualStartDate` as phase is already started
34-
return new Date(phase.scheduledStartDate || phase.actualStartDate);
40+
return new Date(phase.actualStartDate || phase.scheduledStartDate);
3541
}
3642

3743
/**

0 commit comments

Comments
 (0)