Skip to content

Commit 2d453ae

Browse files
authored
Merge pull request #168 from simranb86/issue_4409
fix for issue #4409
2 parents 9e176f1 + 97ed3f6 commit 2d453ae

File tree

1 file changed

+8
-10
lines changed

1 file changed

+8
-10
lines changed

src/utils/challenge/filter.js

+8-10
Original file line numberDiff line numberDiff line change
@@ -111,20 +111,18 @@ function filterByReviewOpportunityType(opp, state) {
111111

112112
function filterByStartDate(challenge, state) {
113113
if (!state.startDate) return true;
114-
const submissionPhase = challenge.phases.filter(d => d.name === 'Submission')[0];
115-
if (submissionPhase) {
116-
return moment(state.startDate).isBefore(submissionPhase.scheduledEndDate);
117-
}
118-
return false;
114+
const submissionPhase = (challenge.phases || []).filter(d => d.name === 'Submission')[0];
115+
const submissionEndDate = submissionPhase ? submissionPhase.scheduledEndDate
116+
: challenge.submissionEndDate;
117+
return moment(state.startDate).isBefore(submissionEndDate);
119118
}
120119

121120
function filterByEndDate(challenge, state) {
122121
if (!state.endDate) return true;
123-
const registrationPhase = challenge.phases.filter(d => d.name === 'Registration')[0];
124-
if (registrationPhase) {
125-
return moment(state.endDate).isAfter(registrationPhase.scheduledStartDate);
126-
}
127-
return false;
122+
const registrationPhase = (challenge.phases || []).filter(d => d.name === 'Registration')[0];
123+
const registrationStartDate = registrationPhase ? registrationPhase.scheduledStartDate
124+
: challenge.registrationStartDate;
125+
return moment(state.endDate).isAfter(registrationStartDate);
128126
}
129127

130128
function filterByStarted(challenge, state) {

0 commit comments

Comments
 (0)