Skip to content

Commit 08fb3c3

Browse files
Added validation before call phaseEndDate and phaseStartDate
1 parent 22a2677 commit 08fb3c3

File tree

2 files changed

+5
-5
lines changed
  • src/shared
    • components/challenge-listing/Tooltips/ProgressBarTooltip
    • utils/challenge-listing

2 files changed

+5
-5
lines changed

src/shared/components/challenge-listing/Tooltips/ProgressBarTooltip/index.jsx

+3-3
Original file line numberDiff line numberDiff line change
@@ -97,9 +97,9 @@ function Tip(props) {
9797

9898
const allPhases = c.phases || [];
9999
const endPhaseDate = Math.max(...allPhases.map(d => phaseEndDate(d)));
100-
const registrationPhase = allPhases.find(phase => phase.name === 'Registration');
101-
const submissionPhase = allPhases.find(phase => phase.name === 'Submission');
102-
const checkpointPhase = allPhases.find(phase => phase.name === 'Checkpoint Submission');
100+
const registrationPhase = allPhases.find(phase => phase.name === 'Registration') || {};
101+
const submissionPhase = allPhases.find(phase => phase.name === 'Submission') || {};
102+
const checkpointPhase = allPhases.find(phase => phase.name === 'Checkpoint Submission') || {};
103103

104104
if (registrationPhase) {
105105
steps.push({

src/shared/utils/challenge-listing/sort.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -56,8 +56,8 @@ export default {
5656
const getChallengeStartDate = (challenge) => {
5757
// extract the phases from `challenge.phases`,
5858
// as `challenge.registrationStartDate` returned from API is not reliable
59-
const registrationPhase = find(challenge.phases, p => p.name === 'Registration');
60-
const submissionPhase = find(challenge.phases, p => p.name === 'Submission');
59+
const registrationPhase = find(challenge.phases, p => p.name === 'Registration') || {};
60+
const submissionPhase = find(challenge.phases, p => p.name === 'Submission') || {};
6161
// registration phase exists
6262
if (registrationPhase) {
6363
return moment(phaseStartDate(registrationPhase));

0 commit comments

Comments
 (0)