Skip to content

Commit a18b377

Browse files
authored
Merge pull request #3617 from topcoder-platform/hot-fix-no-result
Hot fix no result
2 parents a1c2683 + 2376e34 commit a18b377

File tree

7 files changed

+79
-3
lines changed

7 files changed

+79
-3
lines changed

.circleci/config.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,7 @@ workflows:
175175
branches:
176176
only:
177177
- develop
178-
- hot-fix-challenge-details
178+
- hot-fix-no-result
179179
# This is alternate dev env for parallel testing
180180
- "build-test":
181181
context : org-global

__tests__/shared/components/challenge-listing/Listing/__snapshots__/Bucket.jsx.snap

+3
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ exports[`Matches shallow shapshot 1`] = `
77
location="/"
88
>
99
<Bucket
10+
activeBucket=""
1011
bucket={
1112
Object {
1213
"filter": Object {
@@ -91,6 +92,7 @@ exports[`Matches shallow shapshot 2`] = `
9192
location="/"
9293
>
9394
<Bucket
95+
activeBucket=""
9496
bucket={
9597
Object {
9698
"filter": Object {
@@ -239,6 +241,7 @@ exports[`Matches shallow shapshot 3`] = `
239241
location="/"
240242
>
241243
<Bucket
244+
activeBucket=""
242245
bucket={
243246
Object {
244247
"filter": Object {

src/shared/components/challenge-listing/Listing/Bucket/index.jsx

+14-1
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import PT from 'prop-types';
99
import qs from 'qs';
1010
import React from 'react';
1111
import Sort from 'utils/challenge-listing/sort';
12+
import { NO_LIVE_CHALLENGES_CONFIG, BUCKETS } from 'utils/challenge-listing/buckets';
1213
import SortingSelectBar from 'components/SortingSelectBar';
1314
import Waypoint from 'react-waypoint';
1415
import { challenge as challengeUtils } from 'topcoder-react-lib';
@@ -42,6 +43,7 @@ export default function Bucket({
4243
userHandle,
4344
expandedTags,
4445
expandTag,
46+
activeBucket,
4547
}) {
4648
const filter = Filter.getFilterFunction(bucket.filter);
4749
const activeSort = sort || bucket.sorts[0];
@@ -67,7 +69,16 @@ export default function Bucket({
6769
}
6870
}
6971

70-
if (!filteredChallenges.length && !loadMore) return null;
72+
if (!filteredChallenges.length && !loadMore) {
73+
if (activeBucket === BUCKETS.ALL) {
74+
return null;
75+
}
76+
return (
77+
<div styleName="no-results">
78+
{`${NO_LIVE_CHALLENGES_CONFIG[bucketId]}`}
79+
</div>
80+
);
81+
}
7182

7283
const cards = filteredChallenges.map(item => (
7384
<ChallengeCard
@@ -158,6 +169,7 @@ Bucket.defaultProps = {
158169
userHandle: '',
159170
expandedTags: [],
160171
expandTag: null,
172+
activeBucket: '',
161173
};
162174

163175
Bucket.propTypes = {
@@ -182,4 +194,5 @@ Bucket.propTypes = {
182194
userHandle: PT.string,
183195
expandedTags: PT.arrayOf(PT.number),
184196
expandTag: PT.func,
197+
activeBucket: PT.string,
185198
};

src/shared/components/challenge-listing/Listing/Bucket/style.scss

+9
Original file line numberDiff line numberDiff line change
@@ -31,3 +31,12 @@
3131
border: 3px solid #79a3ef;
3232
border-radius: 4px;
3333
}
34+
35+
.no-results {
36+
@include tc-label-lg;
37+
38+
display: flex;
39+
align-items: center;
40+
justify-content: center;
41+
padding: $base-unit * 5;
42+
}

src/shared/components/challenge-listing/Listing/index.jsx

+32-1
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,16 @@ import _ from 'lodash';
66
import React from 'react';
77
import PT from 'prop-types';
88
import { connect } from 'react-redux';
9-
import { BUCKETS, getBuckets, isReviewOpportunitiesBucket } from 'utils/challenge-listing/buckets';
9+
import {
10+
BUCKETS, getBuckets, isReviewOpportunitiesBucket, NO_LIVE_CHALLENGES_CONFIG,
11+
} from 'utils/challenge-listing/buckets';
12+
import { challenge as challengeUtils } from 'topcoder-react-lib';
1013
import Bucket from './Bucket';
1114
import ReviewOpportunityBucket from './ReviewOpportunityBucket';
1215
import './style.scss';
1316

17+
const Filter = challengeUtils.filter;
18+
1419
function Listing({
1520
activeBucket,
1621
auth,
@@ -39,6 +44,17 @@ function Listing({
3944
expandTag,
4045
}) {
4146
const buckets = getBuckets(_.get(auth.user, 'handle'));
47+
const isChallengesAvailable = (bucket) => {
48+
const filter = Filter.getFilterFunction(buckets[bucket].filter);
49+
const clonedChallenges = _.clone(challenges);
50+
const filteredChallenges = [];
51+
for (let i = 0; i < clonedChallenges.length; i += 1) {
52+
if (filter(clonedChallenges[i])) {
53+
filteredChallenges.push(clonedChallenges[i]);
54+
}
55+
}
56+
return filteredChallenges.length > 0;
57+
};
4258
const getBucket = (bucket, expanded = false) => {
4359
let keepPlaceholders = false;
4460
let loading;
@@ -96,6 +112,7 @@ function Listing({
96112
setSort={sort => setSort(bucket, sort)}
97113
sort={sorts[bucket]}
98114
userHandle={_.get(auth, 'user.handle')}
115+
activeBucket={activeBucket}
99116
/>
100117
)
101118
);
@@ -110,6 +127,20 @@ function Listing({
110127
);
111128
}
112129

130+
let isFilled = isChallengesAvailable(BUCKETS.OPEN_FOR_REGISTRATION)
131+
|| isChallengesAvailable(BUCKETS.ONGOING);
132+
if (auth.user) {
133+
isFilled = isFilled || isChallengesAvailable(BUCKETS.MY);
134+
}
135+
if (!isFilled) {
136+
return (
137+
<div styleName="challengeCardContainer">
138+
<div styleName="no-results">
139+
{`${NO_LIVE_CHALLENGES_CONFIG[activeBucket]}`}
140+
</div>
141+
</div>
142+
);
143+
}
113144
return (
114145
<div styleName="challengeCardContainer">
115146
{preListingMsg}

src/shared/components/challenge-listing/Listing/style.scss

+10
Original file line numberDiff line numberDiff line change
@@ -40,4 +40,14 @@
4040
padding-top: $base-unit;
4141
margin: 0;
4242
}
43+
44+
.no-results {
45+
@include tc-label-lg;
46+
47+
display: flex;
48+
align-items: center;
49+
justify-content: center;
50+
padding: $base-unit * 5;
51+
border-radius: $corner-radius;
52+
}
4353
}

src/shared/utils/challenge-listing/buckets.js

+10
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,16 @@ const BUCKET_DATA = {
119119
},
120120
};
121121

122+
export const NO_LIVE_CHALLENGES_CONFIG = {
123+
[BUCKETS.ALL]: 'No Live Challenges found in All Challenges',
124+
[BUCKETS.MY]: 'No challenges found in My Challenges',
125+
[BUCKETS.OPEN_FOR_REGISTRATION]: 'No challenges found in Open for Registration',
126+
[BUCKETS.ONGOING]: 'No challenges found in Ongoing Challenges',
127+
[BUCKETS.PAST]: 'No challenges found in Past',
128+
[BUCKETS.SAVED_FILTER]: 'No challenges found in Saved filter Challenges',
129+
[BUCKETS.UPCOMING]: 'No challenges found in Upcoming Challenges',
130+
};
131+
122132
/**
123133
* Returns configuration of all possible challenge buckets.
124134
* @param {String} userHandle Handle of the authenticated

0 commit comments

Comments
 (0)