1
- import React , { useEffect } from 'react' ;
1
+ import React , { useEffect , useState } from 'react' ;
2
2
import { Link } from 'react-router-dom' ;
3
3
import { createStyles , makeStyles } from '@material-ui/core/styles' ;
4
4
import Drawer from '@material-ui/core/Drawer' ;
@@ -7,19 +7,31 @@ import ListItem from '@material-ui/core/ListItem';
7
7
import ListItemIcon from '@material-ui/core/ListItemIcon' ;
8
8
import ListItemText from '@material-ui/core/ListItemText' ;
9
9
import SettingsIcon from '@material-ui/icons/Settings' ;
10
- import ExitToAppIcon from '@material-ui/icons/ExitToApp' ;
11
10
import Toolbar from '@material-ui/core/Toolbar' ;
12
11
import { useRouteMatch } from 'react-router' ;
13
- import { Divider , ListSubheader } from '@material-ui/core' ;
12
+ import { Collapse , Divider , ListSubheader } from '@material-ui/core' ;
14
13
15
- import { PieChart as PieChartIcon } from 'react-feather' ;
14
+ import {
15
+ PieChart as PieChartIcon ,
16
+ ShoppingCart as ShoppingCartIcon ,
17
+ ChevronUp as ChevronUpIcon ,
18
+ ChevronDown as ChevronDownIcon ,
19
+ List as ListIcon ,
20
+ FilePlus as FilePlusIcon ,
21
+ LogOut as LogOutIcon ,
22
+ } from 'react-feather' ;
16
23
17
24
const DashboardSidebarNavigation = ( ) => {
18
25
const classes = useStyles ( ) ;
19
26
const { url } = useRouteMatch ( ) ;
27
+ const [ open , setOpen ] = useState ( false ) ;
20
28
21
29
useEffect ( ( ) => { } , [ ] ) ;
22
30
31
+ const handleClick = ( ) => {
32
+ setOpen ( ! open ) ;
33
+ } ;
34
+
23
35
return (
24
36
< >
25
37
< div className = { classes . root } >
@@ -51,18 +63,40 @@ const DashboardSidebarNavigation = () => {
51
63
< ListItemText primary = { 'Dashboard' } />
52
64
</ ListItem >
53
65
</ Link >
54
- < Link className = { classes . link } to = { `${ url } /settings-and-privacy` } >
55
- < ListItem button >
56
- < ListItemIcon >
57
- < SettingsIcon />
58
- </ ListItemIcon >
59
- < ListItemText primary = { 'settings and privacy' } />
60
- </ ListItem >
61
- </ Link >
66
+
67
+ < ListSubheader > Management</ ListSubheader >
68
+ < ListItem button onClick = { handleClick } >
69
+ < ListItemIcon >
70
+ < ShoppingCartIcon />
71
+ </ ListItemIcon >
72
+ < ListItemText primary = "Products" />
73
+ { open ? < ChevronUpIcon /> : < ChevronDownIcon /> }
74
+ </ ListItem >
75
+ < Collapse in = { open } timeout = "auto" unmountOnExit >
76
+ < List component = "div" disablePadding >
77
+ < Link className = { classes . link } to = { `${ url } /list-products` } >
78
+ < ListItem button className = { classes . nested } >
79
+ < ListItemIcon >
80
+ < ListIcon />
81
+ </ ListItemIcon >
82
+ < ListItemText primary = "List Products" />
83
+ </ ListItem >
84
+ </ Link >
85
+ < Link className = { classes . link } to = { `${ url } /create-product` } >
86
+ < ListItem button className = { classes . nested } >
87
+ < ListItemIcon >
88
+ < FilePlusIcon />
89
+ </ ListItemIcon >
90
+ < ListItemText primary = "Create Product" />
91
+ </ ListItem >
92
+ </ Link >
93
+ </ List >
94
+ </ Collapse >
95
+
62
96
< a className = { classes . link } href = { '/' } >
63
97
< ListItem button >
64
98
< ListItemIcon >
65
- < ExitToAppIcon />
99
+ < LogOutIcon />
66
100
</ ListItemIcon >
67
101
< ListItemText primary = { 'logout' } />
68
102
</ ListItem >
@@ -106,5 +140,8 @@ const useStyles = makeStyles(theme =>
106
140
textDecoration : 'none' ,
107
141
color : 'inherit' ,
108
142
} ,
143
+ nested : {
144
+ paddingLeft : theme . spacing ( 4 ) ,
145
+ } ,
109
146
} ) ,
110
147
) ;
0 commit comments