Skip to content

Commit 6579001

Browse files
committed
filter update
1 parent 06d7a2c commit 6579001

File tree

2 files changed

+11
-8
lines changed

2 files changed

+11
-8
lines changed

src/services/challenges.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,8 @@ class ChallengesService {
174174
filter,
175175
) => {
176176
let res = {};
177-
if (_.some(filter.frontFilter.tracks, val => val)) {
177+
if (_.some(filter.frontFilter.tracks, val => val)
178+
&& !_.isEqual(filter.frontFilter.types, [])) {
178179
const query = getFilterUrl(filter.backendFilter, filter.frontFilter);
179180
const url = `${endpoint}?${query}`;
180181
res = await this.private.apiV5.get(url).then(checkErrorV5);

src/utils/challenge/filter.js

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -106,8 +106,8 @@ function filterByRegistrationOpen(challenge, state) {
106106
* @return {Boolean} True if opp satifies the filter
107107
*/
108108
function filterByReviewOpportunityType(opp, state) {
109-
if (!state.reviewOpportunityType) return true;
110-
return opp.type === state.reviewOpportunityType;
109+
if (state.reviewOpportunityTypes.length === 0) return false;
110+
return state.reviewOpportunityTypes.includes(opp.type);
111111
}
112112

113113
function filterByStartDate(challenge, state) {
@@ -447,14 +447,16 @@ export function setEndDate(state, date) {
447447
/**
448448
* Clones the state and sets the review opportunity type.
449449
* @param {Object} state
450-
* @param {Array} reviewOpportunityType Possible values found in utils/tc REVIEW_OPPORTUNITY_TYPES
450+
* @param {Array} reviewOpportunityTypes Possible values found in utils/tc REVIEW_OPPORTUNITY_TYPES
451451
* @return {Object}
452452
*/
453-
export function setReviewOpportunityType(state, reviewOpportunityType) {
454-
if (reviewOpportunityType) return { ...state, reviewOpportunityType };
455-
if (!state.reviewOpportunityType) return state;
453+
export function setReviewOpportunityType(state, reviewOpportunityTypes) {
454+
if (reviewOpportunityTypes && reviewOpportunityTypes.length) {
455+
return { ...state, reviewOpportunityTypes };
456+
}
457+
if (!state.reviewOpportunityTypes) return state;
456458
const res = _.clone(state);
457-
delete res.reviewOpportunityType;
459+
delete res.reviewOpportunityTypes;
458460
return res;
459461
}
460462

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy