File tree 1 file changed +27
-1
lines changed
src/shared/utils/challenge-listing
1 file changed +27
-1
lines changed Original file line number Diff line number Diff line change @@ -21,7 +21,33 @@ export const SORTS = {
21
21
22
22
export default {
23
23
[ SORTS . CURRENT_PHASE ] : {
24
- func : ( a , b ) => a . status . localeCompare ( b . status ) ,
24
+ func : ( a , b ) => {
25
+ const aPhases = a . phases || [ ] ;
26
+ const bPhases = b . phases || [ ] ;
27
+ const aPhase = aPhases
28
+ . filter ( p => p . name !== 'Registration' && p . isOpen )
29
+ . sort ( ( p1 , p2 ) => moment ( p1 . scheduledEndDate ) . diff ( p2 . scheduledEndDate ) ) [ 0 ] ;
30
+ const bPhase = bPhases
31
+ . filter ( p => p . name !== 'Registration' && p . isOpen )
32
+ . sort ( ( p1 , p2 ) => moment ( p1 . scheduledEndDate ) . diff ( p2 . scheduledEndDate ) ) [ 0 ] ;
33
+
34
+ let aPhaseName = 'Stalled' ;
35
+ let bPhaseName = 'Stalled' ;
36
+ if ( ! aPhase && a . type === 'First2Finish' && aPhases . length ) {
37
+ aPhaseName = 'Submission' ;
38
+ }
39
+ if ( ! bPhase && b . type === 'First2Finish' && bPhases . length ) {
40
+ bPhaseName = 'Submission' ;
41
+ }
42
+
43
+ if ( aPhase ) aPhaseName = aPhase . name ;
44
+ else if ( a . status === 'Draft' ) aPhaseName = 'Draft' ;
45
+
46
+ if ( bPhase ) bPhaseName = bPhase . name ;
47
+ else if ( b . status === 'Draft' ) bPhaseName = 'Draft' ;
48
+
49
+ return aPhaseName . localeCompare ( bPhaseName ) ;
50
+ } ,
25
51
name : 'Current phase' ,
26
52
} ,
27
53
[ SORTS . MOST_RECENT ] : {
You can’t perform that action at this time.
0 commit comments