@@ -183,12 +183,21 @@ export default function FiltersPanel({
183
183
) ;
184
184
} ;
185
185
186
+ const mapCommunityOps = ( community ) => {
187
+ if ( community . challengeFilter
188
+ && community . challengeFilter . events && community . challengeFilter . events . length ) {
189
+ return `event_${ community . challengeFilter . events [ 0 ] } ` ;
190
+ }
191
+
192
+ return community . communityName === 'All' ? '' : community . groupIds [ 0 ] ;
193
+ } ;
194
+
186
195
const communityOps = communityFilters . filter ( community => (
187
196
( ! community . hidden && ! community . hideFilter && ! _ . isEmpty ( community . groupIds ) ) || community . communityName === 'All'
188
197
) )
189
198
. map ( community => ( {
190
199
label : community . communityName ,
191
- value : community . communityName === 'All' ? '' : community . groupIds [ 0 ] ,
200
+ value : mapCommunityOps ( community ) ,
192
201
name : community . communityName ,
193
202
data : getLabel ( community ) ,
194
203
} ) ) ;
@@ -202,6 +211,16 @@ export default function FiltersPanel({
202
211
203
212
const mapOps = item => ( { label : item , value : item } ) ;
204
213
const mapTypes = item => ( { label : item . name , value : item . abbreviation } ) ;
214
+ const getCommunityOption = ( ) => {
215
+ if ( filterState . events && filterState . events . length ) {
216
+ return `event_${ filterState . events [ 0 ] } ` ;
217
+ }
218
+ if ( filterState . groups && filterState . groups . length ) {
219
+ return filterState . groups [ 0 ] ;
220
+ }
221
+ return '' ;
222
+ } ;
223
+
205
224
return (
206
225
< div styleName = { className } >
207
226
< div styleName = "header" >
@@ -247,13 +266,26 @@ export default function FiltersPanel({
247
266
id = "community-select"
248
267
// onChange={selectCommunity}
249
268
onChange = { ( value ) => {
250
- const group = value ;
251
- setFilterState ( { ..._ . clone ( filterState ) , groups : group === '' ? [ ] : [ group ] } ) ;
269
+ if ( value && value . startsWith ( 'event_' ) ) {
270
+ const event = value . split ( '_' ) [ 1 ] ;
271
+ setFilterState ( {
272
+ ..._ . clone ( filterState ) ,
273
+ events : event === '' ? [ ] : [ event ] ,
274
+ groups : [ ] ,
275
+ } ) ;
276
+ } else {
277
+ const group = value ;
278
+ setFilterState ( {
279
+ ..._ . clone ( filterState ) ,
280
+ groups : group === '' ? [ ] : [ group ] ,
281
+ events : [ ] ,
282
+ } ) ;
283
+ }
252
284
// setFilterState({ ..._.clone(filterState), groups: [value] });
253
285
} }
254
286
options = { communityOps }
255
287
simpleValue
256
- value = { filterState . groups && filterState . groups . length ? filterState . groups [ 0 ] : '' }
288
+ value = { getCommunityOption ( ) }
257
289
valueRenderer = { option => (
258
290
< span styleName = "active-community" >
259
291
{ option . name }
@@ -398,6 +430,7 @@ export default function FiltersPanel({
398
430
tags : [ ] ,
399
431
types : [ ] ,
400
432
groups : [ ] ,
433
+ events : [ ] ,
401
434
endDateStart : null ,
402
435
startDateEnd : null ,
403
436
} ) ;
0 commit comments