@@ -21,7 +21,7 @@ import { changeDrawer } from '../../store/actions/mainActions';
21
21
import { StoreModel } from '../../models/storeModel' ;
22
22
import PeopleAltOutlinedIcon from '@material-ui/icons/PeopleAltOutlined' ;
23
23
import { useHistory , useLocation } from 'react-router' ;
24
- import { adminRoutes , routes } from '../../utils/routes' ;
24
+ import { adminRoutes , reportsRoutes , routes } from '../../utils/routes' ;
25
25
import ExpandLess from '@material-ui/icons/ExpandLess' ;
26
26
import ExpandMore from '@material-ui/icons/ExpandMore' ;
27
27
import { useState } from 'react' ;
@@ -35,6 +35,7 @@ import PlaylistAddCheckIcon from '@material-ui/icons/PlaylistAddCheck';
35
35
import EmojiPeopleIcon from '@material-ui/icons/EmojiPeople' ;
36
36
import AttachMoneyIcon from '@material-ui/icons/AttachMoney' ;
37
37
import PointOfSaleIcon from '@mui/icons-material/PointOfSale' ;
38
+ import AssessmentIcon from '@mui/icons-material/Assessment' ;
38
39
39
40
const Appbar = ( ) => {
40
41
const open = useSelector ( ( state : StoreModel ) => state . mainStore . isDrawerOpen ) ;
@@ -45,11 +46,16 @@ const Appbar = () => {
45
46
const history = useHistory ( ) ;
46
47
const location = useLocation ( ) ;
47
48
const [ openSubMenu , setOpenSubMenu ] = useState ( false ) ;
49
+ const [ openReports , setOpenReports ] = useState ( false ) ;
48
50
49
51
const handleOpenSubmenu = ( ) => {
50
52
setOpenSubMenu ( ! openSubMenu ) ;
51
53
} ;
52
54
55
+ const handleReportsMenu = ( ) => {
56
+ setOpenReports ( ! openReports ) ;
57
+ } ;
58
+
53
59
const handleChange = ( ) => {
54
60
dispatch ( changeDrawer ( ! open ) ) ;
55
61
} ;
@@ -127,9 +133,56 @@ const Appbar = () => {
127
133
</ ListItem >
128
134
) ) }
129
135
136
+ < ListItem
137
+ button
138
+ onClick = { handleReportsMenu }
139
+ className = {
140
+ location . pathname === '/reports'
141
+ ? 'menu__item menu__item_selected'
142
+ : 'menu__item'
143
+ }
144
+ >
145
+ < ListItemIcon >
146
+ < AssessmentIcon />
147
+ </ ListItemIcon >
148
+ < ListItemText primary = "Отчеты" />
149
+ { openReports ? < ExpandLess /> : < ExpandMore /> }
150
+ </ ListItem >
151
+
152
+ < Collapse in = { openReports } unmountOnExit >
153
+ < List component = "div" disablePadding className = "menu__nested" >
154
+ { reportsRoutes . map ( ( route , index ) => (
155
+ < ListItem
156
+ key = { index }
157
+ button
158
+ onClick = { ( ) => navigateTo ( route . path ) }
159
+ selected = { location . pathname === route . path }
160
+ className = {
161
+ location . pathname === route . path
162
+ ? 'menu__item menu__item_selected'
163
+ : 'menu__item'
164
+ }
165
+ >
166
+ < ListItemIcon >
167
+ { route . code === 'requestsReport' && < WorkIcon /> }
168
+ </ ListItemIcon >
169
+ < ListItemText primary = { route . name } />
170
+ </ ListItem >
171
+ ) ) }
172
+ </ List >
173
+ </ Collapse >
174
+
130
175
{ ( userRoleCode === 'ADMIN' || userRoleCode === 'SUPER_ADMIN' ) && (
131
176
< >
132
- < ListItem button onClick = { handleOpenSubmenu } >
177
+ < ListItem
178
+ button
179
+ onClick = { handleOpenSubmenu }
180
+ className = {
181
+ location . pathname === '/administration'
182
+ ? 'menu__item menu__item_selected'
183
+ : 'menu__item'
184
+ }
185
+ >
133
186
< ListItemIcon >
134
187
< SettingsIcon />
135
188
</ ListItemIcon >
0 commit comments