Skip to content

Commit 488401a

Browse files
Merge pull request #6863 from topcoder-platform/develop
Release v1.21.12 - Challenge with registration phase open is showing with status `Challenge is currently on hold`
2 parents 3a1a491 + 5188302 commit 488401a

File tree

2 files changed

+15
-5
lines changed

2 files changed

+15
-5
lines changed

src/shared/components/challenge-detail/Header/index.jsx

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ import { COMPETITION_TRACKS } from 'utils/tc';
1818
import { phaseEndDate } from 'utils/challenge-listing/helper';
1919
import {
2020
getTimeLeft,
21+
isRegistrationPhase,
2122
} from 'utils/challenge-detail/helper';
2223

2324
import LeftArrow from 'assets/images/arrow-prev.svg';
@@ -112,9 +113,12 @@ export default function ChallengeHeader(props) {
112113
registrationEnded = !regPhase.isOpen;
113114
}
114115

115-
const currentPhases = challenge.phases
116-
.filter(p => p.name !== 'Registration' && p.isOpen)
117-
.sort((a, b) => moment(a.scheduledEndDate).diff(b.scheduledEndDate))[0];
116+
const allOpenPhases = challenge.phases
117+
.filter(p => p.isOpen)
118+
.sort((a, b) => moment(a.scheduledEndDate).diff(b.scheduledEndDate));
119+
120+
const currentPhases = allOpenPhases
121+
.filter(p => !isRegistrationPhase(p))[0];
118122

119123
const trackLower = track ? track.replace(' ', '-').toLowerCase() : 'design';
120124

@@ -138,14 +142,14 @@ export default function ChallengeHeader(props) {
138142

139143
const openPhases = sortedAllPhases.filter(p => p.isOpen);
140144
let nextPhase = openPhases[0];
141-
if (hasRegistered && openPhases[0] && openPhases[0].name === 'Registration') {
145+
if (hasRegistered && openPhases[0] && isRegistrationPhase(openPhases[0])) {
142146
nextPhase = openPhases[1] || {};
143147
}
144148

145149
const deadlineEnd = moment(nextPhase && phaseEndDate(nextPhase));
146150
const currentTime = moment();
147151

148-
const timeDiff = getTimeLeft(currentPhases, 'to go', true);
152+
const timeDiff = getTimeLeft(currentPhases || allOpenPhases[0], 'to go', true);
149153

150154
if (!timeDiff.late) {
151155
timeDiff.text = timeDiff.text.replace('to go', '');

src/shared/utils/challenge-detail/helper.jsx

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,10 @@ export function getEndDate(challenge) {
4747
return moment(endPhaseDate).format('MMM DD');
4848
}
4949

50+
export function isRegistrationPhase(phase) {
51+
return phase.name === 'Registration';
52+
}
53+
5054
/**
5155
* Generates human-readable string containing time till the phase end.
5256
* @param {Object} phase phase need to check
@@ -58,11 +62,13 @@ export function getTimeLeft(
5862
fullText = false,
5963
) {
6064
const STALLED_TIME_LEFT_MSG = 'Challenge is currently on hold';
65+
const REGISTRATION_PHASE_MESSAGE = 'Open For Registration';
6166
const FF_TIME_LEFT_MSG = 'Winner is working on fixes';
6267
const HOUR_MS = 60 * 60 * 1000;
6368
const DAY_MS = 24 * HOUR_MS;
6469

6570
if (!phase) return { late: false, text: STALLED_TIME_LEFT_MSG };
71+
if (isRegistrationPhase(phase)) return { late: false, text: REGISTRATION_PHASE_MESSAGE };
6672
if (phase.phaseType === 'Final Fix') {
6773
return { late: false, text: FF_TIME_LEFT_MSG };
6874
}

0 commit comments

Comments
 (0)