From 2bfdd6d1695ab215e08adcf635cb395343464048 Mon Sep 17 00:00:00 2001 From: Justin Gasper Date: Fri, 31 Oct 2025 06:48:34 +1100 Subject: [PATCH] Swap dates shown on challenge details page --- src/shared/utils/challenge-listing/helper.js | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/shared/utils/challenge-listing/helper.js b/src/shared/utils/challenge-listing/helper.js index 919bba5f86..7368d2e1a5 100644 --- a/src/shared/utils/challenge-listing/helper.js +++ b/src/shared/utils/challenge-listing/helper.js @@ -6,6 +6,9 @@ import moment from 'moment'; * @return {Date} */ export function phaseEndDate(phase) { + if (phase.actualEndDate) { + return new Date(phase.actualEndDate); + } // Case 1: phase is still open. take the `scheduledEndDate` // Case 2: phase is not open but `scheduledStartDate` is a future date. // This means phase is not yet started. So take the `scheduledEndDate` @@ -17,7 +20,7 @@ export function phaseEndDate(phase) { return new Date(phase.scheduledEndDate); } // for other cases, take the `actualEndDate` as phase is already closed - return new Date(phase.scheduledEndDate || phase.actualEndDate); + return new Date(phase.actualEndDate || phase.scheduledEndDate); } /** @@ -26,12 +29,15 @@ export function phaseEndDate(phase) { * @return {Date} */ export function phaseStartDate(phase) { + if (phase.actualStartDate) { + return new Date(phase.actualStartDate); + } // Case 1: Phase is not yet started. take the `scheduledStartDate` if (phase.isOpen !== true && moment(phase.scheduledStartDate).isAfter()) { return new Date(phase.scheduledStartDate); } // For all other cases, take the `actualStartDate` as phase is already started - return new Date(phase.scheduledStartDate || phase.actualStartDate); + return new Date(phase.actualStartDate || phase.scheduledStartDate); } /**