@@ -7,10 +7,13 @@ import React from 'react';
7
7
import PT from 'prop-types' ;
8
8
import { connect } from 'react-redux' ;
9
9
import { BUCKETS , getBuckets , isReviewOpportunitiesBucket } from 'utils/challenge-listing/buckets' ;
10
+ import { challenge as challengeUtils } from 'topcoder-react-lib' ;
10
11
import Bucket from './Bucket' ;
11
12
import ReviewOpportunityBucket from './ReviewOpportunityBucket' ;
12
13
import './style.scss' ;
13
14
15
+ const Filter = challengeUtils . filter ;
16
+
14
17
function Listing ( {
15
18
activeBucket,
16
19
auth,
@@ -39,6 +42,17 @@ function Listing({
39
42
expandTag,
40
43
} ) {
41
44
const buckets = getBuckets ( _ . get ( auth . user , 'handle' ) ) ;
45
+ const isChallengesAvailable = ( bucket ) => {
46
+ const filter = Filter . getFilterFunction ( buckets [ bucket ] . filter ) ;
47
+ const clonedChallenges = _ . clone ( challenges ) ;
48
+ const filteredChallenges = [ ] ;
49
+ for ( let i = 0 ; i < clonedChallenges . length ; i += 1 ) {
50
+ if ( filter ( clonedChallenges [ i ] ) ) {
51
+ filteredChallenges . push ( clonedChallenges [ i ] ) ;
52
+ }
53
+ }
54
+ return filteredChallenges . length > 0 ;
55
+ } ;
42
56
const getBucket = ( bucket , expanded = false ) => {
43
57
let keepPlaceholders = false ;
44
58
let loading ;
@@ -110,6 +124,18 @@ function Listing({
110
124
) ;
111
125
}
112
126
127
+ let isFilled = isChallengesAvailable ( BUCKETS . OPEN_FOR_REGISTRATION )
128
+ || isChallengesAvailable ( BUCKETS . ONGOING ) ;
129
+ if ( auth . user ) {
130
+ isFilled = isFilled || isChallengesAvailable ( BUCKETS . MY ) ;
131
+ }
132
+ if ( ! isFilled ) {
133
+ return (
134
+ < div styleName = "challengeCardContainer" >
135
+ < h3 > No Live challenges found </ h3 >
136
+ </ div >
137
+ ) ;
138
+ }
113
139
return (
114
140
< div styleName = "challengeCardContainer" >
115
141
{ preListingMsg }
0 commit comments