)
}
@@ -699,6 +701,7 @@ ChallengeDetailPageContainer.propTypes = {
// expandTag: PT.func.isRequired,
// loadingRecommendedChallengesUUID: PT.string.isRequired,
history: PT.shape().isRequired,
+ openForRegistrationChallenges: PT.shape().isRequired,
};
function mapStateToProps(state, props) {
@@ -808,6 +811,7 @@ function mapStateToProps(state, props) {
allCountries: state.lookup.allCountries,
mySubmissions,
reviewTypes,
+ openForRegistrationChallenges: state.challengeListing.openForRegistrationChallenges,
};
}
diff --git a/src/shared/containers/challenge-listing/FilterPanel.jsx b/src/shared/containers/challenge-listing/FilterPanel.jsx
index 1a05dbbc9d..5f5f2522ac 100644
--- a/src/shared/containers/challenge-listing/FilterPanel.jsx
+++ b/src/shared/containers/challenge-listing/FilterPanel.jsx
@@ -5,6 +5,7 @@
import actions from 'actions/challenge-listing/filter-panel';
import challengeListingActions from 'actions/challenge-listing';
import communityActions from 'actions/tc-communities';
+import sidebarActions from 'actions/challenge-listing/sidebar';
import shortId from 'shortid';
import FilterPanel from 'components/challenge-listing/Filters/FiltersPanel';
import PT from 'prop-types';
@@ -102,7 +103,7 @@ export class Container extends React.Component {
if (!filterState.types.length && validTypes.length && !this.initialDefaultChallengeTypes) {
setFilterState({
..._.clone(filterState),
- types: validTypes.map(item => item.abbreviation).filter(item => item !== 'REC'),
+ types: validTypes.map(item => item.abbreviation),
});
this.initialDefaultChallengeTypes = true;
}
@@ -122,6 +123,7 @@ export class Container extends React.Component {
hidden,
onClose,
setSort,
+ selectBucket,
} = this.props;
const communityFilters2 = [
{
@@ -148,6 +150,7 @@ export class Container extends React.Component {
hidden={hidden}
onClose={onClose}
setSort={setSort}
+ selectBucket={selectBucket}
/>
);
@@ -193,11 +196,13 @@ Container.propTypes = {
validTypes: PT.arrayOf(PT.shape()).isRequired,
setSearchText: PT.func.isRequired,
setSort: PT.func.isRequired,
+ selectBucket: PT.func.isRequired,
};
function mapDispatchToProps(dispatch) {
const a = actions.challengeListing.filterPanel;
const cla = challengeListingActions.challengeListing;
+ const sa = sidebarActions.challengeListing.sidebar;
return {
...bindActionCreators(a, dispatch),
getTypes: () => {
@@ -217,6 +222,7 @@ function mapDispatchToProps(dispatch) {
setFilterState: s => dispatch(cla.setFilter(s)),
onClose: () => dispatch(a.setExpanded(false)),
setSort: (bucket, sort) => dispatch(cla.setSort(bucket, sort)),
+ selectBucket: (bucket, expanding) => dispatch(sa.selectBucket(bucket, expanding)),
};
}
diff --git a/src/shared/containers/challenge-listing/Listing/index.jsx b/src/shared/containers/challenge-listing/Listing/index.jsx
index a511987240..05e67311ec 100644
--- a/src/shared/containers/challenge-listing/Listing/index.jsx
+++ b/src/shared/containers/challenge-listing/Listing/index.jsx
@@ -25,7 +25,7 @@ import filterPanelActions from 'actions/challenge-listing/filter-panel';
import communityActions from 'actions/tc-communities';
// import SORT from 'utils/challenge-listing/sort';
import {
- BUCKETS, filterChanged, sortChangedBucket, isRecommendedChallengeType,
+ BUCKETS, filterChanged, sortChangedBucket,
} from 'utils/challenge-listing/buckets';
import MetaTags from 'components/MetaTags';
import { USER_GROUP_MAXAGE } from 'config';
@@ -109,18 +109,19 @@ export class ListingContainer extends React.Component {
dropMyPastChallenges,
getMyPastChallenges,
dropAllChallenges,
- dropRecommendedChallenges,
getAllChallenges,
getOpenForRegistrationChallenges,
- getRecommendedChallenges,
getActiveChallenges,
dropActiveChallenges,
dropOpenForRegistrationChallenges,
dropPastChallenges,
getPastChallenges,
+ filterState,
} = this.props;
const oldUserId = _.get(prevProps, 'auth.user.userId');
const userId = _.get(this.props, 'auth.user.userId');
+ const handle = _.get(auth, 'user.handle');
+
if (userId !== oldUserId) {
getCommunitiesList(auth);
}
@@ -139,12 +140,18 @@ export class ListingContainer extends React.Component {
// const f = this.getBackendFilter();
// getRestActiveChallenges(auth.tokenV3, f.back);
// }
- const bucket = sortChangedBucket(sorts, prevProps.sorts);
+ let bucket = sortChangedBucket(sorts, prevProps.sorts);
const f = this.getBackendFilter();
+
const fA = {
back: { ..._.clone(f.back), startDateEnd: null, endDateStart: null },
front: { ..._.clone(f.front), startDateEnd: null, endDateStart: null },
};
+
+ if (prevProps.filterState.recommended !== filterState.recommended && filterState.recommended) {
+ bucket = 'openForRegistration';
+ }
+
if (bucket) {
switch (bucket) {
case BUCKETS.MY: {
@@ -168,23 +175,15 @@ export class ListingContainer extends React.Component {
break;
}
case BUCKETS.OPEN_FOR_REGISTRATION: {
- if (isRecommendedChallengeType(bucket, filter)) {
- dropRecommendedChallenges();
- getRecommendedChallenges(
- 0,
- sorts,
- auth.tokenV3,
- filter,
- );
- } else {
- dropOpenForRegistrationChallenges();
- getOpenForRegistrationChallenges(
- 0,
- fA.back,
- auth.tokenV3,
- fA.front,
- );
- }
+ dropOpenForRegistrationChallenges();
+ getOpenForRegistrationChallenges(
+ 0,
+ fA.back,
+ auth.tokenV3,
+ fA.front,
+ filterState.recommended,
+ handle,
+ );
break;
}
case BUCKETS.ONGOING: {
@@ -234,11 +233,7 @@ export class ListingContainer extends React.Component {
return;
}
if (filterChanged(filter, prevProps.filter)) {
- if (filter.types.includes('REC')) {
- this.reloadRecommendedChallenges();
- } else {
- this.reloadChallenges();
- }
+ this.reloadChallenges();
}
setTimeout(() => {
selectBucketDone();
@@ -292,32 +287,12 @@ export class ListingContainer extends React.Component {
};
}
- reloadRecommendedChallenges() {
- const {
- sorts,
- auth,
- filter,
- dropOpenForRegistrationChallenges,
- getRecommendedChallenges,
- } = this.props;
-
- dropOpenForRegistrationChallenges();
- getRecommendedChallenges(
- 0,
- sorts,
- auth.tokenV3,
- filter,
- );
- }
-
loadChallenges() {
const {
auth,
// DISABLED: Until api receive fix community-app#5073
// getActiveChallenges,
getOpenForRegistrationChallenges,
- getRecommendedChallenges,
- allRecommendedChallengesLoaded,
getMyChallenges,
getMyPastChallenges,
getAllChallenges,
@@ -328,8 +303,11 @@ export class ListingContainer extends React.Component {
// lastRequestedPageOfPastChallenges,
// getUserChallenges,
getTotalChallengesCount,
+ filterState,
} = this.props;
const f = this.getBackendFilter();
+ const handle = _.get(auth, 'user.handle');
+
getAllChallenges(
0,
f.back,
@@ -350,6 +328,8 @@ export class ListingContainer extends React.Component {
f.back,
auth.tokenV3,
f.front,
+ filterState.recommended,
+ handle,
);
// Only retrieve my challenge only when user has login
@@ -366,14 +346,6 @@ export class ListingContainer extends React.Component {
auth.tokenV3,
f.front,
);
- if (!allRecommendedChallengesLoaded) {
- getRecommendedChallenges(
- 0,
- f.back,
- auth.tokenV3,
- f.front,
- );
- }
}
getPastChallenges(
0,
@@ -466,7 +438,6 @@ export class ListingContainer extends React.Component {
lastRequestedPageOfMyChallenges,
lastRequestedPageOfMyPastChallenges,
lastRequestedPageOfAllChallenges,
- lastRequestedPageOfRecommendedChallenges,
lastRequestedPageOfActiveChallenges,
lastRequestedPageOfOpenForRegistrationChallenges,
lastRequestedPageOfPastChallenges,
@@ -477,7 +448,6 @@ export class ListingContainer extends React.Component {
loadingMyChallengesUUID,
loadingMyPastChallengesUUID,
loadingAllChallengesUUID,
- loadingRecommendedChallengesUUID,
loadingPastChallengesUUID,
loadingReviewOpportunitiesUUID,
listingOnly,
@@ -497,9 +467,11 @@ export class ListingContainer extends React.Component {
// userChallenges,
meta,
setSearchText,
+ filterState,
} = this.props;
const { tokenV3 } = auth;
+ const handle = _.get(auth, 'user.handle');
const isLoggedIn = !_.isEmpty(auth.tokenV3);
@@ -540,6 +512,8 @@ export class ListingContainer extends React.Component {
f.back,
tokenV3,
f.front,
+ filterState.recommended,
+ handle,
);
};
@@ -563,16 +537,6 @@ export class ListingContainer extends React.Component {
);
};
- const loadMoreRecommended = () => {
- const f = this.getBackendFilter();
- getAllChallenges(
- 1 + lastRequestedPageOfRecommendedChallenges,
- f.back,
- tokenV3,
- f.front,
- );
- };
-
let loadMoreReviewOpportunities;
if (!allReviewOpportunitiesLoaded) {
loadMoreReviewOpportunities = () => getReviewOpportunities(
@@ -640,7 +604,6 @@ export class ListingContainer extends React.Component {
loadingMyChallenges={Boolean(loadingMyChallengesUUID)}
loadingMyPastChallenges={Boolean(loadingMyPastChallengesUUID)}
loadingAllChallenges={Boolean(loadingAllChallengesUUID)}
- loadingRecommendedChallenges={Boolean(loadingRecommendedChallengesUUID)}
loadingOpenForRegistrationChallenges={Boolean(loadingOpenForRegistrationChallengesUUID)}
loadingOnGoingChallenges={Boolean(loadingActiveChallengesUUID)}
// eslint-disable-next-line max-len
@@ -659,7 +622,6 @@ export class ListingContainer extends React.Component {
loadMoreMy={loadMoreMy}
loadMoreMyPast={loadMoreMyPast}
loadMoreAll={loadMoreAll}
- loadMoreRecommended={loadMoreRecommended}
loadMoreOpenForRegistration={loadMoreOpenForRegistration}
loadMoreOnGoing={loadMoreOnGoing}
reviewOpportunities={reviewOpportunities}
@@ -720,7 +682,6 @@ ListingContainer.propTypes = {
// allActiveChallengesLoaded: PT.bool.isRequired,
// allPastChallengesLoaded: PT.bool.isRequired,
allReviewOpportunitiesLoaded: PT.bool.isRequired,
- allRecommendedChallengesLoaded: PT.bool.isRequired,
ChallengeListingBanner: PT.node,
challenges: PT.arrayOf(PT.shape({})).isRequired, // active challenges.
openForRegistrationChallenges: PT.arrayOf(PT.shape({})).isRequired,
@@ -744,7 +705,6 @@ ListingContainer.propTypes = {
dropMyChallenges: PT.func.isRequired,
dropMyPastChallenges: PT.func.isRequired,
dropAllChallenges: PT.func.isRequired,
- dropRecommendedChallenges: PT.func.isRequired,
dropOpenForRegistrationChallenges: PT.func.isRequired,
dropActiveChallenges: PT.func.isRequired,
dropPastChallenges: PT.func.isRequired,
@@ -757,7 +717,6 @@ ListingContainer.propTypes = {
// extraBucket: PT.string,
getActiveChallenges: PT.func.isRequired,
getOpenForRegistrationChallenges: PT.func.isRequired,
- getRecommendedChallenges: PT.func.isRequired,
getMyChallenges: PT.func.isRequired,
getMyPastChallenges: PT.func.isRequired,
getAllChallenges: PT.func.isRequired,
@@ -771,7 +730,6 @@ ListingContainer.propTypes = {
lastRequestedPageOfMyChallenges: PT.number.isRequired,
lastRequestedPageOfMyPastChallenges: PT.number.isRequired,
lastRequestedPageOfAllChallenges: PT.number.isRequired,
- lastRequestedPageOfRecommendedChallenges: PT.number.isRequired,
lastRequestedPageOfPastChallenges: PT.number.isRequired,
lastRequestedPageOfReviewOpportunities: PT.number.isRequired,
// lastUpdateOfActiveChallenges: PT.number.isRequired,
@@ -780,7 +738,6 @@ ListingContainer.propTypes = {
loadingMyChallengesUUID: PT.string.isRequired,
loadingMyPastChallengesUUID: PT.string.isRequired,
loadingAllChallengesUUID: PT.string.isRequired,
- loadingRecommendedChallengesUUID: PT.string.isRequired,
loadingPastChallengesUUID: PT.string.isRequired,
loadingReviewOpportunitiesUUID: PT.string.isRequired,
markHeaderMenu: PT.func.isRequired,
@@ -810,6 +767,7 @@ ListingContainer.propTypes = {
// userChallenges: PT.arrayOf(PT.string),
// getUserChallenges: PT.func.isRequired,
setSearchText: PT.func.isRequired,
+ filterState: PT.shape().isRequired,
};
const mapStateToProps = (state, ownProps) => {
@@ -822,7 +780,6 @@ const mapStateToProps = (state, ownProps) => {
auth: state.auth,
// allActiveChallengesLoaded: cl.allActiveChallengesLoaded,
allPastChallengesLoaded: cl.allPastChallengesLoaded,
- allRecommendedChallengesLoaded: cl.allRecommendedChallengesLoaded,
allReviewOpportunitiesLoaded: cl.allReviewOpportunitiesLoaded,
filter: cl.filter,
challenges: cl.challenges,
@@ -845,7 +802,6 @@ const mapStateToProps = (state, ownProps) => {
lastRequestedPageOfMyChallenges: cl.lastRequestedPageOfMyChallenges,
lastRequestedPageOfMyPastChallenges: cl.lastRequestedPageOfMyPastChallenges,
lastRequestedPageOfAllChallenges: cl.lastRequestedPageOfAllChallenges,
- lastRequestedPageOfRecommendedChallenges: cl.lastRequestedPageOfRecommendedChallenges,
lastRequestedPageOfPastChallenges: cl.lastRequestedPageOfPastChallenges,
lastRequestedPageOfReviewOpportunities: cl.lastRequestedPageOfReviewOpportunities,
// lastUpdateOfActiveChallenges: cl.lastUpdateOfActiveChallenges,
@@ -854,7 +810,6 @@ const mapStateToProps = (state, ownProps) => {
loadingMyChallengesUUID: cl.loadingMyChallengesUUID,
loadingMyPastChallengesUUID: cl.loadingMyPastChallengesUUID,
loadingAllChallengesUUID: cl.loadingAllChallengesUUID,
- loadingRecommendedChallengesUUID: cl.loadingRecommendedChallengesUUID,
loadingPastChallengesUUID: cl.loadingPastChallengesUUID,
loadingReviewOpportunitiesUUID: cl.loadingReviewOpportunitiesUUID,
loadingChallengeTypes: cl.loadingChallengeTypes,
@@ -872,6 +827,7 @@ const mapStateToProps = (state, ownProps) => {
expandedTags: cl.expandedTags,
meta: cl.meta,
// userChallenges: cl.userChallenges,
+ filterState: cl.filter,
};
};
@@ -889,10 +845,25 @@ function mapDispatchToProps(dispatch) {
dispatch(a.getActiveChallengesDone(uuid, page, filter, token, frontFilter));
},
dropActiveChallenges: () => dispatch(a.dropActiveChallenges()),
- getOpenForRegistrationChallenges: (page, filter, token, frontFilter) => {
+ getOpenForRegistrationChallenges: (
+ page,
+ filter,
+ token,
+ frontFilter,
+ isRecommendedOn = false,
+ handle,
+ ) => {
const uuid = shortId();
dispatch(a.getOpenForRegistrationChallengesInit(uuid, page, frontFilter));
- dispatch(a.getOpenForRegistrationChallengesDone(uuid, page, filter, token, frontFilter));
+ dispatch(a.getOpenForRegistrationChallengesDone(
+ uuid,
+ page,
+ filter,
+ token,
+ frontFilter,
+ isRecommendedOn,
+ handle,
+ ));
},
dropOpenForRegistrationChallenges: () => dispatch(a.dropOpenForRegistrationChallenges()),
getMyChallenges: (page, filter, token, frontFilter) => {
@@ -913,17 +884,11 @@ function mapDispatchToProps(dispatch) {
dispatch(a.getAllChallengesDone(uuid, page, filter, token, frontFilter));
},
dropAllChallenges: () => dispatch(a.dropAllChallenges()),
- dropRecommendedChallenges: () => dispatch(a.dropRecommendedChallenges()),
getTotalChallengesCount: (token, frontFilter) => {
const uuid = shortId();
dispatch(a.getTotalChallengesCountInit(uuid));
dispatch(a.getTotalChallengesCountDone(uuid, token, frontFilter));
},
- getRecommendedChallenges: (page, sort, token, filter) => {
- const uuid = shortId();
- dispatch(a.getRecommendedChallengesInit(uuid, page, sort));
- dispatch(a.getRecommendedChallengesDone(uuid, token, sort, filter));
- },
// getRestActiveChallenges: (token, filter) => {
// const uuid = shortId();
// dispatch(a.getRestActiveChallengesInit(uuid));
diff --git a/src/shared/reducers/challenge-listing/index.js b/src/shared/reducers/challenge-listing/index.js
index 3f89b1d47f..8632e3363c 100644
--- a/src/shared/reducers/challenge-listing/index.js
+++ b/src/shared/reducers/challenge-listing/index.js
@@ -149,15 +149,6 @@ function onGetAllChallengesInit(state, { payload }) {
};
}
-function onGetRecommendedChallengesInit(state, { payload }) {
- return {
- ...state,
- loadingRecommendedChallengesUUID: payload.uuid,
- lastRequestedPageOfRecommendedChallenges: payload.page,
- recommendedChallenges: [],
- };
-}
-
function onGetMyPastChallengesInit(state, { payload }) {
return {
...state,
@@ -645,26 +636,6 @@ function onGetAllChallengesDone(state, { error, payload }) {
};
}
-function onGetRecommendedChallengesDone(state, { error, payload }) {
- if (error) {
- logger.error(payload);
- return state;
- }
- const { uuid, recommendedChallenges: loaded } = payload;
- if (uuid !== state.loadingRecommendedChallengesUUID) return state;
- const challenges = loaded;
- return {
- ...state,
- recommendedChallenges: challenges,
- loadingRecommendedChallengesUUID: '',
- allRecommendedChallengesLoaded: challenges.length >= payload.meta.allRecommendedChallengesCount,
- meta: {
- ...state.meta,
- openChallengesCount: payload.meta.allRecommendedChallengesCount,
- },
- };
-}
-
function onGetMyPastChallengesDone(state, { error, payload }) {
if (error) {
logger.error(payload);
@@ -847,9 +818,6 @@ function create(initialState) {
[a.getAllChallengesInit]: onGetAllChallengesInit,
[a.getAllChallengesDone]: onGetAllChallengesDone,
- [a.getRecommendedChallengesInit]: onGetRecommendedChallengesInit,
- [a.getRecommendedChallengesDone]: onGetRecommendedChallengesDone,
-
[a.getTotalChallengesCountInit]: onGetTotalChallengesCountInit,
[a.getTotalChallengesCountDone]: onGetTotalChallengesCountDone,
diff --git a/src/shared/utils/challenge-listing/buckets.js b/src/shared/utils/challenge-listing/buckets.js
index a9681401c0..4d785b25b5 100644
--- a/src/shared/utils/challenge-listing/buckets.js
+++ b/src/shared/utils/challenge-listing/buckets.js
@@ -18,8 +18,6 @@ export const BUCKETS = {
// SAVED_REVIEW_OPPORTUNITIES_FILTER: 'savedReviewOpportunitiesFilter',
ALL_PAST: 'allPast',
MY_PAST: 'myPast',
- NOT_LOGGED_IN: 'bestMatchNotLoggedIn',
- NO_RECOMMENDED_MATCH: 'noRecommendedMatch',
};
export const BUCKET_DATA = {
@@ -152,8 +150,6 @@ export const NO_LIVE_CHALLENGES_CONFIG = {
// [BUCKETS.UPCOMING]: 'No challenges found in Upcoming Challenges',
[BUCKETS.ALL_PAST]: 'No challenges found in All Past Challenges',
[BUCKETS.MY_PAST]: 'No challenges found in My Past Challenges',
- [BUCKETS.NOT_LOGGED_IN]: 'There are no recommended challenges for you. This could be because you are not logged in and/or the recommendation tool will only recommend challenges that match your skills once you successfully place in a challenge. Try exploring other challenges or checking back later.',
- [BUCKETS.NO_RECOMMENDED_MATCH]: 'There are no challenges open for registration at the moment that match your skills. Try exploring other challenges or checking back later.',
};
/**
@@ -275,7 +271,7 @@ export function isPastBucket(bucket) {
* @param {Object} filterState current filter state
*/
export function isRecommendedChallengeType(bucket, filterState) {
- return bucket === 'openForRegistration' && filterState.types.includes('REC');
+ return bucket === 'openForRegistration' && filterState.recommended;
}
export default undefined;
diff --git a/src/shared/utils/challenge-listing/sort.js b/src/shared/utils/challenge-listing/sort.js
index fbce202b88..1e9f0d94cb 100644
--- a/src/shared/utils/challenge-listing/sort.js
+++ b/src/shared/utils/challenge-listing/sort.js
@@ -101,7 +101,7 @@ export default {
name: 'Review start date',
},
[SORTS.BEST_MATCH]: {
- func: (a, b) => calculateScore(b.matchScore) - calculateScore(a.matchScore),
+ func: (a, b) => calculateScore(b.jaccard_index) - calculateScore(a.jaccard_index),
name: 'Best Match',
},
};
diff --git a/src/styles/_mixins/_variables.scss b/src/styles/_mixins/_variables.scss
index f3c494fc02..37b2b33efa 100644
--- a/src/styles/_mixins/_variables.scss
+++ b/src/styles/_mixins/_variables.scss
@@ -10,3 +10,6 @@ $member-green: #258205;
$member-blue: #4c50d9;
$member-yellow: #f2c900;
$member-red: #ea1900;
+
+/* recommendation tag color */
+$recommendation-bg: #cef0af;