@@ -245,12 +245,23 @@ class ChallengeList extends Component {
245245 } )
246246 }
247247
248+ renderSortIcon ( currentSortBy ) {
249+ const { sortBy, sortOrder } = this . state
250+ return sortBy === currentSortBy ? (
251+ < img
252+ className = { cn (
253+ styles . sortIcon ,
254+ sortOrder === 'asc' ? styles . asc : ''
255+ ) }
256+ src = { SortIcon }
257+ />
258+ ) : null
259+ }
260+
248261 render ( ) {
249262 const {
250263 searchText,
251264 errorMessage,
252- sortBy,
253- sortOrder,
254265 challengeProjectOption,
255266 challengeStatus,
256267 challengeType,
@@ -593,24 +604,22 @@ class ChallengeList extends Component {
593604 ) }
594605 { challenges . length > 0 && (
595606 < div className = { styles . header } >
596- < div className = { cn ( styles . col5 , styles . sortable ) } >
597- Type
607+ < div
608+ className = { cn ( styles . col5 , styles . sortable ) }
609+ onClick = { ( ) => this . updateSort ( 'type' ) }
610+ >
611+ < span className = { styles . filterItem } >
612+ Type
613+ { this . renderSortIcon ( 'type' ) }
614+ </ span >
598615 </ div >
599616 < div
600617 className = { cn ( styles . col2 , styles . sortable ) }
601618 onClick = { ( ) => this . updateSort ( 'name' ) }
602619 >
603620 < span className = { styles . filterItem } >
604621 Challenge Name
605- { sortBy === 'name' && (
606- < img
607- className = { cn (
608- styles . sortIcon ,
609- sortOrder === 'asc' ? styles . asc : ''
610- ) }
611- src = { SortIcon }
612- />
613- ) }
622+ { this . renderSortIcon ( 'name' ) }
614623 </ span >
615624 </ div >
616625 < div
@@ -619,15 +628,7 @@ class ChallengeList extends Component {
619628 >
620629 < span className = { styles . filterItem } >
621630 Start Date
622- { sortBy === 'startDate' && (
623- < img
624- className = { cn (
625- styles . sortIcon ,
626- sortOrder === 'asc' ? styles . asc : ''
627- ) }
628- src = { SortIcon }
629- />
630- ) }
631+ { this . renderSortIcon ( 'startDate' ) }
631632 </ span >
632633 </ div >
633634 < div
@@ -636,28 +637,39 @@ class ChallengeList extends Component {
636637 >
637638 < span className = { styles . filterItem } >
638639 End Date
639- { sortBy === 'endDate' && (
640- < img
641- className = { cn (
642- styles . sortIcon ,
643- sortOrder === 'asc' ? styles . asc : ''
644- ) }
645- src = { SortIcon }
646- />
647- ) }
640+ { this . renderSortIcon ( 'endDate' ) }
648641 </ span >
649642 </ div >
650- < div className = { cn ( styles . col4 , styles . sortable ) } >
643+ < div
644+ className = { cn ( styles . col4 , styles . sortable ) }
645+ onClick = { ( ) => this . updateSort ( 'numOfRegistrants' ) }
646+ >
651647 < span className = { styles . filterItem } >
652648 < FontAwesomeIcon icon = { faUser } className = { styles . faIcon } />
649+ { this . renderSortIcon ( 'numOfRegistrants' ) }
653650 </ span >
654651 </ div >
655- < div className = { cn ( styles . col4 , styles . sortable ) } >
656- < FontAwesomeIcon icon = { faFile } className = { styles . faIcon } />
652+ < div
653+ className = { cn ( styles . col4 , styles . sortable ) }
654+ onClick = { ( ) => this . updateSort ( 'numOfSubmissions' ) }
655+ >
656+ < span className = { styles . filterItem } >
657+ < FontAwesomeIcon icon = { faFile } className = { styles . faIcon } />
658+ { this . renderSortIcon ( 'numOfSubmissions' ) }
659+ </ span >
657660 </ div >
658- < div className = { cn ( styles . col4 , styles . sortable ) } > Forums</ div >
659- < div className = { cn ( styles . col3 , styles . sortable ) } > Status</ div >
660- < div className = { styles . col6 } />
661+ < div
662+ className = { cn ( styles . col3 , styles . sortable ) }
663+ onClick = { ( ) => this . updateSort ( 'status' ) }
664+ >
665+ < span className = { styles . filterItem } >
666+ Status
667+ { this . renderSortIcon ( 'status' ) }
668+ </ span >
669+ </ div >
670+ < div className = { styles . col6 } > </ div >
671+ < div className = { styles . col6 } > </ div >
672+ < div className = { styles . col6 } > </ div >
661673 < div className = { styles . col6 } />
662674 < div className = { styles . col6 } />
663675 </ div >
0 commit comments