diff --git a/src/shared/components/challenge-detail/Header/index.jsx b/src/shared/components/challenge-detail/Header/index.jsx index b5dcf32b33..feaedb67c9 100644 --- a/src/shared/components/challenge-detail/Header/index.jsx +++ b/src/shared/components/challenge-detail/Header/index.jsx @@ -71,6 +71,7 @@ export default function ChallengeHeader(props) { numRegistrants, numSubmissions, appealsEndDate, + status, } = challenge; const { track } = legacy; @@ -79,7 +80,6 @@ export default function ChallengeHeader(props) { const allPhases = challenge.phases || []; const { prizes } = prizeSets && prizeSets.length ? prizeSets[0] : []; - const status = allPhases.length ? allPhases[0].name : ''; const checkpointPrizes = _.find(prizeSets, { type: 'checkpoint' }); let numberOfCheckpointsPrizes = 0; @@ -125,8 +125,8 @@ export default function ChallengeHeader(props) { */ const hasSubmissions = userDetails && (userDetails.submissions || []).reduce((acc, submission) => acc || submission.status !== 'Deleted', false); - let nextPhase = (allPhases && allPhases[0]) || {}; - if (hasRegistered && nextPhase && nextPhase.name === 'Registration') { + let nextPhase = allPhases.filter(p => p.name !== 'Registration' && p.isOpen).sort((a, b) => moment(a.scheduledEndDate).diff(b.scheduledEndDate))[0]; + if (hasRegistered && allPhases[0] && allPhases[0].name === 'Registration') { nextPhase = allPhases[1] || {}; } const nextDeadline = nextPhase && nextPhase.name;