Skip to content

Commit 15eca0a

Browse files
authored
Update index.jsx
1 parent 67c1c1f commit 15eca0a

File tree

1 file changed

+3
-4
lines changed
  • src/shared/components/challenge-detail/Header

1 file changed

+3
-4
lines changed

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

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -66,12 +66,12 @@ export default function ChallengeHeader(props) {
6666
events,
6767
legacy,
6868
prizeSets,
69-
currentPhases,
7069
reliabilityBonus,
7170
userDetails,
7271
numRegistrants,
7372
numSubmissions,
7473
appealsEndDate,
74+
status,
7575
} = challenge;
7676

7777
const { track } = legacy;
@@ -80,7 +80,6 @@ export default function ChallengeHeader(props) {
8080

8181
const allPhases = challenge.phases || [];
8282
const { prizes } = prizeSets && prizeSets.length ? prizeSets[0] : [];
83-
const status = allPhases.length ? allPhases[0].name : '';
8483

8584
const checkpointPrizes = _.find(prizeSets, { type: 'checkpoint' });
8685
let numberOfCheckpointsPrizes = 0;
@@ -126,8 +125,8 @@ export default function ChallengeHeader(props) {
126125
*/
127126
const hasSubmissions = userDetails && (userDetails.submissions || []).reduce((acc, submission) => acc || submission.status !== 'Deleted', false);
128127

129-
let nextPhase = (currentPhases && currentPhases[0]) || {};
130-
if (hasRegistered && nextPhase && nextPhase.name === 'Registration') {
128+
let nextPhase = allPhases.filter(p => p.name !== 'Registration' && p.isOpen).sort((a, b) => moment(a.scheduledEndDate).diff(b.scheduledEndDate))[0];
129+
if (hasRegistered && allPhases && allPhases.name === 'Registration') {
131130
nextPhase = allPhases[1] || {};
132131
}
133132
const nextDeadline = nextPhase && nextPhase.name;

0 commit comments

Comments
 (0)