瀏覽代碼

list item refactor and use node v16

amenpunk 3 年之前
父節點
當前提交
e5e1936e38
共有 9 個文件被更改,包括 10357 次插入18157 次删除
  1. 2 2
      Jenkinsfile
  2. 10296 18059
      package-lock.json
  3. 4 2
      package.json
  4. 4 1
      src/Components/Dashboard.js
  5. 0 4
      src/Components/PrivateRoute.js
  6. 2 2
      src/Components/Routes.js
  7. 32 71
      src/Components/listItems.js
  8. 2 1
      src/Pages/Login.jsx
  9. 15 15
      src/Pages/PruebaNueva.jsx

+ 2 - 2
Jenkinsfile

12
         }
12
         }
13
         stage('install dependencies') {
13
         stage('install dependencies') {
14
             steps {
14
             steps {
15
-                nvm( version : '14.18.3' ){
15
+                nvm( version : '16.13.2' ){
16
                     sh 'npm install'
16
                     sh 'npm install'
17
                 }
17
                 }
18
             }
18
             }
19
         }
19
         }
20
         stage('build') {
20
         stage('build') {
21
             steps {
21
             steps {
22
-                nvm( version : '14.18.3' ){
22
+                nvm( version : '16.13.2' ){
23
                     sh 'npm run build'
23
                     sh 'npm run build'
24
                 }
24
                 }
25
             }
25
             }

文件差異過大導致無法顯示
+ 10296 - 18059
package-lock.json


+ 4 - 2
package.json

1
 {
1
 {
2
-  "homepage": "http://clubdit.ditca.org/psicoadmin/",
3
   "name": "psicoadmin",
2
   "name": "psicoadmin",
4
   "version": "0.1.0",
3
   "version": "0.1.0",
5
   "private": true,
4
   "private": true,
22
     "react-dom": "^17.0.2",
21
     "react-dom": "^17.0.2",
23
     "react-router": "6.2.1",
22
     "react-router": "6.2.1",
24
     "react-router-dom": "6.2.1",
23
     "react-router-dom": "6.2.1",
25
-    "react-scripts": "4.0.3",
24
+    "react-scripts": "^5.0.0",
26
     "web-vitals": "^1.0.1",
25
     "web-vitals": "^1.0.1",
27
     "yup": "^0.32.11"
26
     "yup": "^0.32.11"
28
   },
27
   },
28
+  "resolutions": {
29
+    "react-error-overlay": "6.0.9"
30
+  },
29
   "scripts": {
31
   "scripts": {
30
     "start": "react-scripts start",
32
     "start": "react-scripts start",
31
     "build": "react-scripts build",
33
     "build": "react-scripts build",

+ 4 - 1
src/Components/Dashboard.js

250
                     </Toolbar>
250
                     </Toolbar>
251
                     <Divider />
251
                     <Divider />
252
                     <List>
252
                     <List>
253
-                        <MainListItems AppBarVisible={open}  setAppBarVisible={setOpen} />
253
+                        <MainListItems 
254
+                            AppBarVisible={open}  
255
+                            setAppBarVisible={setOpen} 
256
+                        />
254
                     </List>
257
                     </List>
255
                     <Divider />
258
                     <Divider />
256
                     <List>
259
                     <List>

+ 0 - 4
src/Components/PrivateRoute.js

4
 export default function RequireAuth({ children }) {
4
 export default function RequireAuth({ children }) {
5
     let auth = useAuth();
5
     let auth = useAuth();
6
     let location = useLocation();
6
     let location = useLocation();
7
-
8
-    console.log('check if is logged in private route ')
9
-
10
     if (!auth.isLogged()) {
7
     if (!auth.isLogged()) {
11
         return <Navigate to="/login" state={{ from: location }} replace />;
8
         return <Navigate to="/login" state={{ from: location }} replace />;
12
     }
9
     }
13
-
14
     return children;
10
     return children;
15
 }
11
 }
16
 
12
 

+ 2 - 2
src/Components/Routes.js

1
-import React, {useEffect} from 'react'
2
-import { Routes, Route,useNavigate, Navigate } from "react-router-dom";
1
+import React from 'react'
2
+import { Routes, Route, Navigate } from "react-router-dom";
3
 
3
 
4
 import { Dashboard } from "./Dashboard";
4
 import { Dashboard } from "./Dashboard";
5
 import { Login } from '../Pages/Login'
5
 import { Login } from '../Pages/Login'

+ 32 - 71
src/Components/listItems.js

25
 import Collapse from '@mui/material/Collapse';
25
 import Collapse from '@mui/material/Collapse';
26
 import ExpandLess from '@mui/icons-material/ExpandLess';
26
 import ExpandLess from '@mui/icons-material/ExpandLess';
27
 import ExpandMore from '@mui/icons-material/ExpandMore';
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
 function SubMenuItem (props) {
30
 function SubMenuItem (props) {
33
 
31
 
34
     let navigate = useNavigate()
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
     return(
36
     return(
46
         <ListItem 
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
             button
41
             button
51
         >
42
         >
52
             <ListItemText 
43
             <ListItemText 
62
     )
53
     )
63
 }
54
 }
64
 
55
 
65
-function Item (props) {
66
-
56
+function NavItem (props) {
57
+    
67
     let navigate = useNavigate()
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
     return(
62
     return(
78
         <ListItem
63
         <ListItem
79
             sx={{ color : '#25344f'}}
64
             sx={{ color : '#25344f'}}
80
-            selected={isOn}
81
-            onClick={change} 
65
+            selected={match}
66
+            onClick={() => navigate(props.route) } 
82
             button
67
             button
83
         >
68
         >
84
             <ListItemIcon>
69
             <ListItemIcon>
85
-                {props.icon}
70
+                {props.icon && props.icon}
86
             </ListItemIcon>
71
             </ListItemIcon>
87
             <ListItemText 
72
             <ListItemText 
88
                 sx={{
73
                 sx={{
100
 
85
 
101
 export const MainListItems = (props) =>  {
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
     const [open, setOpen] = React.useState(false);
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
     const showPruebas = () => {
91
     const showPruebas = () => {
134
         if(!props.AppBarVisible){
92
         if(!props.AppBarVisible){
135
             props.setAppBarVisible(true);
93
             props.setAppBarVisible(true);
139
 
97
 
140
     return(
98
     return(
141
         <List>
99
         <List>
100
+
142
             <ListSubheader inset>MENÚ</ListSubheader>
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
                 <ListItemIcon>
111
                 <ListItemIcon>
151
                     <FingerprintIcon />
112
                     <FingerprintIcon />
152
                 </ListItemIcon>
113
                 </ListItemIcon>
168
             <Collapse in={open} timeout="auto" unmountOnExit>
129
             <Collapse in={open} timeout="auto" unmountOnExit>
169
                 <List component="div" disablePadding>
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
                 </List>
138
                 </List>
178
             </Collapse>
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
         </List>
143
         </List>
183
     )
144
     )
184
 };
145
 };
186
 export const secondaryListItems = (
147
 export const secondaryListItems = (
187
     <Nav>
148
     <Nav>
188
         <ListSubheader inset>EXTRAS</ListSubheader>
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
     </Nav>
153
     </Nav>
193
 );
154
 );

+ 2 - 1
src/Pages/Login.jsx

47
     };
47
     };
48
 
48
 
49
     React.useEffect(() => {
49
     React.useEffect(() => {
50
+        console.log(auth)
50
         if(auth.isLogged()){
51
         if(auth.isLogged()){
51
             return navigate('/dashboard/home')
52
             return navigate('/dashboard/home')
52
         }    
53
         }    
53
-    }, [])
54
+    }, [auth,navigate])
54
 
55
 
55
 
56
 
56
     return (
57
     return (

+ 15 - 15
src/Pages/PruebaNueva.jsx

153
                                             <div className="respuesta_pregunta">
153
                                             <div className="respuesta_pregunta">
154
                                                 <div className="radio">
154
                                                 <div className="radio">
155
                                                         <input onChange={(event)=> console.log(event.target.value)} id="true" type="radio" name="gender" value="true" />
155
                                                         <input onChange={(event)=> console.log(event.target.value)} id="true" type="radio" name="gender" value="true" />
156
-                                                        <label for="true">Verdadero</label>
156
+                                                        <label htmlFor="true">Verdadero</label>
157
                                                         <input id="false" type="radio" name="gender" value="false"/>
157
                                                         <input id="false" type="radio" name="gender" value="false"/>
158
-                                                        <label for="false">Falso</label>
158
+                                                        <label htmlFor="false">Falso</label>
159
                                                 </div>
159
                                                 </div>
160
                                             </div>
160
                                             </div>
161
                                         </div>
161
                                         </div>
166
                                             <div className="respuesta_pregunta">
166
                                             <div className="respuesta_pregunta">
167
                                                 <div className="radio">
167
                                                 <div className="radio">
168
                                                         <input id="opcion1" type="radio" name="gender" value="opcion1"/>
168
                                                         <input id="opcion1" type="radio" name="gender" value="opcion1"/>
169
-                                                        <label for="opcion1">Opción 1</label>
169
+                                                        <label htmlFor="opcion1">Opción 1</label>
170
                                                         <input id="opcion2" type="radio" name="gender" value="opcion2" />
170
                                                         <input id="opcion2" type="radio" name="gender" value="opcion2" />
171
-                                                        <label for="opcion2">Opción 2</label>
171
+                                                        <label htmlFor="opcion2">Opción 2</label>
172
                                                         <input id="opcion3" type="radio" name="gender" value="opcion3"/>
172
                                                         <input id="opcion3" type="radio" name="gender" value="opcion3"/>
173
-                                                        <label for="opcion3">Opción 3</label>
173
+                                                        <label htmlFor="opcion3">Opción 3</label>
174
                                                         <input id="opcion4" type="radio" name="gender" value="opcion4"/>
174
                                                         <input id="opcion4" type="radio" name="gender" value="opcion4"/>
175
-                                                        <label for="opcion4">Opción 4</label>
175
+                                                        <label htmlFor="opcion4">Opción 4</label>
176
                                                         <input id="opcion5" type="radio" name="gender" value="opcion5"/>
176
                                                         <input id="opcion5" type="radio" name="gender" value="opcion5"/>
177
-                                                        <label for="opcion5">Opción 5</label>
177
+                                                        <label htmlFor="opcion5">Opción 5</label>
178
                                                 </div>
178
                                                 </div>
179
                                             </div>
179
                                             </div>
180
                                         </div>
180
                                         </div>
183
                                                 <span>Pregunta 4</span><input type="text" name="pregunta" placeholder="Ve la siguiente imagen y encuentra la faltante" className="input_pregunta"/>
183
                                                 <span>Pregunta 4</span><input type="text" name="pregunta" placeholder="Ve la siguiente imagen y encuentra la faltante" className="input_pregunta"/>
184
                                                 <div className="button_subir_foto_pregunta">
184
                                                 <div className="button_subir_foto_pregunta">
185
                                                         <div className="form-group">
185
                                                         <div className="form-group">
186
-                                                            <label style={{ color : 'white' }} for="upload" className="btn d-inline-block btn-info">Subir imagen</label>
186
+                                                            <label style={{ color : 'white' }} htmlFor="upload" className="btn d-inline-block btn-info">Subir imagen</label>
187
                                                             <input type="file" name="" id="upload" />
187
                                                             <input type="file" name="" id="upload" />
188
                                                         </div>
188
                                                         </div>
189
                                                 </div>
189
                                                 </div>
194
                                             <div className="respuesta_pregunta">
194
                                             <div className="respuesta_pregunta">
195
                                                 <div className="button_subir_foto_pregunta">
195
                                                 <div className="button_subir_foto_pregunta">
196
                                                         <div className="form-group">
196
                                                         <div className="form-group">
197
-                                                            <label style={{  color : 'white' }} for="upload" className="btn d-inline-block btn-info">Añadir respuesta</label>
197
+                                                            <label style={{  color : 'white' }} htmlFor="upload" className="btn d-inline-block btn-info">Añadir respuesta</label>
198
                                                             <input type="file" name="" id="upload" />
198
                                                             <input type="file" name="" id="upload" />
199
                                                         </div>
199
                                                         </div>
200
                                                 </div>
200
                                                 </div>
201
                                                     <div id="sites">
201
                                                     <div id="sites">
202
-                                                        <input type="radio" name="site" id="option1" value="option1" />A.<label for="option1"><img src={Respuesta1} alt="Opción 1" /></label>
203
-                                                        <input type="radio" name="site" id="option2" value="option2" />B.<label for="option2"><img src={Respuesta2} alt="Opción 2" /></label>
204
-                                                        <input type="radio" name="site" id="option3" value="option3" />C.<label for="option3"><img src={Respuesta3} alt="Opción 3" /></label>
205
-                                                        <input type="radio" name="site" id="option1" value="option1" />D.<label for="option1"><img src={Respuesta1} alt="Opción 1" /></label>
206
-                                                        <input type="radio" name="site" id="option2" value="option2" />E.<label for="option2"><img src={Respuesta2} alt="Opción 2" /></label>
207
-                                                        <input type="radio" name="site" id="option3" value="option3" />F.<label for="option3"><img src={Respuesta3} alt="Opción 3" /></label>
202
+                                                        <input type="radio" name="site" id="option1" value="option1" />A.<label htmlFor="option1"><img src={Respuesta1} alt="Opción 1" /></label>
203
+                                                        <input type="radio" name="site" id="option2" value="option2" />B.<label htmlFor="option2"><img src={Respuesta2} alt="Opción 2" /></label>
204
+                                                        <input type="radio" name="site" id="option3" value="option3" />C.<label htmlFor="option3"><img src={Respuesta3} alt="Opción 3" /></label>
205
+                                                        <input type="radio" name="site" id="option1" value="option1" />D.<label htmlFor="option1"><img src={Respuesta1} alt="Opción 1" /></label>
206
+                                                        <input type="radio" name="site" id="option2" value="option2" />E.<label htmlFor="option2"><img src={Respuesta2} alt="Opción 2" /></label>
207
+                                                        <input type="radio" name="site" id="option3" value="option3" />F.<label htmlFor="option3"><img src={Respuesta3} alt="Opción 3" /></label>
208
                                                     </div>
208
                                                     </div>
209
                                             </div>
209
                                             </div>
210
                                             <div className="form-group-guardar-prueba">
210
                                             <div className="form-group-guardar-prueba">