Skip to content

fix(challenge-listing): add NO_LIVE_CHALLENGES messsage to All bucket in case of 0 challenges #5001

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

if (sortedChallenges.length === 0) {
if (!loading && sortedChallenges.length === 0) {
return (
<div styleName="no-results">
{ `${NO_LIVE_CHALLENGES_CONFIG[bucket]}` }
Expand Down
36 changes: 30 additions & 6 deletions src/shared/components/challenge-listing/Listing/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,13 @@ import React from 'react';
import PT from 'prop-types';
import { connect } from 'react-redux';
import {
BUCKETS, isReviewOpportunitiesBucket,
BUCKETS, isReviewOpportunitiesBucket, NO_LIVE_CHALLENGES_CONFIG,
// BUCKETS, getBuckets, isReviewOpportunitiesBucket, NO_LIVE_CHALLENGES_CONFIG,
} from 'utils/challenge-listing/buckets';
// import { challenge as challengeUtils } from 'topcoder-react-lib';
import Bucket from './Bucket';
import ReviewOpportunityBucket from './ReviewOpportunityBucket';
import CardPlaceholder from '../placeholders/ChallengeCard';
import './style.scss';

// const Filter = challengeUtils.filter;
Expand Down Expand Up @@ -181,13 +182,36 @@ function Listing({
// </div>
// );
// }
const loading = loadingMyChallenges
|| loadingOpenForRegistrationChallenges
|| loadingOnGoingChallenges;
const placeholders = [];
if (challenges.length > 0) {
return (
<div styleName="challengeCardContainer">
{preListingMsg}
{(auth.user && myChallenges.length > 0) ? getBucket(BUCKETS.MY) : null}
{/* {extraBucket ? getBucket(extraBucket) : null} */}
{openForRegistrationChallenges.length > 0 && getBucket(BUCKETS.OPEN_FOR_REGISTRATION)}
{/* {getBucket(BUCKETS.ONGOING)} */}
</div>
);
}

if (loading) {
for (let i = 0; i < 10; i += 1) {
placeholders.push(<CardPlaceholder id={i} key={i} />);
}
}
return (
<div styleName="challengeCardContainer">
{preListingMsg}
{(auth.user && myChallenges.length > 0) ? getBucket(BUCKETS.MY) : null}
{/* {extraBucket ? getBucket(extraBucket) : null} */}
{openForRegistrationChallenges.length > 0 && getBucket(BUCKETS.OPEN_FOR_REGISTRATION)}
{/* {getBucket(BUCKETS.ONGOING)} */}
{
loading
? placeholders
: (
<div styleName="no-results">{ `${NO_LIVE_CHALLENGES_CONFIG[activeBucket]}` }</div>
)
}
</div>
);
}
Expand Down