Skip to content

Commit 4993459

Browse files
committed
fix: add placeholder challenge cards when loading
1 parent f14f861 commit 4993459

File tree

2 files changed

+31
-13
lines changed

2 files changed

+31
-13
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
@@ -102,7 +102,7 @@ export default function Bucket({
102102
// );
103103
// }
104104

105-
if (sortedChallenges.length === 0) {
105+
if (!loading && sortedChallenges.length === 0) {
106106
return (
107107
<div styleName="no-results">
108108
{ `${NO_LIVE_CHALLENGES_CONFIG[bucket]}` }

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

Lines changed: 30 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import {
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;
@@ -181,19 +182,36 @@ function Listing({
181182
// </div>
182183
// );
183184
// }
184-
return challenges.length > 0 ? (
185-
<div styleName="challengeCardContainer">
186-
{preListingMsg}
187-
{(auth.user && myChallenges.length > 0) ? getBucket(BUCKETS.MY) : null}
188-
{/* {extraBucket ? getBucket(extraBucket) : null} */}
189-
{openForRegistrationChallenges.length > 0 && getBucket(BUCKETS.OPEN_FOR_REGISTRATION)}
190-
{/* {getBucket(BUCKETS.ONGOING)} */}
191-
</div>
192-
) : (
193-
<div styleName="challengeCardContainer">
194-
<div styleName="no-results">
195-
{ `${NO_LIVE_CHALLENGES_CONFIG[activeBucket]}` }
185+
const loading = loadingMyChallenges
186+
|| loadingOpenForRegistrationChallenges
187+
|| loadingOnGoingChallenges;
188+
const placeholders = [];
189+
if (challenges.length > 0) {
190+
return (
191+
<div styleName="challengeCardContainer">
192+
{preListingMsg}
193+
{(auth.user && myChallenges.length > 0) ? getBucket(BUCKETS.MY) : null}
194+
{/* {extraBucket ? getBucket(extraBucket) : null} */}
195+
{openForRegistrationChallenges.length > 0 && getBucket(BUCKETS.OPEN_FOR_REGISTRATION)}
196+
{/* {getBucket(BUCKETS.ONGOING)} */}
196197
</div>
198+
);
199+
}
200+
201+
if (loading) {
202+
for (let i = 0; i < 10; i += 1) {
203+
placeholders.push(<CardPlaceholder id={i} key={i} />);
204+
}
205+
}
206+
return (
207+
<div styleName="challengeCardContainer">
208+
{
209+
loading
210+
? placeholders
211+
: (
212+
<div styleName="no-results">{ `${NO_LIVE_CHALLENGES_CONFIG[activeBucket]}` }</div>
213+
)
214+
}
197215
</div>
198216
);
199217
}

0 commit comments

Comments
 (0)