Skip to content

Commit cb067d6

Browse files
Merge pull request topcoder-platform#5001 from cagdas001/fix-4962
fix(challenge-listing): add NO_LIVE_CHALLENGES messsage to All bucket in case of 0 challenges
2 parents a352932 + 4993459 commit cb067d6

File tree

2 files changed

+31
-7
lines changed

2 files changed

+31
-7
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ export default function Bucket({
114114
// );
115115
// }
116116

117-
if (sortedChallenges.length === 0) {
117+
if (!loading && sortedChallenges.length === 0) {
118118
return (
119119
<div styleName="no-results">
120120
{ `${NO_LIVE_CHALLENGES_CONFIG[bucket]}` }

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

Lines changed: 30 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,13 @@ import React from 'react';
77
import PT from 'prop-types';
88
import { connect } from 'react-redux';
99
import {
10-
BUCKETS, isReviewOpportunitiesBucket,
10+
BUCKETS, isReviewOpportunitiesBucket, NO_LIVE_CHALLENGES_CONFIG,
1111
// BUCKETS, getBuckets, isReviewOpportunitiesBucket, NO_LIVE_CHALLENGES_CONFIG,
1212
} from 'utils/challenge-listing/buckets';
1313
// import { challenge as challengeUtils } from 'topcoder-react-lib';
1414
import Bucket from './Bucket';
1515
import ReviewOpportunityBucket from './ReviewOpportunityBucket';
16+
import CardPlaceholder from '../placeholders/ChallengeCard';
1617
import './style.scss';
1718

1819
// const Filter = challengeUtils.filter;
@@ -194,13 +195,36 @@ function Listing({
194195
// </div>
195196
// );
196197
// }
198+
const loading = loadingMyChallenges
199+
|| loadingOpenForRegistrationChallenges
200+
|| loadingOnGoingChallenges;
201+
const placeholders = [];
202+
if (challenges.length > 0) {
203+
return (
204+
<div styleName="challengeCardContainer">
205+
{preListingMsg}
206+
{(auth.user && myChallenges.length > 0) ? getBucket(BUCKETS.MY) : null}
207+
{/* {extraBucket ? getBucket(extraBucket) : null} */}
208+
{openForRegistrationChallenges.length > 0 && getBucket(BUCKETS.OPEN_FOR_REGISTRATION)}
209+
{/* {getBucket(BUCKETS.ONGOING)} */}
210+
</div>
211+
);
212+
}
213+
214+
if (loading) {
215+
for (let i = 0; i < 10; i += 1) {
216+
placeholders.push(<CardPlaceholder id={i} key={i} />);
217+
}
218+
}
197219
return (
198220
<div styleName="challengeCardContainer">
199-
{preListingMsg}
200-
{(auth.user && myChallenges.length > 0) ? getBucket(BUCKETS.MY) : null}
201-
{/* {extraBucket ? getBucket(extraBucket) : null} */}
202-
{openForRegistrationChallenges.length > 0 && getBucket(BUCKETS.OPEN_FOR_REGISTRATION)}
203-
{/* {getBucket(BUCKETS.ONGOING)} */}
221+
{
222+
loading
223+
? placeholders
224+
: (
225+
<div styleName="no-results">{ `${NO_LIVE_CHALLENGES_CONFIG[activeBucket]}` }</div>
226+
)
227+
}
204228
</div>
205229
);
206230
}

0 commit comments

Comments
 (0)