Skip to content

Commit e963eae

Browse files
committed
deadline panel fix
1 parent dd90b49 commit e963eae

File tree

2 files changed

+29
-14
lines changed

2 files changed

+29
-14
lines changed

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

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,17 @@ export default function DeadlinesPanel({ deadlines }) {
1515
start = start.actualStartDate || start.scheduledStartDate;
1616
const started = moment(start).isBefore(moment());
1717

18+
deadlines.sort((a, b) => {
19+
if (a.name.toLowerCase().includes('registration')) {
20+
return -1;
21+
}
22+
if (b.name.toLowerCase().includes('registration')) {
23+
return 1;
24+
}
25+
return (new Date(a.scheduledEndDate || a.actualEndDate)).getTime()
26+
- (new Date(b.scheduledEndDate || b.actualEndDate)).getTime();
27+
});
28+
1829
return (
1930
<div styleName="panel" tabIndex="0" role="tabpanel">
2031
<p styleName="timezone">

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

Lines changed: 18 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ export default function ChallengeHeader(props) {
3838
challenge,
3939
challengesUrl,
4040
checkpoints,
41-
hasRegistered,
41+
isRegistered,
4242
numWinners,
4343
onSelectorClicked,
4444
onToggleDeadlines,
@@ -122,13 +122,15 @@ export default function ChallengeHeader(props) {
122122
*/
123123
const hasSubmissions = !_.isEmpty(mySubmissions);
124124

125-
let nextPhase = allPhases.filter(p => p.isOpen)
126-
.sort((a, b) => moment(a.scheduledEndDate).diff(b.scheduledEndDate))[0];
127-
if (hasRegistered && allPhases[0] && allPhases[0].name === 'Registration') {
125+
const nextPhaseArray = allPhases.filter(p => p.isOpen)
126+
.sort((a, b) => moment(b.scheduledEndDate).diff(a.scheduledEndDate));
127+
let nextPhase = nextPhaseArray[0];
128+
if (isRegistered && allPhases[0] && allPhases[0].name === 'Registration') {
128129
nextPhase = allPhases[1] || {};
129130
}
130-
const nextDeadline = nextPhase && nextPhase.name;
131-
131+
if (!isRegistered && nextPhase.name === 'Submission' && type === 'First2Finish') {
132+
nextPhase = nextPhaseArray[1] || {};
133+
}
132134
const deadlineEnd = moment(nextPhase && nextPhase.scheduledEndDate);
133135
const currentTime = moment();
134136

@@ -182,23 +184,25 @@ export default function ChallengeHeader(props) {
182184
scheduledEndDate: endPhaseDate,
183185
});
184186
} else if (relevantPhases.length > 1) {
185-
const lastPhase = relevantPhases[relevantPhases.length - 1];
187+
const lastPhase = allPhases[allPhases.length - 1];
186188
const lastPhaseTime = (
187189
new Date(lastPhase.actualEndDate || lastPhase.scheduledEndDate)
188190
).getTime();
191+
const challengeName = lastPhase.name === 'Iterative Review' ? lastPhase.name : 'Winners';
189192

190193
const appealsEnd = (new Date(appealsEndDate).getTime());
191-
if (lastPhaseTime < appealsEnd && lastPhase.name !== 'Review') {
194+
if (lastPhaseTime < appealsEnd && lastPhase.name !== 'Review' && lastPhase.name !== 'Approval') {
192195
relevantPhases.push({
193196
id: -1,
194-
name: 'Winners',
197+
name: challengeName,
195198
scheduledEndDate: appealsEndDate,
196199
});
197200
}
198201
}
199202
}
200203

201204
const checkpointCount = checkpoints && checkpoints.numberOfUniqueSubmitters;
205+
const nextDeadline = nextPhase && nextPhase.name;
202206

203207
let nextDeadlineMsg;
204208
switch ((status || '').toLowerCase()) {
@@ -358,7 +362,7 @@ export default function ChallengeHeader(props) {
358362
</div>
359363
<div styleName="challenge-ops-wrapper">
360364
<div styleName="challenge-ops-container">
361-
{hasRegistered ? (
365+
{isRegistered ? (
362366
<DangerButton
363367
disabled={unregistering || registrationEnded
364368
|| hasSubmissions || isLegacyMM}
@@ -379,14 +383,14 @@ export default function ChallengeHeader(props) {
379383
</PrimaryButton>
380384
)}
381385
<PrimaryButton
382-
disabled={!hasRegistered || unregistering || submissionEnded || isLegacyMM}
386+
disabled={!isRegistered || unregistering || submissionEnded || isLegacyMM}
383387
theme={{ button: style.challengeAction }}
384388
to={`${challengesUrl}/${challengeId}/submit`}
385389
>
386390
Submit
387391
</PrimaryButton>
388392
{
389-
track === COMPETITION_TRACKS.DESIGN && hasRegistered && !unregistering
393+
track === COMPETITION_TRACKS.DESIGN && isRegistered && !unregistering
390394
&& hasSubmissions && (
391395
<PrimaryButton
392396
theme={{ button: style.challengeAction }}
@@ -456,7 +460,7 @@ export default function ChallengeHeader(props) {
456460
hasCheckpoints={checkpoints && checkpoints.length > 0}
457461
numOfSubmissions={numOfSubmissions}
458462
numOfCheckpointSubmissions={numOfCheckpointSubmissions}
459-
hasRegistered={hasRegistered}
463+
hasRegistered={isRegistered}
460464
checkpointCount={checkpointCount}
461465
mySubmissions={mySubmissions}
462466
/>
@@ -501,7 +505,7 @@ ChallengeHeader.propTypes = {
501505
prizeSets: PT.any,
502506
}).isRequired,
503507
challengesUrl: PT.string.isRequired,
504-
hasRegistered: PT.bool.isRequired,
508+
isRegistered: PT.bool.isRequired,
505509
hasThriveArticles: PT.bool,
506510
hasRecommendedChallenges: PT.bool,
507511
submissionEnded: PT.bool.isRequired,

0 commit comments

Comments
 (0)