Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 8 additions & 10 deletions src/utils/challenge/filter.js
Original file line number Diff line number Diff line change
Expand Up @@ -111,20 +111,18 @@ function filterByReviewOpportunityType(opp, state) {

function filterByStartDate(challenge, state) {
if (!state.startDate) return true;
const submissionPhase = challenge.phases.filter(d => d.name === 'Submission')[0];
if (submissionPhase) {
return moment(state.startDate).isBefore(submissionPhase.scheduledEndDate);
}
return false;
const submissionPhase = (challenge.phases || []).filter(d => d.name === 'Submission')[0];
const submissionEndDate = submissionPhase ? submissionPhase.scheduledEndDate
: challenge.submissionEndDate;
return moment(state.startDate).isBefore(submissionEndDate);
}

function filterByEndDate(challenge, state) {
if (!state.endDate) return true;
const registrationPhase = challenge.phases.filter(d => d.name === 'Registration')[0];
if (registrationPhase) {
return moment(state.endDate).isAfter(registrationPhase.scheduledStartDate);
}
return false;
const registrationPhase = (challenge.phases || []).filter(d => d.name === 'Registration')[0];
const registrationStartDate = registrationPhase ? registrationPhase.scheduledStartDate
: challenge.registrationStartDate;
return moment(state.endDate).isAfter(registrationStartDate);
}

function filterByStarted(challenge, state) {
Expand Down