Skip to content

Commit 9dfa9f5

Browse files
authored
Merge pull request #5362 from nursoltan-s/nursoltan/final-fixes
integrate recommendation challenges with api
2 parents 4c91824 + 0581c0e commit 9dfa9f5

File tree

32 files changed

+728
-403
lines changed

32 files changed

+728
-403
lines changed

__tests__/shared/components/challenge-listing/Filters/__snapshots__/FiltersPanel.jsx.snap

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ exports[`Matches shallow shapshot 2`] = `
137137
<span
138138
className="src-shared-components-challenge-listing-Filters-FiltersPanel-___style__label___3W9TU"
139139
>
140-
Challenge Type
140+
Type
141141
</span>
142142
<div
143143
className="src-shared-components-challenge-listing-Filters-FiltersPanel-___style__checkboxes___3ukXp"
@@ -184,7 +184,6 @@ exports[`Matches shallow shapshot 2`] = `
184184
</div>
185185
</div>
186186
</div>
187-
<hr />
188187
<div
189188
className="src-shared-components-challenge-listing-Filters-FiltersPanel-___style__buttons___2r3xW"
190189
>

__tests__/shared/components/challenge-listing/__snapshots__/index.jsx.snap

Lines changed: 70 additions & 64 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,6 @@ exports[`Matches shallow shapshot 1 shapshot 1 1`] = `
55
className="src-shared-components-challenge-listing-___style__ChallengeFiltersExample___3IjeI"
66
id="challengeFilterContainer"
77
>
8-
<Connect(Container)
9-
setFilterState={[MockFunction]}
10-
/>
118
<div
129
className="src-shared-components-challenge-listing-___style__tc-content-wrapper___1MqlF"
1310
>
@@ -24,35 +21,41 @@ exports[`Matches shallow shapshot 1 shapshot 1 1`] = `
2421
setFilterState={[MockFunction]}
2522
/>
2623
</div>
27-
<Connect(Listing)
28-
activeBucket="abc"
29-
auth={Object {}}
30-
challenges={Array []}
31-
communityName={null}
32-
expandTag={null}
33-
expandedTags={Array []}
34-
expanding={false}
35-
filterState={Object {}}
36-
loadMoreActive={null}
37-
loadMoreAll={null}
38-
loadMoreMy={null}
39-
loadMoreMyPast={null}
40-
loadMoreOnGoing={null}
41-
loadMoreOpenForRegistration={null}
42-
loadMorePast={null}
43-
loadMoreRecommended={null}
44-
loadMoreReviewOpportunities={null}
45-
loadingPastChallenges={false}
46-
newChallengeDetails={false}
47-
openChallengesInNewTabs={false}
48-
preListingMsg={null}
49-
prizeMode="money-usd"
50-
reviewOpportunities={Array []}
51-
selectBucket={[MockFunction]}
52-
setFilterState={[MockFunction]}
53-
setSort={[MockFunction]}
54-
sorts={Object {}}
55-
/>
24+
<div
25+
className="src-shared-components-challenge-listing-___style__card-container___3-J4n"
26+
>
27+
<Connect(Container)
28+
setFilterState={[MockFunction]}
29+
/>
30+
<Connect(Listing)
31+
activeBucket="abc"
32+
auth={Object {}}
33+
challenges={Array []}
34+
communityName={null}
35+
expandTag={null}
36+
expandedTags={Array []}
37+
expanding={false}
38+
filterState={Object {}}
39+
loadMoreActive={null}
40+
loadMoreAll={null}
41+
loadMoreMy={null}
42+
loadMoreMyPast={null}
43+
loadMoreOnGoing={null}
44+
loadMoreOpenForRegistration={null}
45+
loadMorePast={null}
46+
loadMoreReviewOpportunities={null}
47+
loadingPastChallenges={false}
48+
newChallengeDetails={false}
49+
openChallengesInNewTabs={false}
50+
preListingMsg={null}
51+
prizeMode="money-usd"
52+
reviewOpportunities={Array []}
53+
selectBucket={[MockFunction]}
54+
setFilterState={[MockFunction]}
55+
setSort={[MockFunction]}
56+
sorts={Object {}}
57+
/>
58+
</div>
5659
</div>
5760
</div>
5861
`;
@@ -62,9 +65,6 @@ exports[`Matches shallow shapshot 2 shapshot 2 1`] = `
6265
className="src-shared-components-challenge-listing-___style__ChallengeFiltersExample___3IjeI"
6366
id="challengeFilterContainer"
6467
>
65-
<Connect(Container)
66-
setFilterState={[MockFunction]}
67-
/>
6868
<div
6969
className="src-shared-components-challenge-listing-___style__tc-content-wrapper___1MqlF"
7070
>
@@ -81,35 +81,41 @@ exports[`Matches shallow shapshot 2 shapshot 2 1`] = `
8181
setFilterState={[MockFunction]}
8282
/>
8383
</div>
84-
<Connect(Listing)
85-
activeBucket="abc"
86-
auth={Object {}}
87-
challenges={Array []}
88-
communityName={null}
89-
expandTag={null}
90-
expandedTags={Array []}
91-
expanding={false}
92-
filterState={Object {}}
93-
loadMoreActive={null}
94-
loadMoreAll={null}
95-
loadMoreMy={null}
96-
loadMoreMyPast={null}
97-
loadMoreOnGoing={null}
98-
loadMoreOpenForRegistration={null}
99-
loadMorePast={null}
100-
loadMoreRecommended={null}
101-
loadMoreReviewOpportunities={null}
102-
loadingPastChallenges={false}
103-
newChallengeDetails={false}
104-
openChallengesInNewTabs={false}
105-
preListingMsg={null}
106-
prizeMode="money-usd"
107-
reviewOpportunities={Array []}
108-
selectBucket={[MockFunction]}
109-
setFilterState={[MockFunction]}
110-
setSort={[MockFunction]}
111-
sorts={Object {}}
112-
/>
84+
<div
85+
className="src-shared-components-challenge-listing-___style__card-container___3-J4n"
86+
>
87+
<Connect(Container)
88+
setFilterState={[MockFunction]}
89+
/>
90+
<Connect(Listing)
91+
activeBucket="abc"
92+
auth={Object {}}
93+
challenges={Array []}
94+
communityName={null}
95+
expandTag={null}
96+
expandedTags={Array []}
97+
expanding={false}
98+
filterState={Object {}}
99+
loadMoreActive={null}
100+
loadMoreAll={null}
101+
loadMoreMy={null}
102+
loadMoreMyPast={null}
103+
loadMoreOnGoing={null}
104+
loadMoreOpenForRegistration={null}
105+
loadMorePast={null}
106+
loadMoreReviewOpportunities={null}
107+
loadingPastChallenges={false}
108+
newChallengeDetails={false}
109+
openChallengesInNewTabs={false}
110+
preListingMsg={null}
111+
prizeMode="money-usd"
112+
reviewOpportunities={Array []}
113+
selectBucket={[MockFunction]}
114+
setFilterState={[MockFunction]}
115+
setSort={[MockFunction]}
116+
sorts={Object {}}
117+
/>
118+
</div>
113119
</div>
114120
</div>
115121
`;

src/assets/images/icon-circle.png

581 Bytes
Loading

src/assets/images/icon-computer.svg

Lines changed: 17 additions & 0 deletions
Loading

src/assets/images/icon-verified.svg

Lines changed: 37 additions & 0 deletions
Loading

src/shared/actions/challenge-listing/index.js

Lines changed: 26 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,8 @@ const REVIEW_OPPORTUNITY_PAGE_SIZE = 1000;
5353
*/
5454
function getChallengeTypesDone() {
5555
return getService()
56-
.getChallengeTypes();
56+
.getChallengeTypes()
57+
.then(res => res.sort((a, b) => a.name.localeCompare(b.name)));
5758
}
5859

5960
/**
@@ -90,10 +91,6 @@ function getAllChallengesInit(uuid, page, frontFilter) {
9091
return { uuid, page, frontFilter };
9192
}
9293

93-
function getRecommendedChallengesInit(uuid, page, frontFilter) {
94-
return { uuid, page, frontFilter };
95-
}
96-
9794
function getMyPastChallengesInit(uuid, page, frontFilter) {
9895
return { uuid, page, frontFilter };
9996
}
@@ -231,8 +228,22 @@ function getActiveChallengesDone(uuid, page, backendFilter, tokenV3, frontFilter
231228
// }));
232229
}
233230

231+
/**
232+
* Gets open for registration challenges
233+
* @param {String} uuid
234+
* @param {Number} page
235+
* @param {Object} backendFilter Backend filter to use.
236+
* @param {String} tokenV3 Optional. Topcoder auth token v3. Without token only
237+
* public challenges will be fetched. With the token provided, the action will
238+
* also fetch private challenges related to this user.
239+
* @param {Object} frontFilter
240+
* @param {boolean} recommended recommended toggle is on or off
241+
* @param {String} handle user handle
242+
243+
* @return {Promise}
244+
*/
234245
function getOpenForRegistrationChallengesDone(uuid, page, backendFilter,
235-
tokenV3, frontFilter = {}) {
246+
tokenV3, frontFilter = {}, recommended = false, handle) {
236247
const { sorts } = frontFilter;
237248
const sortOrder = SORT[sorts[BUCKETS.OPEN_FOR_REGISTRATION]];
238249
const filter = {
@@ -249,6 +260,15 @@ function getOpenForRegistrationChallengesDone(uuid, page, backendFilter,
249260
};
250261
delete filter.frontFilter.sorts;
251262
const service = getService(tokenV3);
263+
if (recommended) {
264+
return service.getRecommendedChallenges(filter, handle).then(ch => ({
265+
uuid,
266+
openForRegistrationChallenges: ch.challenges,
267+
meta: ch.meta,
268+
frontFilter,
269+
}));
270+
}
271+
252272
return service.getChallenges(filter).then(ch => ({
253273
uuid,
254274
openForRegistrationChallenges: ch.challenges,
@@ -305,17 +325,6 @@ function getAllChallengesDone(uuid, page, backendFilter, tokenV3, frontFilter =
305325
}));
306326
}
307327

308-
function getRecommendedChallengesDone(uuid, tokenV3, sort, filter) {
309-
const service = getService(tokenV3);
310-
return service.getRecommendedChallenges(sort, filter).then(ch => ({
311-
uuid,
312-
recommendedChallenges: ch.challenges,
313-
meta: {
314-
allRecommendedChallengesCount: ch.meta,
315-
},
316-
}));
317-
}
318-
319328
function getMyPastChallengesDone(uuid, page, backendFilter, tokenV3, frontFilter = {}) {
320329
const userId = decodeToken(tokenV3).userId.toString();
321330
const { sorts } = frontFilter;
@@ -551,9 +560,6 @@ export default createActions({
551560
GET_ALL_CHALLENGES_INIT: getAllChallengesInit,
552561
GET_ALL_CHALLENGES_DONE: getAllChallengesDone,
553562

554-
GET_RECOMMENDED_CHALLENGES_INIT: getRecommendedChallengesInit,
555-
GET_RECOMMENDED_CHALLENGES_DONE: getRecommendedChallengesDone,
556-
557563
GET_ACTIVE_CHALLENGES_INIT: getActiveChallengesInit,
558564
GET_ACTIVE_CHALLENGES_DONE: getActiveChallengesDone,
559565

0 commit comments

Comments
 (0)