Skip to content

Commit 24fd428

Browse files
committed
fix: status message in challenge details page
1 parent 818442c commit 24fd428

File tree

2 files changed

+24
-27
lines changed

2 files changed

+24
-27
lines changed

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

Lines changed: 24 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,9 @@ import { PrimaryButton } from 'topcoder-react-ui-kit';
1717
import { Link } from 'topcoder-react-utils';
1818
import { COMPETITION_TRACKS } from 'utils/tc';
1919
import { phaseEndDate } from 'utils/challenge-listing/helper';
20+
import {
21+
getTimeLeft,
22+
} from 'utils/challenge-detail/helper';
2023

2124
import LeftArrow from 'assets/images/arrow-prev.svg';
2225

@@ -112,6 +115,10 @@ export default function ChallengeHeader(props) {
112115
registrationEnded = !regPhase.isOpen;
113116
}
114117

118+
const currentPhases = challenge.phases
119+
.filter(p => p.name !== 'Registration' && p.isOpen)
120+
.sort((a, b) => moment(a.scheduledEndDate).diff(b.scheduledEndDate))[0];
121+
115122
const trackLower = track ? track.replace(' ', '-').toLowerCase() : 'design';
116123

117124
const eventNames = (events || []).map((event => (event.eventName || '').toUpperCase()));
@@ -137,11 +144,16 @@ export default function ChallengeHeader(props) {
137144
if (hasRegistered && openPhases[0] && openPhases[0].name === 'Registration') {
138145
nextPhase = openPhases[1] || {};
139146
}
140-
const nextDeadline = nextPhase && nextPhase.name;
141147

142148
const deadlineEnd = moment(nextPhase && phaseEndDate(nextPhase));
143149
const currentTime = moment();
144150

151+
const timeDiff = getTimeLeft(currentPhases, 'to go');
152+
153+
if (!timeDiff.late) {
154+
timeDiff.text = timeDiff.text.replace('to go', '');
155+
}
156+
145157
let timeLeft = deadlineEnd.isAfter(currentTime)
146158
? deadlineEnd.diff(currentTime) : 0;
147159

@@ -228,19 +240,6 @@ export default function ChallengeHeader(props) {
228240

229241
let nextDeadlineMsg;
230242
switch ((status || '').toLowerCase()) {
231-
case 'active':
232-
nextDeadlineMsg = (
233-
<div styleName="next-deadline">
234-
Next Deadline:
235-
{' '}
236-
{
237-
<span styleName="deadline-highlighted">
238-
{nextDeadline || '-'}
239-
</span>
240-
}
241-
</div>
242-
);
243-
break;
244243
case 'completed':
245244
nextDeadlineMsg = (
246245
<div styleName="completed">
@@ -249,15 +248,15 @@ export default function ChallengeHeader(props) {
249248
);
250249
break;
251250
default:
252-
nextDeadlineMsg = (
253-
<div>
254-
Status:
255-
&zwnj;
256-
<span styleName="deadline-highlighted">
257-
{_.upperFirst(_.lowerCase(status))}
258-
</span>
259-
</div>
260-
);
251+
// nextDeadlineMsg = (
252+
// <div>
253+
// Status:
254+
// &zwnj;
255+
// <span styleName="deadline-highlighted">
256+
// {_.upperFirst(_.lowerCase(status))}
257+
// </span>
258+
// </div>
259+
// );
261260
break;
262261
}
263262

@@ -446,9 +445,9 @@ export default function ChallengeHeader(props) {
446445
(status || '').toLowerCase() === 'active'
447446
&& (
448447
<div styleName="current-phase">
449-
Current Deadline Ends:{' '}
448+
{currentPhases && `${currentPhases.name} Ends: `}
450449
<span styleName="deadline-highlighted">
451-
{timeLeft}
450+
{timeDiff.text}
452451
</span>
453452
</div>
454453
)
@@ -532,7 +531,6 @@ ChallengeHeader.propTypes = {
532531
timelineTemplateId: PT.string,
533532
reliabilityBonus: PT.any,
534533
userDetails: PT.any,
535-
currentPhases: PT.any,
536534
numOfRegistrants: PT.any,
537535
numOfCheckpointSubmissions: PT.any,
538536
numOfSubmissions: PT.any,

src/shared/components/challenge-detail/Header/style.scss

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -602,7 +602,6 @@
602602

603603
.current-phase {
604604
overflow-wrap: normal;
605-
padding-left: 10px;
606605

607606
@include xs-to-md {
608607
padding-left: 0;

0 commit comments

Comments
 (0)