浏览代码

modal candi info in home

amenpunk 2 年之前
父节点
当前提交
83f4e1e767

+ 16 - 16
src/Components/Home/Candidato.jsx

@@ -11,47 +11,47 @@ import {
11 11
   Error as ErrorIcon,
12 12
   AssignmentTurnedIn as AssignmentTurnedInIcon
13 13
 } from '@mui/icons-material'
14
-import { useNavigate } from 'react-router-dom'
14
+// import { useNavigate } from 'react-router-dom'
15 15
 
16 16
 import { Col, Row } from 'react-bootstrap'
17 17
 const big_as = 70
18 18
 
19
-function IconStatus(props){
20
-  return(
19
+function IconStatus(props) {
20
+  return (
21 21
     <Tooltip title={props.message}>
22 22
       <IconButton
23 23
         style={{ color: '#0bd641' }}
24 24
         components="label">
25
-        {<props.icon/>}
25
+        {<props.icon />}
26 26
       </IconButton>
27 27
     </Tooltip>
28 28
 
29 29
   )
30 30
 }
31 31
 
32
-function getOperation(estado){
32
+function getOperation(estado) {
33 33
   // Patrik: 100 -> Significa que el examen esta completo
34 34
   // Patrik: 99 -> Que el candidato lo esta haciendo (como "doing test" del otro servicio)
35 35
   // Patrik: 97 ->  Que hay un error y que hay mas respuestas de las que deberian
36 36
   // Patrik: 1 -> Solo esta asignado.
37
-  switch(estado){
37
+  switch (estado) {
38 38
     case 1: // solo asignado
39
-      return <IconStatus icon={AddTaskIcon} message="Candidato Asignado"/>
39
+      return <IconStatus icon={AddTaskIcon} message="Candidato Asignado" />
40 40
     case 97: //error en las respuestas
41
-      return <IconStatus icon={ErrorIcon} message="Hay error en las respuestas"/>
41
+      return <IconStatus icon={ErrorIcon} message="Hay error en las respuestas" />
42 42
     case 99: // el candidato se encuentra realizndolo
43
-      return <IconStatus icon={AssignmentTurnedInIcon} message="El candidato se encuentra realizando la prueba"/>
43
+      return <IconStatus icon={AssignmentTurnedInIcon} message="El candidato se encuentra realizando la prueba" />
44 44
     case 100: // finalizado
45
-      return <IconStatus icon={CheckBoxIcon} message="Calificar el examen"/>
45
+      return <IconStatus icon={CheckBoxIcon} message="Calificar el examen" />
46 46
     default: return null
47 47
   }
48 48
 }
49 49
 
50 50
 function Asignaciones(props) {
51 51
 
52
-  let navigate = useNavigate()
53
-  console.log(props)
54
-  let { estado,cattest, calificacionescleaver: test_result, id: SuperPWD } = props.asign;
52
+  // let navigate = useNavigate()
53
+  let { estado, cattest, calificacionescleaver: test_result, id: SuperPWD } = props.asign;
54
+  console.log(props,test_result,SuperPWD)
55 55
 
56 56
   return (
57 57
     <tr>
@@ -70,7 +70,7 @@ function Asignaciones(props) {
70 70
                 </IconButton>
71 71
               </Tooltip>
72 72
             ) : null
73
-        */}
73
+      */}
74 74
         {
75 75
           getOperation(estado)
76 76
         }
@@ -123,7 +123,7 @@ export function Candidato(props) {
123 123
   return (
124 124
     <div className="data_candidato">
125 125
       <Row>
126
-        <Col md="3" sm="12" style={{ padding: 10, borderRight: '1px solid #f1f1f1' }}>
126
+        <Col onClick={props.onClick}  md="3" sm="12" style={{ padding: 10, borderRight: '1px solid #f1f1f1' }}>
127 127
           <p><b>{password?.toUpperCase()}</b></p>
128 128
         </Col>
129 129
         <Col md="9">
@@ -134,7 +134,6 @@ export function Candidato(props) {
134 134
                   candidatos.length > 0 ?
135 135
                     candidatos.map(u => <TableUser key={u.candi.id} user={u} />)
136 136
                     : <SinAsignRealizadas />
137
-
138 137
                 }
139 138
               </TableBody>
140 139
             </Table>
@@ -145,6 +144,7 @@ export function Candidato(props) {
145 144
   )
146 145
 }
147 146
 
147
+
148 148
 function SinAsignRealizadas() {
149 149
   return (
150 150
     <tr style={{ padding: 5 }}>

+ 17 - 6
src/Components/Home/Candidatos.js

@@ -25,11 +25,10 @@ function fromBase64(text) {
25 25
 
26 26
 export default function Candidatos(props) {
27 27
 
28
-  let { passwords } = props;
28
+  let { passwords, setPassword, setVisible} = props;
29 29
   const [page, setPage] = useState(1);
30 30
   const [users, setUser] = useState([]);
31 31
 
32
-
33 32
   const changePage = (_, value) => {
34 33
     let page_numer = value;
35 34
     Divide(users)
@@ -37,19 +36,22 @@ export default function Candidatos(props) {
37 36
   };
38 37
 
39 38
   useEffect(() => {
40
-
41 39
     let list = passwords.map(pwd => {
42 40
       let { candidatospwds } = pwd
43
-      console.log("CANDI: " , candidatospwds)
44 41
       return {
45 42
         password: fromBase64(pwd.pwd),
46
-        candidatos: candidatospwds
43
+        candidatos: candidatospwds,
44
+        pwd: pwd.pwd,
45
+        plz: pwd.plaza_id
47 46
       }
48 47
     })
49 48
 
50 49
     let divided = Divide(list);
51 50
     setUser(divided)
52 51
 
52
+    // setPassword({})
53
+    // setVisible(true)
54
+
53 55
   }, [passwords])
54 56
 
55 57
   return (
@@ -70,7 +72,16 @@ export default function Candidatos(props) {
70 72
         </div>
71 73
         {
72 74
           users.length
73
-            ? users[page - 1].map((user, i) => (<Candidato key={i} user={user} />))
75
+            ? users[page - 1].map((user, i) => (
76
+              <Candidato 
77
+                onClick={() => {
78
+                  setPassword(user) 
79
+                  setVisible(true) 
80
+                }}
81
+                key={i} 
82
+                user={user} 
83
+              />
84
+            ))
74 85
             : <Preview style={{ paddingTop: 10 }} lenght={10} />
75 86
         }
76 87
         <Row style={{ padding: 5 }}>

+ 68 - 34
src/Components/Password/Operation.jsx

@@ -44,7 +44,7 @@ function Candidatos(props) {
44 44
   });
45 45
 
46 46
 
47
-  let { candidatos, add, remove } = props
47
+  let { candidatos, add, remove, home } = props
48 48
 
49 49
   const formik = useFormik({
50 50
     initialValues: {
@@ -80,12 +80,16 @@ function Candidatos(props) {
80 80
 
81 81
   return (
82 82
     <FormikProvider style={{ padding: 25 }} value={formik}>
83
-      <Typography style={{ padding: 5, marginBottom: 15 }}>Ingresa la informacion del candidato</Typography>
83
+      <Typography style={{ padding: !home? 5: 0, marginBottom: !home? 15: 0 }}>
84
+        { home ? "": "Ingresa la informacion del candidato" }
85
+      </Typography>
84 86
       <Divider />
85 87
       <Form autoComplete="off" noValidate onSubmit={handleSubmit}>
86 88
         <Stack spacing={3}>
87
-          <Stack style={{ paddingTop: 15 }} direction={{ xs: 'column', sm: 'row' }} spacing={2}>
89
+
90
+          <Stack style={{ paddingTop:!home? 15 :0, background:'' }} direction={{ xs: 'column', sm: 'row' }} spacing={2}>
88 91
             <TextField
92
+              style={{ display: home ?'none': 'block',background:'' }}
89 93
               label="Nombre"
90 94
               {...getFieldProps('nombres')}
91 95
               error={Boolean(touched.nombres && errors.nombres)}
@@ -93,6 +97,7 @@ function Candidatos(props) {
93 97
             />
94 98
 
95 99
             <TextField
100
+              style={{ display: home ?'none': 'block' }}
96 101
               label="Apellidos"
97 102
               {...getFieldProps('apellidos')}
98 103
               error={Boolean(touched.apellidos && errors.apellidos)}
@@ -100,8 +105,9 @@ function Candidatos(props) {
100 105
             />
101 106
           </Stack>
102 107
 
103
-          <Stack direction={{ xs: 'column', sm: 'row' }} spacing={2}>
108
+          <Stack style={{ marginTop:0}} direction={{ xs: 'column', sm: 'row' }} spacing={2}>
104 109
             <TextField
110
+              style={{ display: home ?'none': 'block' }}
105 111
               fullWidth
106 112
               type="email"
107 113
               label="Correo Electronico"
@@ -110,13 +116,14 @@ function Candidatos(props) {
110 116
               helperText={touched.mail && errors.mail}
111 117
             />
112 118
 
113
-            <Button type="submit">
119
+            <Button hidden={home} type="submit">
114 120
               <AddCircle style={{ color: 'var(--main)' }} />
115 121
             </Button>
116 122
 
117 123
           </Stack>
118 124
 
119 125
           <MailTable
126
+            home={home}
120 127
             remove={remove}
121 128
             users={candidatos}
122 129
           />
@@ -130,7 +137,7 @@ function Candidatos(props) {
130 137
 export function ModalEdit(props) {
131 138
 
132 139
   const auth = useSelector((state) => state.token)
133
-  let { password, open, handleOpen } = props
140
+  let { password, open, handleOpen, home } = props
134 141
   let { pwd, plz } = password
135 142
 
136 143
   return (
@@ -144,6 +151,7 @@ export function ModalEdit(props) {
144 151
     >
145 152
       <DialogContent>
146 153
         <ModalForm
154
+          home={home}
147 155
           pwdinfo={{ pwd, plz }}
148 156
           closeModal={handleOpen}
149 157
           token={auth.token}
@@ -161,7 +169,7 @@ export function Loading() {
161 169
 
162 170
 function ModalForm(props) {
163 171
 
164
-  let { pwdinfo, closeModal } = props
172
+  let { pwdinfo, closeModal,home } = props
165 173
   const auth = useSelector((state) => state.token)
166 174
   let [candidatos, setCandidatos] = React.useState([]);
167 175
   let [password, setPassword] = React.useState();
@@ -186,8 +194,10 @@ function ModalForm(props) {
186 194
 
187 195
   React.useEffect(() => {
188 196
     let { pwd, plz } = pwdinfo;
197
+    console.log('PWDINOF',{pwd,plz})
198
+
199
+    let rest = new Service(`/contrasenia/${home ? pwd : btoa(pwd)}/${plz}`)
189 200
 
190
-    let rest = new Service(`/contrasenia/${btoa(pwd)}/${plz}`)
191 201
     rest.getQuery(auth.token)
192 202
       .then(resp => {
193 203
 
@@ -212,14 +222,13 @@ function ModalForm(props) {
212 222
       })
213 223
       .catch(error => console.log(error))
214 224
 
215
-  }, [auth.token, pwdinfo, reset])
225
+  }, [auth.token, pwdinfo, reset,home])
216 226
 
217 227
   const saveCandidato = async (body) => {
218 228
     let rest = new Service('/passwordcandidato/candidato')
219 229
     return await rest.postQuery(body, auth.token)
220 230
   }
221 231
 
222
-
223 232
   function onSubmit(fields) {
224 233
 
225 234
     let candi_body = candidatos.map( c => {
@@ -248,7 +257,7 @@ function ModalForm(props) {
248 257
     }
249 258
 
250 259
     rest.putQuery(body_req, auth.token)
251
-      .then( async result => {
260
+      .then( async _result => {
252 261
         queryClient.invalidateQueries('passwords')
253 262
 
254 263
         //TODO: insert into passwordcanidato/candidato 
@@ -279,7 +288,7 @@ function ModalForm(props) {
279 288
   return (
280 289
     <Row>
281 290
       <Col>
282
-        <form style={{ padding: 20, maxWidth: 950 }} onSubmit={handleSubmit(onSubmit)}>
291
+        <form style={{ padding: !home? 20: 0, maxWidth: 950 }} onSubmit={handleSubmit(onSubmit)}>
283 292
           <Stack spacing={4}>
284 293
 
285 294
             <TextField
@@ -299,22 +308,28 @@ function ModalForm(props) {
299 308
                 type="text"
300 309
                 disabled
301 310
               />
302
-              <FormControlLabel
303
-                label="Activo?"
304
-                control={
305
-                  <Controller
306
-                    name="state"
307
-                    control={control}
308
-                    render={({ field: props }) =>
309
-                      <Checkbox
310
-                        style={{ color: 'var(--main)' }}
311
-                        checked={props.value}
312
-                        onChange={(e) => props.onChange(e.target.checked)}
311
+
312
+              {
313
+                !home ? 
314
+                  <FormControlLabel
315
+                    label="Activo?"
316
+                    control={
317
+                      <Controller
318
+                        name="state"
319
+                        control={control}
320
+                        render={({ field: props }) =>
321
+                          <Checkbox
322
+                            style={{ color: 'var(--main)' }}
323
+                            checked={props.value}
324
+                            onChange={(e) => props.onChange(e.target.checked)}
325
+                          />
326
+                        }
313 327
                       />
314 328
                     }
315
-                  />
316
-                }
317
-              />
329
+                  /> : null
330
+              }
331
+
332
+
318 333
             </Stack>
319 334
 
320 335
             <LocalizationProvider dateAdapter={DateFnsUtils}>
@@ -323,6 +338,7 @@ function ModalForm(props) {
323 338
                 control={control}
324 339
                 render={({ field }) =>
325 340
                   <DesktopDatePicker
341
+                    disabled={home}
326 342
                     {...field}
327 343
                     label="Fecha de Activación"
328 344
                     inputFormat="dd/MM/yyyy"
@@ -346,6 +362,7 @@ function ModalForm(props) {
346 362
                 render={({ field }) =>
347 363
                   <DesktopDatePicker
348 364
                     {...field}
365
+                    disabled={home}
349 366
                     label="Fecha de Vencimiento"
350 367
                     error={Boolean(errors?.deadpwd)}
351 368
                     inputFormat="dd/MM/yyyy"
@@ -361,14 +378,30 @@ function ModalForm(props) {
361 378
               </Controller>
362 379
             </LocalizationProvider>
363 380
 
364
-            <DialogActions style={{ paddingTop: 25, 'justifyContent': "flex-start" }}>
365
-              <Button onClick={() => closeModal(false)}>
366
-                Cerrar
367
-              </Button>
368
-              <Button type="submit" style={{ color: 'white', background: 'var(--main)' }} >
369
-                Guardar
370
-              </Button>
371
-            </DialogActions>
381
+            { !home?
382
+              <DialogActions style={{ paddingTop: 25, 'justifyContent': "flex-start" }}>
383
+                <Button onClick={() => closeModal(false)}>
384
+                  Cerrar
385
+                </Button>
386
+                <Button type="submit" style={{ color: 'white', background: 'var(--main)' }} >
387
+                  Guardar
388
+                </Button>
389
+              </DialogActions> : 
390
+
391
+              <DialogActions 
392
+                style={{
393
+                  justifyContent: "flex-start",
394
+                }} >
395
+                <Button onClick={() => { 
396
+                  console.log('close modal')
397
+                  console.log(closeModal)
398
+                  closeModal(true) 
399
+                }}>
400
+                  Cerrar
401
+                </Button>
402
+              </DialogActions>
403
+
404
+            }
372 405
 
373 406
           </Stack>
374 407
         </form>
@@ -376,6 +409,7 @@ function ModalForm(props) {
376 409
       </Col>
377 410
       <Col>
378 411
         <Candidatos
412
+          home={home}
379 413
           add={addCandidato}
380 414
           remove={removeCandidato}
381 415
           candidatos={candidatos}

+ 11 - 7
src/Components/Password/Steps/MailTable.jsx

@@ -8,10 +8,12 @@ import { DisabledByDefault } from '@mui/icons-material'
8 8
 
9 9
 export function MailTable(props) {
10 10
 
11
-  let { users, remove } = props;
11
+  let { users, remove, home } = props;
12 12
 
13 13
   return (
14
-    <TableContainer component={Paper}>
14
+    <TableContainer 
15
+      style={{boxShadow:'none',margin:'0px !important'}}
16
+      component={Paper}>
15 17
       <Table aria-label="simple table">
16 18
         <TableHead>
17 19
           <TableRow>
@@ -29,11 +31,13 @@ export function MailTable(props) {
29 31
               </TableCell>
30 32
               <TableCell align="right">{row.nombres}</TableCell>
31 33
               <TableCell align="right">{row.apellidos}</TableCell>
32
-              <TableCell align="right">
33
-                <ButtonBase>
34
-                  <DisabledByDefault onClick={() => remove(row.mail)} style={{color:'var(--main)'}} />
35
-                </ButtonBase>
36
-              </TableCell>
34
+              { !home?
35
+                <TableCell align="right">
36
+                  <ButtonBase>
37
+                    <DisabledByDefault onClick={() => remove(row.mail)} style={{color:'var(--main)'}} />
38
+                  </ButtonBase>
39
+                </TableCell>: null
40
+              }
37 41
             </TableRow>
38 42
           )) : null}
39 43
         </TableBody>

+ 17 - 1
src/Pages/Home.jsx

@@ -1,4 +1,4 @@
1
-import React from 'react'
1
+import React, { useState } from 'react'
2 2
 import { Col, Row } from 'react-bootstrap'
3 3
 import { PersonOutline, VerifiedUser, ListAlt } from '@mui/icons-material/'
4 4
 // import Actividades from '../Components/Home/Actividades'
@@ -7,10 +7,14 @@ import { Card } from '../Components/Card';
7 7
 import { useSelector } from 'react-redux';
8 8
 import { Service } from '../Utils/HTTP.js'
9 9
 import { useQuery } from 'react-query';
10
+import { ModalEdit } from '../Components/Password/Operation';
10 11
 
11 12
 export function Home() {
12 13
 
13 14
   const auth = useSelector((state) => state.token)
15
+  const [password,setPasword]= useState(null)
16
+  const [visible,setVisible]= useState(false)
17
+  const hideModal = () => setVisible(false)
14 18
 
15 19
   const getAllPwd = async () => {
16 20
     let rest = new Service('/contrasenia/getallbyidUsr');
@@ -53,6 +57,8 @@ export function Home() {
53 57
             <Row>
54 58
               <Col md="12">
55 59
                 <Candidatos 
60
+                  setPassword={setPasword}
61
+                  setVisible={setVisible}
56 62
                   passwords={data?.data || []}
57 63
                 />
58 64
               </Col>
@@ -64,6 +70,16 @@ export function Home() {
64 70
             </Row>
65 71
           </div>
66 72
         </div>
73
+
74
+        { password ?
75
+          <ModalEdit
76
+            home={true}
77
+            password={password}
78
+            open={visible}
79
+            handleOpen={hideModal}
80
+          />: null
81
+        }
82
+
67 83
       </div>
68 84
     </section>
69 85
   )