1
1
import React from "react" ;
2
- import globalHook from ' use-global-hook' ;
2
+ import globalHook from " use-global-hook" ;
3
3
import { classNames } from "react-extras" ;
4
4
import { useHistory } from "react-router-dom" ;
5
5
6
- import { makeStyles , useTheme } from ' @material-ui/core/styles' ;
7
- import Avatar from ' @material-ui/core/Avatar' ;
8
- import Divider from ' @material-ui/core/Divider' ;
9
- import Drawer from ' @material-ui/core/Drawer' ;
10
- import IconButton from ' @material-ui/core/IconButton' ;
11
- import List from ' @material-ui/core/List' ;
12
- import ListItem from ' @material-ui/core/ListItem' ;
13
- import ListItemIcon from ' @material-ui/core/ListItemIcon' ;
14
- import ListItemText from ' @material-ui/core/ListItemText' ;
6
+ import { makeStyles , useTheme } from " @material-ui/core/styles" ;
7
+ import Avatar from " @material-ui/core/Avatar" ;
8
+ import Divider from " @material-ui/core/Divider" ;
9
+ import Drawer from " @material-ui/core/Drawer" ;
10
+ import IconButton from " @material-ui/core/IconButton" ;
11
+ import List from " @material-ui/core/List" ;
12
+ import ListItem from " @material-ui/core/ListItem" ;
13
+ import ListItemIcon from " @material-ui/core/ListItemIcon" ;
14
+ import ListItemText from " @material-ui/core/ListItemText" ;
15
15
16
- import ChevronRightIcon from '@material-ui/icons/ChevronRight' ;
17
- import ChevronLeftIcon from '@material-ui/icons/ChevronLeft' ;
18
- import ExitToAppIcon from '@material-ui/icons/ExitToApp' ;
19
- import GroupIcon from '@material-ui/icons/Group' ;
20
- import SettingsIcon from '@material-ui/icons/Settings' ;
21
- import SupervisorAccountIcon from '@material-ui/icons/SupervisorAccount' ;
16
+ import ChevronRightIcon from "@material-ui/icons/ChevronRight" ;
17
+ import ChevronLeftIcon from "@material-ui/icons/ChevronLeft" ;
18
+ import ExitToAppIcon from "@material-ui/icons/ExitToApp" ;
19
+ import GroupIcon from "@material-ui/icons/Group" ;
20
+ import SettingsIcon from "@material-ui/icons/Settings" ;
21
+ import SupervisorAccountIcon from "@material-ui/icons/SupervisorAccount" ;
22
+ import EmojiEventsIcon from "@material-ui/icons/EmojiEvents" ;
22
23
// import InboxIcon from '@material-ui/icons/Inbox';
23
24
// import MailIcon from '@material-ui/icons/Mail';
24
25
25
- import { useUserState } from ' ./auth' ;
26
+ import { useUserState } from " ./auth" ;
26
27
27
- const useStyles = makeStyles ( theme => ( {
28
+ const useStyles = makeStyles ( ( theme ) => ( {
28
29
drawer : {
29
30
flexShrink : 0 ,
30
- whiteSpace : ' nowrap' ,
31
+ whiteSpace : " nowrap" ,
31
32
} ,
32
33
drawerOpen : {
33
- width : drawerWidth => drawerWidth ,
34
- transition : theme . transitions . create ( ' width' , {
34
+ width : ( drawerWidth ) => drawerWidth ,
35
+ transition : theme . transitions . create ( " width" , {
35
36
easing : theme . transitions . easing . sharp ,
36
37
duration : theme . transitions . duration . enteringScreen ,
37
38
} ) ,
38
39
} ,
39
40
drawerClose : {
40
- transition : theme . transitions . create ( ' width' , {
41
+ transition : theme . transitions . create ( " width" , {
41
42
easing : theme . transitions . easing . sharp ,
42
43
duration : theme . transitions . duration . leavingScreen ,
43
44
} ) ,
44
- overflowX : ' hidden' ,
45
+ overflowX : " hidden" ,
45
46
width : theme . spacing ( 7 ) + 1 ,
46
- [ theme . breakpoints . up ( 'sm' ) ] : {
47
+ [ theme . breakpoints . up ( "sm" ) ] : {
47
48
width : theme . spacing ( 9 ) + 1 ,
48
49
} ,
49
50
} ,
50
51
toolbar : {
51
- display : ' flex' ,
52
- alignItems : ' center' ,
53
- justifyContent : ' flex-end' ,
52
+ display : " flex" ,
53
+ alignItems : " center" ,
54
+ justifyContent : " flex-end" ,
54
55
padding : theme . spacing ( 0 , 1 ) ,
55
56
...theme . mixins . toolbar ,
56
57
} ,
57
58
} ) ) ;
58
59
59
60
const initialState = {
60
61
open : false ,
61
- drawerWidth : 240
62
+ drawerWidth : 240 ,
62
63
} ;
63
64
64
65
const actions = {
65
66
toggleDrawer : ( store ) => {
66
67
store . setState ( {
67
- open : ! store . state . open
68
+ open : ! store . state . open ,
68
69
} ) ;
69
70
} ,
70
71
openDrawer : ( store ) => {
71
72
store . setState ( {
72
- open : true
73
+ open : true ,
73
74
} ) ;
74
75
} ,
75
76
closeDrawer : ( store ) => {
76
77
store . setState ( {
77
- open : false
78
+ open : false ,
78
79
} ) ;
79
80
} ,
80
81
} ;
@@ -94,82 +95,102 @@ export default function AppDrawer(props) {
94
95
history . push ( entry . path ) ;
95
96
}
96
97
97
- const menuItems = [ {
98
- icon : GroupIcon ,
99
- text : 'Your Teams' ,
100
- path : '/team'
101
- } , {
102
- icon : GroupIcon ,
103
- text : 'All Teams' ,
104
- path : '/team/list'
105
- } , {
106
- icon : SettingsIcon ,
107
- text : 'Manage Team' ,
108
- path : '/team/manage'
109
- } ,
110
- 'divider' ,
111
- {
112
- icon : ExitToAppIcon ,
113
- text : 'Logout' ,
114
- path : '/logout'
115
- } ] ;
98
+ const menuItems = [
99
+ {
100
+ icon : EmojiEventsIcon ,
101
+ text : "Top Players" ,
102
+ path : "/top" ,
103
+ } ,
104
+ {
105
+ icon : GroupIcon ,
106
+ text : "Your Teams" ,
107
+ path : "/team" ,
108
+ } ,
109
+ {
110
+ icon : GroupIcon ,
111
+ text : "All Teams" ,
112
+ path : "/team/list" ,
113
+ } ,
114
+ {
115
+ icon : SettingsIcon ,
116
+ text : "Manage Team" ,
117
+ path : "/team/manage" ,
118
+ } ,
119
+ "divider" ,
120
+ {
121
+ icon : ExitToAppIcon ,
122
+ text : "Logout" ,
123
+ path : "/logout" ,
124
+ } ,
125
+ ] ;
116
126
117
127
if ( userState . user . isAdmin ) {
118
128
const logout = menuItems . pop ( ) ;
119
129
menuItems . push ( {
120
130
icon : SupervisorAccountIcon ,
121
- text : ' Admin' ,
122
- path : ' /admin'
131
+ text : " Admin" ,
132
+ path : " /admin" ,
123
133
} ) ;
124
- menuItems . push ( ' divider' )
134
+ menuItems . push ( " divider" ) ;
125
135
menuItems . push ( logout ) ;
126
136
}
127
137
128
138
return (
129
139
< Drawer
130
- variant = "permanent"
131
- className = { classNames ( classes . drawer , {
140
+ variant = "permanent"
141
+ className = { classNames ( classes . drawer , {
142
+ [ classes . drawerOpen ] : open ,
143
+ [ classes . drawerClose ] : ! open ,
144
+ } ) }
145
+ classes = { {
146
+ paper : classNames ( {
132
147
[ classes . drawerOpen ] : open ,
133
148
[ classes . drawerClose ] : ! open ,
134
- } ) }
135
- classes = { {
136
- paper : classNames ( {
137
- [ classes . drawerOpen ] : open ,
138
- [ classes . drawerClose ] : ! open ,
139
- } ) ,
140
- } }
141
- open = { open }
142
- >
143
- < div className = { classes . toolbar } >
144
- < IconButton onClick = { drawerActions . closeDrawer } >
145
- { theme . direction === 'rtl' ? < ChevronRightIcon /> : < ChevronLeftIcon /> }
146
- </ IconButton >
147
- </ div >
148
- < Divider />
149
- < List >
150
- < ListItem button onClick = { ( ) => handleMenuEntry ( { path : '/' } ) } >
149
+ } ) ,
150
+ } }
151
+ open = { open }
152
+ >
153
+ < div className = { classes . toolbar } >
154
+ < IconButton onClick = { drawerActions . closeDrawer } >
155
+ { theme . direction === "rtl" ? (
156
+ < ChevronRightIcon />
157
+ ) : (
158
+ < ChevronLeftIcon />
159
+ ) }
160
+ </ IconButton >
161
+ </ div >
162
+ < Divider />
163
+ < List >
164
+ < ListItem button onClick = { ( ) => handleMenuEntry ( { path : "/" } ) } >
165
+ < ListItemIcon >
166
+ < Avatar
167
+ alt = { userState . user . profile . name }
168
+ src = { userState . user . profile . avatar }
169
+ />
170
+ </ ListItemIcon >
171
+ < ListItemText
172
+ primary = { userState . user . profile . name }
173
+ secondary = { `MMR: ${ userState . user . mmr } ` }
174
+ />
175
+ </ ListItem >
176
+ { menuItems . map ( ( entry , index ) => {
177
+ if ( entry === "divider" ) {
178
+ return < Divider key = { "divider" + index } /> ;
179
+ }
180
+ return (
181
+ < ListItem
182
+ button
183
+ key = { entry . text }
184
+ onClick = { ( ) => handleMenuEntry ( entry ) }
185
+ >
151
186
< ListItemIcon >
152
- < Avatar
153
- alt = { userState . user . profile . name }
154
- src = { userState . user . profile . avatar }
155
- />
187
+ < entry . icon />
156
188
</ ListItemIcon >
157
- < ListItemText
158
- primary = { userState . user . profile . name }
159
- secondary = { `MMR: ${ userState . user . mmr } ` } />
189
+ < ListItemText primary = { entry . text } />
160
190
</ ListItem >
161
- { menuItems . map ( ( entry , index ) => {
162
- if ( entry === 'divider' ) {
163
- return < Divider key = { 'divider' + index } /> ;
164
- }
165
- return (
166
- < ListItem button key = { entry . text } onClick = { ( ) => handleMenuEntry ( entry ) } >
167
- < ListItemIcon > < entry . icon /> </ ListItemIcon >
168
- < ListItemText primary = { entry . text } />
169
- </ ListItem >
170
- ) ;
171
- } ) }
172
- </ List >
191
+ ) ;
192
+ } ) }
193
+ </ List >
173
194
</ Drawer >
174
195
) ;
175
196
}
0 commit comments