@@ -16,7 +16,7 @@ class GradesSection extends React.Component {
16
16
selectedSubmit : "submit" ,
17
17
selectedTeamId : null ,
18
18
rangeMin : 1 ,
19
- rangeMax : 1
19
+ rangeMax : 1 ,
20
20
} ;
21
21
}
22
22
@@ -27,63 +27,53 @@ class GradesSection extends React.Component {
27
27
loadData = ( query = null ) => {
28
28
Promise . all ( [
29
29
get ( "/api/milestones/" ) ,
30
- get (
31
- "/api/teams" ,
32
- query ? { populate : true , searchQuery : query } : { populate : true }
33
- )
30
+ get ( "/api/teams" , query ? { populate : true , searchQuery : query } : { populate : true } ) ,
34
31
] )
35
- . then ( data => {
32
+ . then ( ( data ) => {
36
33
this . setState ( {
37
34
loading : false ,
38
35
milestones : data [ 0 ] ,
39
36
allTeams : data [ 1 ] ,
40
37
selectedTeams : data [ 1 ] , //TODO how will this integrate with search?
41
- rangeMax : data [ 1 ] . length
38
+ rangeMax : data [ 1 ] . length ,
42
39
} ) ;
43
40
} )
44
- . catch ( err => console . log ( err ) ) ;
41
+ . catch ( ( err ) => console . log ( err ) ) ;
45
42
} ;
46
43
47
- updateRange = event => {
44
+ updateRange = ( event ) => {
48
45
const target = event . target ;
49
- const value =
50
- target . type === "number" ? parseInt ( target . value ) : target . value ;
46
+ const value = target . type === "number" ? parseInt ( target . value ) : target . value ;
51
47
this . setState ( {
52
- [ target . name ] : value
48
+ [ target . name ] : value ,
53
49
} ) ;
54
50
} ;
55
51
56
- updateSelectedTeams = event => {
52
+ updateSelectedTeams = ( event ) => {
57
53
const { allTeams } = this . state ;
58
54
const selectedMilestoneId = event . target . value ;
59
55
let newSelectedTeams = allTeams ;
60
56
console . log ( "selected:" + selectedMilestoneId ) ;
61
57
if ( selectedMilestoneId !== "" ) {
62
- newSelectedTeams = allTeams . filter ( team => {
58
+ newSelectedTeams = allTeams . filter ( ( team ) => {
63
59
return hasSubmission ( team , selectedMilestoneId ) ;
64
60
} ) ;
65
61
}
66
62
67
63
this . setState ( {
68
64
selectedTeams : newSelectedTeams ,
69
65
rangeMax : newSelectedTeams . length == 0 ? 1 : newSelectedTeams . length ,
70
- rangeMin : 1
66
+ rangeMin : 1 ,
71
67
} ) ;
72
68
} ;
73
69
74
- showMilestonesSection = teamId => {
70
+ showMilestonesSection = ( teamId ) => {
75
71
this . setState ( { selectedTeamId : teamId } ) ;
76
72
this . props . toggleViewMilestones ( ) ;
77
73
} ;
78
74
79
75
render ( ) {
80
- const {
81
- loading,
82
- milestones,
83
- selectedTeams,
84
- rangeMin,
85
- rangeMax
86
- } = this . state ;
76
+ const { loading, milestones, selectedTeams, rangeMin, rangeMax } = this . state ;
87
77
88
78
if ( loading ) {
89
79
return < div > Loading!</ div > ;
@@ -113,11 +103,7 @@ class GradesSection extends React.Component {
113
103
milestones = { milestones }
114
104
teams = { selectedTeams }
115
105
rangeMin = { Number . isNaN ( rangeMin ) ? 1 : rangeMin }
116
- rangeMax = {
117
- Number . isNaN ( rangeMax ) || rangeMax < rangeMin
118
- ? rangeMin + 1
119
- : rangeMax
120
- }
106
+ rangeMax = { Number . isNaN ( rangeMax ) || rangeMax < rangeMin ? rangeMin + 1 : rangeMax }
121
107
showMilestonesSection = { this . showMilestonesSection }
122
108
/>
123
109
</ div >
0 commit comments