Skip to content

integrate recommendation challenges with api #5362

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Show file tree
Hide file tree
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
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ exports[`Matches shallow shapshot 2`] = `
<span
className="src-shared-components-challenge-listing-Filters-FiltersPanel-___style__label___3W9TU"
>
Challenge Type
Type
</span>
<div
className="src-shared-components-challenge-listing-Filters-FiltersPanel-___style__checkboxes___3ukXp"
Expand Down Expand Up @@ -184,7 +184,6 @@ exports[`Matches shallow shapshot 2`] = `
</div>
</div>
</div>
<hr />
<div
className="src-shared-components-challenge-listing-Filters-FiltersPanel-___style__buttons___2r3xW"
>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,6 @@ exports[`Matches shallow shapshot 1 shapshot 1 1`] = `
className="src-shared-components-challenge-listing-___style__ChallengeFiltersExample___3IjeI"
id="challengeFilterContainer"
>
<Connect(Container)
setFilterState={[MockFunction]}
/>
<div
className="src-shared-components-challenge-listing-___style__tc-content-wrapper___1MqlF"
>
Expand All @@ -24,35 +21,41 @@ exports[`Matches shallow shapshot 1 shapshot 1 1`] = `
setFilterState={[MockFunction]}
/>
</div>
<Connect(Listing)
activeBucket="abc"
auth={Object {}}
challenges={Array []}
communityName={null}
expandTag={null}
expandedTags={Array []}
expanding={false}
filterState={Object {}}
loadMoreActive={null}
loadMoreAll={null}
loadMoreMy={null}
loadMoreMyPast={null}
loadMoreOnGoing={null}
loadMoreOpenForRegistration={null}
loadMorePast={null}
loadMoreRecommended={null}
loadMoreReviewOpportunities={null}
loadingPastChallenges={false}
newChallengeDetails={false}
openChallengesInNewTabs={false}
preListingMsg={null}
prizeMode="money-usd"
reviewOpportunities={Array []}
selectBucket={[MockFunction]}
setFilterState={[MockFunction]}
setSort={[MockFunction]}
sorts={Object {}}
/>
<div
className="src-shared-components-challenge-listing-___style__card-container___3-J4n"
>
<Connect(Container)
setFilterState={[MockFunction]}
/>
<Connect(Listing)
activeBucket="abc"
auth={Object {}}
challenges={Array []}
communityName={null}
expandTag={null}
expandedTags={Array []}
expanding={false}
filterState={Object {}}
loadMoreActive={null}
loadMoreAll={null}
loadMoreMy={null}
loadMoreMyPast={null}
loadMoreOnGoing={null}
loadMoreOpenForRegistration={null}
loadMorePast={null}
loadMoreReviewOpportunities={null}
loadingPastChallenges={false}
newChallengeDetails={false}
openChallengesInNewTabs={false}
preListingMsg={null}
prizeMode="money-usd"
reviewOpportunities={Array []}
selectBucket={[MockFunction]}
setFilterState={[MockFunction]}
setSort={[MockFunction]}
sorts={Object {}}
/>
</div>
</div>
</div>
`;
Expand All @@ -62,9 +65,6 @@ exports[`Matches shallow shapshot 2 shapshot 2 1`] = `
className="src-shared-components-challenge-listing-___style__ChallengeFiltersExample___3IjeI"
id="challengeFilterContainer"
>
<Connect(Container)
setFilterState={[MockFunction]}
/>
<div
className="src-shared-components-challenge-listing-___style__tc-content-wrapper___1MqlF"
>
Expand All @@ -81,35 +81,41 @@ exports[`Matches shallow shapshot 2 shapshot 2 1`] = `
setFilterState={[MockFunction]}
/>
</div>
<Connect(Listing)
activeBucket="abc"
auth={Object {}}
challenges={Array []}
communityName={null}
expandTag={null}
expandedTags={Array []}
expanding={false}
filterState={Object {}}
loadMoreActive={null}
loadMoreAll={null}
loadMoreMy={null}
loadMoreMyPast={null}
loadMoreOnGoing={null}
loadMoreOpenForRegistration={null}
loadMorePast={null}
loadMoreRecommended={null}
loadMoreReviewOpportunities={null}
loadingPastChallenges={false}
newChallengeDetails={false}
openChallengesInNewTabs={false}
preListingMsg={null}
prizeMode="money-usd"
reviewOpportunities={Array []}
selectBucket={[MockFunction]}
setFilterState={[MockFunction]}
setSort={[MockFunction]}
sorts={Object {}}
/>
<div
className="src-shared-components-challenge-listing-___style__card-container___3-J4n"
>
<Connect(Container)
setFilterState={[MockFunction]}
/>
<Connect(Listing)
activeBucket="abc"
auth={Object {}}
challenges={Array []}
communityName={null}
expandTag={null}
expandedTags={Array []}
expanding={false}
filterState={Object {}}
loadMoreActive={null}
loadMoreAll={null}
loadMoreMy={null}
loadMoreMyPast={null}
loadMoreOnGoing={null}
loadMoreOpenForRegistration={null}
loadMorePast={null}
loadMoreReviewOpportunities={null}
loadingPastChallenges={false}
newChallengeDetails={false}
openChallengesInNewTabs={false}
preListingMsg={null}
prizeMode="money-usd"
reviewOpportunities={Array []}
selectBucket={[MockFunction]}
setFilterState={[MockFunction]}
setSort={[MockFunction]}
sorts={Object {}}
/>
</div>
</div>
</div>
`;
Binary file added src/assets/images/icon-circle.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
17 changes: 17 additions & 0 deletions src/assets/images/icon-computer.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
37 changes: 37 additions & 0 deletions src/assets/images/icon-verified.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
46 changes: 26 additions & 20 deletions src/shared/actions/challenge-listing/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,8 @@ const REVIEW_OPPORTUNITY_PAGE_SIZE = 1000;
*/
function getChallengeTypesDone() {
return getService()
.getChallengeTypes();
.getChallengeTypes()
.then(res => res.sort((a, b) => a.name.localeCompare(b.name)));
}

/**
Expand Down Expand Up @@ -90,10 +91,6 @@ function getAllChallengesInit(uuid, page, frontFilter) {
return { uuid, page, frontFilter };
}

function getRecommendedChallengesInit(uuid, page, frontFilter) {
return { uuid, page, frontFilter };
}

function getMyPastChallengesInit(uuid, page, frontFilter) {
return { uuid, page, frontFilter };
}
Expand Down Expand Up @@ -231,8 +228,22 @@ function getActiveChallengesDone(uuid, page, backendFilter, tokenV3, frontFilter
// }));
}

/**
* Gets open for registration challenges
* @param {String} uuid
* @param {Number} page
* @param {Object} backendFilter Backend filter to use.
* @param {String} tokenV3 Optional. Topcoder auth token v3. Without token only
* public challenges will be fetched. With the token provided, the action will
* also fetch private challenges related to this user.
* @param {Object} frontFilter
* @param {boolean} recommended recommended toggle is on or off
* @param {String} handle user handle

* @return {Promise}
*/
function getOpenForRegistrationChallengesDone(uuid, page, backendFilter,
tokenV3, frontFilter = {}) {
tokenV3, frontFilter = {}, recommended = false, handle) {
const { sorts } = frontFilter;
const sortOrder = SORT[sorts[BUCKETS.OPEN_FOR_REGISTRATION]];
const filter = {
Expand All @@ -249,6 +260,15 @@ function getOpenForRegistrationChallengesDone(uuid, page, backendFilter,
};
delete filter.frontFilter.sorts;
const service = getService(tokenV3);
if (recommended) {
return service.getRecommendedChallenges(filter, handle).then(ch => ({
uuid,
openForRegistrationChallenges: ch.challenges,
meta: ch.meta,
frontFilter,
}));
}

return service.getChallenges(filter).then(ch => ({
uuid,
openForRegistrationChallenges: ch.challenges,
Expand Down Expand Up @@ -305,17 +325,6 @@ function getAllChallengesDone(uuid, page, backendFilter, tokenV3, frontFilter =
}));
}

function getRecommendedChallengesDone(uuid, tokenV3, sort, filter) {
const service = getService(tokenV3);
return service.getRecommendedChallenges(sort, filter).then(ch => ({
uuid,
recommendedChallenges: ch.challenges,
meta: {
allRecommendedChallengesCount: ch.meta,
},
}));
}

function getMyPastChallengesDone(uuid, page, backendFilter, tokenV3, frontFilter = {}) {
const userId = decodeToken(tokenV3).userId.toString();
const { sorts } = frontFilter;
Expand Down Expand Up @@ -551,9 +560,6 @@ export default createActions({
GET_ALL_CHALLENGES_INIT: getAllChallengesInit,
GET_ALL_CHALLENGES_DONE: getAllChallengesDone,

GET_RECOMMENDED_CHALLENGES_INIT: getRecommendedChallengesInit,
GET_RECOMMENDED_CHALLENGES_DONE: getRecommendedChallengesDone,

GET_ACTIVE_CHALLENGES_INIT: getActiveChallengesInit,
GET_ACTIVE_CHALLENGES_DONE: getActiveChallengesDone,

Expand Down
Loading