|
@@ -25,28 +25,19 @@ import SupportAgentIcon from '@mui/icons-material/SupportAgent';
|
25
|
25
|
import Collapse from '@mui/material/Collapse';
|
26
|
26
|
import ExpandLess from '@mui/icons-material/ExpandLess';
|
27
|
27
|
import ExpandMore from '@mui/icons-material/ExpandMore';
|
28
|
|
-import { useNavigate } from 'react-router-dom'
|
29
|
|
-
|
30
|
|
-const SubMenuList = [5,6,7,8,9]
|
|
28
|
+import { useNavigate, useResolvedPath, useMatch } from 'react-router-dom'
|
31
|
29
|
|
32
|
30
|
function SubMenuItem (props) {
|
33
|
31
|
|
34
|
32
|
let navigate = useNavigate()
|
35
|
|
-
|
36
|
|
- function change (event){
|
37
|
|
- props.change(event, props.index)
|
38
|
|
- if(props.route){
|
39
|
|
- navigate(props.route)
|
40
|
|
- }
|
41
|
|
- }
|
42
|
|
-
|
43
|
|
- let isOn = props.selected === props.index
|
|
33
|
+ let resolved = useResolvedPath(props.route);
|
|
34
|
+ let match = useMatch({ path: resolved.pathname, end: true });
|
44
|
35
|
|
45
|
36
|
return(
|
46
|
37
|
<ListItem
|
47
|
|
- sx={{ pl: 9}}
|
48
|
|
- selected={isOn}
|
49
|
|
- onClick={change}
|
|
38
|
+ sx={{ pl: 9, color : '#25344f'}}
|
|
39
|
+ selected={match}
|
|
40
|
+ onClick={() => navigate(props.route)}
|
50
|
41
|
button
|
51
|
42
|
>
|
52
|
43
|
<ListItemText
|
|
@@ -62,27 +53,21 @@ function SubMenuItem (props) {
|
62
|
53
|
)
|
63
|
54
|
}
|
64
|
55
|
|
65
|
|
-function Item (props) {
|
66
|
|
-
|
|
56
|
+function NavItem (props) {
|
|
57
|
+
|
67
|
58
|
let navigate = useNavigate()
|
68
|
|
-
|
69
|
|
- function change (event){
|
70
|
|
- console.log('change >>> ', props)
|
71
|
|
- props.change(event, props.index)
|
72
|
|
- navigate(props.route)
|
73
|
|
- }
|
74
|
|
-
|
75
|
|
- let isOn = props.selected === props.index
|
|
59
|
+ let resolved = useResolvedPath(props.route);
|
|
60
|
+ let match = useMatch({ path: resolved.pathname, end: true });
|
76
|
61
|
|
77
|
62
|
return(
|
78
|
63
|
<ListItem
|
79
|
64
|
sx={{ color : '#25344f'}}
|
80
|
|
- selected={isOn}
|
81
|
|
- onClick={change}
|
|
65
|
+ selected={match}
|
|
66
|
+ onClick={() => navigate(props.route) }
|
82
|
67
|
button
|
83
|
68
|
>
|
84
|
69
|
<ListItemIcon>
|
85
|
|
- {props.icon}
|
|
70
|
+ {props.icon && props.icon}
|
86
|
71
|
</ListItemIcon>
|
87
|
72
|
<ListItemText
|
88
|
73
|
sx={{
|
|
@@ -100,36 +85,9 @@ function Item (props) {
|
100
|
85
|
|
101
|
86
|
export const MainListItems = (props) => {
|
102
|
87
|
|
103
|
|
- const [selectedIndex, setSelectedIndex] = React.useState(0);
|
104
|
|
-
|
105
|
|
-
|
106
|
|
- const handleListItemClick = (event, index) => {
|
107
|
|
- setSelectedIndex(index);
|
108
|
|
- };
|
109
|
88
|
|
110
|
89
|
const [open, setOpen] = React.useState(false);
|
111
|
90
|
|
112
|
|
- React.useEffect( () => {
|
113
|
|
-
|
114
|
|
- if(!props.AppBarVisible ){
|
115
|
|
- return setOpen(false)
|
116
|
|
- }
|
117
|
|
-
|
118
|
|
- if( SubMenuList.includes(selectedIndex) && !open ){
|
119
|
|
- if(props.AppBarVisible){
|
120
|
|
- return setOpen(false)
|
121
|
|
- }else{
|
122
|
|
- return setOpen(true)
|
123
|
|
- }
|
124
|
|
- }
|
125
|
|
-
|
126
|
|
- if( !SubMenuList.includes(selectedIndex) && !props.AppBarVisible ){
|
127
|
|
- return setOpen(false)
|
128
|
|
- }
|
129
|
|
-
|
130
|
|
-
|
131
|
|
- }, [props, selectedIndex, open])
|
132
|
|
-
|
133
|
91
|
const showPruebas = () => {
|
134
|
92
|
if(!props.AppBarVisible){
|
135
|
93
|
props.setAppBarVisible(true);
|
|
@@ -139,14 +97,17 @@ export const MainListItems = (props) => {
|
139
|
97
|
|
140
|
98
|
return(
|
141
|
99
|
<List>
|
|
100
|
+
|
142
|
101
|
<ListSubheader inset>MENÚ</ListSubheader>
|
143
|
|
- <Item icon={<HomeIcon/>} index={0} selected={selectedIndex} change={handleListItemClick} title="Inicio" route="home" />
|
144
|
|
- <Item icon={<WorkIcon/>} index={1} selected={selectedIndex} change={handleListItemClick} title="Puestos" route="puestos" />
|
145
|
|
- <Item icon={<VisibilityOffIcon/>} selected={selectedIndex} change={handleListItemClick} index={2} title="Contraseñas" route="contrasenas" />
|
146
|
|
- <Item icon={<PeopleAltIcon/>} selected={selectedIndex} change={handleListItemClick} index={3} title="Expedientes" route="expedientes" />
|
147
|
|
- <Item icon={<EqualizerIcon/>} selected={selectedIndex} change={handleListItemClick} index={4} title="Resultados" route="resultados" />
|
148
|
102
|
|
149
|
|
- <ListItem selected={ SubMenuList.includes(selectedIndex) } onClick={showPruebas}>
|
|
103
|
+ <NavItem icon={<HomeIcon/>} title="Inicio" route="home" />
|
|
104
|
+ <NavItem icon={<WorkIcon/>} title="Puestos" route="puestos" />
|
|
105
|
+ <NavItem icon={<VisibilityOffIcon/>} index={2} title="Contraseñas" route="contrasenas" />
|
|
106
|
+ <NavItem icon={<PeopleAltIcon/>} title="Expedientes" route="expedientes" />
|
|
107
|
+ <NavItem icon={<EqualizerIcon/>} title="Resultados" route="resultados" />
|
|
108
|
+
|
|
109
|
+ {/*<ListItem selected={false} onClick={showPruebas}>*/}
|
|
110
|
+ <ListItem onClick={showPruebas}>
|
150
|
111
|
<ListItemIcon>
|
151
|
112
|
<FingerprintIcon />
|
152
|
113
|
</ListItemIcon>
|
|
@@ -168,17 +129,17 @@ export const MainListItems = (props) => {
|
168
|
129
|
<Collapse in={open} timeout="auto" unmountOnExit>
|
169
|
130
|
<List component="div" disablePadding>
|
170
|
131
|
|
171
|
|
- <SubMenuItem route="pruebas/crear" selected={selectedIndex} index={5} change={handleListItemClick} title="Crear Prueba" />
|
172
|
|
- <SubMenuItem route="pruebas/listar" change={handleListItemClick} selected={selectedIndex} index={6} title="Listado de pruebas" />
|
173
|
|
- <SubMenuItem route="pruebas/aplicar" selected={selectedIndex} index={7} change={handleListItemClick} title="Aplicar" />
|
174
|
|
- <SubMenuItem selected={selectedIndex} index={8} change={handleListItemClick} title="Respuestas" />
|
175
|
|
- <SubMenuItem selected={selectedIndex} index={9} change={handleListItemClick} title="Calificaciones" />
|
|
132
|
+ <NavItem route="pruebas/crear" title="Crear Prueba" />
|
|
133
|
+ <NavItem route="pruebas/listar" title="Listado de pruebas" />
|
|
134
|
+ <NavItem route="pruebas/aplicar" title="Aplicar" />
|
|
135
|
+ <NavItem route="pruebas/respuestas" title="Respuestas" />
|
|
136
|
+ <NavItem route="pruebas/calificaciones" title="Calificaciones" />
|
176
|
137
|
|
177
|
138
|
</List>
|
178
|
139
|
</Collapse>
|
179
|
140
|
|
180
|
|
- <Item icon={<MiscellaneousServicesIcon/>} selected={selectedIndex} change={handleListItemClick} index={10} title="Configuraciones" route="configuraciones" />
|
181
|
|
- <Item icon={<HistoryIcon/>} selected={selectedIndex} change={handleListItemClick} index={11} title="Historial" route="historial" />
|
|
141
|
+ <NavItem icon={<MiscellaneousServicesIcon/>} title="Configuraciones" route="configuraciones" />
|
|
142
|
+ <NavItem icon={<HistoryIcon/>} title="Historial" route="historial" />
|
182
|
143
|
</List>
|
183
|
144
|
)
|
184
|
145
|
};
|
|
@@ -186,8 +147,8 @@ export const MainListItems = (props) => {
|
186
|
147
|
export const secondaryListItems = (
|
187
|
148
|
<Nav>
|
188
|
149
|
<ListSubheader inset>EXTRAS</ListSubheader>
|
189
|
|
- <Item selected={false} icon={<StarIcon/>} title="Elementos" route="/work" />
|
190
|
|
- <Item selected={false} icon={<OndemandVideoIcon/>} title="Tutoriales" route="/work" />
|
191
|
|
- <Item selected={false} icon={<SupportAgentIcon/>} title="Asistencia Técnica" route="/work" />
|
|
150
|
+ <NavItem selected={false} icon={<StarIcon/>} title="Elementos" route="/work" />
|
|
151
|
+ <NavItem selected={false} icon={<OndemandVideoIcon/>} title="Tutoriales" route="/work" />
|
|
152
|
+ <NavItem selected={false} icon={<SupportAgentIcon/>} title="Asistencia Técnica" route="/work" />
|
192
|
153
|
</Nav>
|
193
|
154
|
);
|