浏览代码

render pwd info mok

amenpunk 2 年之前
父节点
当前提交
5ffad08c38
共有 6 个文件被更改,包括 107 次插入358 次删除
  1. 8 3
      src/App.css
  2. 41 28
      src/Components/Home/Candidato.jsx
  3. 6 4
      src/Components/Home/Candidatos.js
  4. 1 2
      src/Css/all.css
  5. 1 1
      src/Pages/Home.jsx
  6. 50 320
      src/temp.js

+ 8 - 3
src/App.css

@@ -385,8 +385,13 @@
385 385
   justify-content: center;
386 386
   align-items: center;
387 387
 }
388
+.table_list_test_user{
389
+  border :none !important;
390
+}
388 391
 
389
-table, th, td {
390
-  border: 1px solid black;
391
-  border-collapse: collapse;
392
+.home_letter{
393
+  font-family: 'gudea' !important;
394
+  color: #878787 !important;
395
+  line-height: 1 !important;
396
+  font-size: 14px !important;
392 397
 }

+ 41 - 28
src/Components/Home/Candidato.jsx

@@ -1,15 +1,25 @@
1 1
 import '../../App.css'
2
-import { Skeleton, Box } from '@mui/material';
2
+import {
3
+  Skeleton, Box, IconButton, TableCell, TableContainer,
4
+  Table, TableRow, Paper, TableBody
5
+} from '@mui/material';
3 6
 import React from 'react'
7
+import CheckBoxIcon from '@mui/icons-material/CheckBox';
8
+
9
+
4 10
 const big_as = 70
5 11
 
6 12
 function Asignaciones(props) {
7 13
   let { asign } = props;
8 14
   let { cattest } = asign;
9
-  // console.log(cattest)
10 15
   return (
11 16
     <tr>
12
-      <td className="tg-0lax">{cattest.decription}</td>
17
+      <td>
18
+        {cattest.decription}
19
+        <IconButton color="primary" aria-label="puesto_status" components="label">
20
+          <CheckBoxIcon />
21
+        </IconButton>
22
+      </td>
13 23
     </tr>
14 24
   )
15 25
 }
@@ -17,21 +27,20 @@ function Asignaciones(props) {
17 27
 function TableUser(props) {
18 28
   let { user } = props;
19 29
   let { asignaciones, candi } = user
20
-  console.log(asignaciones)
30
+  // console.log(asignaciones)
21 31
   return (
22
-    <tr>
23
-      <td className="tg-0lax">{candi.nombre + " " + candi.apellidos}</td>
24
-      <td className="tg-0lax">
25
-        <table className="tg">
26
-          <tbody>
32
+    <TableRow style={{}}>
33
+      <TableCell className="table_list_test_user home_letter">{candi.nombre + " " + candi.apellidos}</TableCell>
34
+      <TableCell className="table_list_test_user home_letter">
35
+        <table>
36
+          <tbody >
27 37
             {
28 38
               asignaciones.map(a => <Asignaciones key={a.id} asign={a} />)
29 39
             }
30 40
           </tbody>
31 41
         </table>
32
-
33
-      </td>
34
-    </tr>
42
+      </TableCell>
43
+    </TableRow>
35 44
   )
36 45
 }
37 46
 
@@ -42,25 +51,29 @@ export function Candidato(props) {
42 51
   return (
43 52
     <div className="data_candidato">
44 53
       <div className="row">
45
-        <div className="col20">
46
-          <p>{password}</p>
54
+        <div style={{padding:15, borderRight: '1px solid #f1f1f1' }} className="col-3" >
55
+          <p><b>{password?.toUpperCase()}</b></p>
47 56
         </div>
48
-        <div className="col20">
57
+        <div className="col-9">
49 58
 
50
-          <table className="tg">
51
-            <thead>
52
-              <tr>
53
-                <th className="tg-0lax">Nombre</th>
54
-                <th className="tg-0lax">Asignaciones</th>
55
-              </tr>
56
-            </thead>
57
-            <tbody>
58
-              {
59
-                candidatos.map(u => <TableUser key={u.candi.id} user={u} />)
60
-              }
61
-            </tbody>
62
-          </table>
59
+          <TableContainer style={{ boxShadow: "none" }} component={Paper}>
60
+            <Table size="small" aria-label="a dense table">
61
+              {/*
62
+              <TableHead>
63
+                <TableRow>
64
+                  <TableCell className="tg-0lax">Nombre</TableCell>
65
+                  <TableCell className="tg-0lax">Asignaciones</TableCell>
66
+                </TableRow>
67
+              </TableHead>
68
+                  */}
69
+              <TableBody>
70
+                {
71
+                  candidatos.map(u => <TableUser key={u.candi.id} user={u} />)
72
+                }
73
+              </TableBody>
74
+            </Table>
63 75
 
76
+          </TableContainer>
64 77
 
65 78
         </div>
66 79
       </div>

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

@@ -6,7 +6,7 @@ import { Candidato, Preview } from './Candidato'
6 6
 
7 7
 function Divide(arregloOriginal) {
8 8
 
9
-  const LONGITUD_PEDAZOS = 8;
9
+  const LONGITUD_PEDAZOS = 4;
10 10
   let arregloDeArreglos = [];
11 11
   for (let i = 0; i < arregloOriginal.length; i += LONGITUD_PEDAZOS) {
12 12
     let pedazo = arregloOriginal.slice(i, i + LONGITUD_PEDAZOS);
@@ -40,7 +40,7 @@ export default function Candidatos(props) {
40 40
 
41 41
     let list = passwords.map(pwd => {
42 42
       let { candidatospwds } = pwd
43
-      console.log(candidatospwds)
43
+      // console.log(candidatospwds)
44 44
       // let candi_info = candidatospwds.map( ({candi}) => candi?.nombre +" "+ candi?.apellidos   )
45 45
       return {
46 46
         password: fromBase64(pwd.pwd),
@@ -92,8 +92,10 @@ export default function Candidatos(props) {
92 92
         <p>Últimos candidatos que han ingresado al sistema:</p>
93 93
         <div className="cabeceras">
94 94
           <Row>
95
-            <div className="col20"><p>Contraseña</p></div>
96
-            <div className="col20"><p>Detalle</p> </div>
95
+            <div className="col20 "><p>Contraseña</p></div>
96
+            <div className="col20 "><p></p> </div>
97
+            <div className="col20 "><p>Usuarios</p> </div>
98
+            <div className="col20 "><p>Asignaciones</p> </div>
97 99
           </Row>
98 100
         </div>
99 101
         {

+ 1 - 2
src/Css/all.css

@@ -1807,8 +1807,7 @@ li.cabecera_li {
1807 1807
     color: #25344f;
1808 1808
 }
1809 1809
 .data_candidato {
1810
-    padding: 10px;
1811
-    border-bottom: 1px solid #f1f1f1;
1810
+  border-bottom: 1px solid #f1f1f1;
1812 1811
 }
1813 1812
 .data_candidato a:hover {
1814 1813
     color: #fd4b4b;

+ 1 - 1
src/Pages/Home.jsx

@@ -22,7 +22,7 @@ export function Home() {
22 22
   const { data, status } = useQuery('homepwd', getAllPwd);
23 23
 
24 24
   let is_loading = status === "loading";
25
-  console.log({ is_loading })
25
+  console.log({is_loading, data})
26 26
 
27 27
   //TODO:
28 28
   //utilizar el servicio 

+ 50 - 320
src/temp.js

@@ -1,324 +1,54 @@
1
-import React, { memo, useCallback, useMemo, useEffect } from 'react';
2
-import * as Yup from 'yup';
3
-// import { useFormik, Form, FormikProvider } from 'formik';
4
-import { Modal } from 'react-bootstrap'
5
-import toast, { Toaster } from 'react-hot-toast';
6
-import { useForm, Controller } from "react-hook-form";
7
-
8
-import DateFnsUtils from '@date-io/date-fns';
9
-import { DesktopDatePicker, LocalizationProvider } from '@mui/lab';
10
-import { TabPanel } from './TabPanel'
11
-
12
-import {
13
-    Button, Stack, TextField, MenuItem, FormControl, InputLabel, Select,
14
-    Backdrop, CircularProgress,
15
-    Tabs,Tab,Box, Divider,FormGroup,FormControlLabel,Checkbox
16
-} from '@mui/material';
17
-
18
-import { Service } from '../../Utils/HTTP';
19
-import { useSelector } from 'react-redux'
20
-import { useQuery, useMutation, useQueryClient } from 'react-query'
21
-
22
-const NewPlazaSchema = Yup.object().shape({
23
-  id: Yup.number(),
24
-  nombrepuesto:
25
-  Yup.string().required('El nombre es requerido')
26
-  .min(5, "El nombre del  puesto debe ser mayor a 5 caracteres")
27
-  .max(100),
28
-  puestosuperior: Yup.number("El puesto superior debe ser un número").required("El puesto es requerido"),
29
-  aredepto: Yup.number().required('Escoge alguna área'),
30
-  fecha: Yup.date("Ingresa una fecha válida"),
31
-  notas: Yup.string("Ingresa una nota válida").min(5).max(150),
32
-  tests: Yup.array()
33
-})
34
-
35
-
36
-
37
-function Edit(props) {
38
-
39
-  const { getValues ,control,register, handleSubmit, watch, formState: { errors } } = useForm({
40
-    defaultValues: {
41
-      departamento: 1,
42
-    }
43
-  });
44
-
45
-  console.log(errors)
46
-
47
-  const onSubmit = data => console.log(data);
48
-  console.log(watch("departamento")); // watch input value by passing the name of it
49
-  //
50
-  const now = useMemo(() => new Date(), [])
51
-  const auth = useSelector((state) => state.token)
52
-  const queryClient = useQueryClient()
53
-  let { visible, toggle } = props
54
-
55
-  // const [departamento, setDepartamento] = React.useState('');
56
-  const [open, setOpen] = React.useState(false);
57
-
58
-  // const changeDepartamento = useCallback((event) => {
59
-  //   setDepartamento(event.target.value);
60
-  // }, []);
61
-
62
-  const [date, setDate] = React.useState(now);
63
-  const [tab, setTab] = React.useState(0);
64
-  const [checklist, setChecklist] = React.useState([]);
65
-
66
-  const addPrueba = (check,id) => {
67
-    let { tests } = getValues("tests")
68
-    console.log(tests);
69
-    let temp ;
70
-    if(check){
71
-      temp = [...tests, {id}]
72
-    }else{
73
-      temp = tests.filter( test => test.id !== id);
74
-    }
75
-    setChecklist(temp.map( test => test.id) )
76
-    // setValues({...values, tests: temp})
77
-  };
78
-
79
-  const getCategories = async () => {
80
-    let rest = new Service("/categoria/getAll")
81
-    return await rest.getQuery(auth.token)
82
-  }
83
-
84
-  const updatePuesto = async (fields) => {
85
-    let rest = new Service('/plaza/edit');
86
-    return rest.putQuery(fields, auth.token)
87
-  }
88
-
89
-  const getTest = async () => {
90
-    let rest = new Service("/tests/getAll")
91
-    return await rest.getQuery(auth.token)
92
-  }
93
-
94
-  const puestoMutation = useMutation(updatePuesto)
95
-
96
-  const close = () => toggle("EDIT", {id : null});
97
-
98
-  const { data: categories } = useQuery('categories', getCategories);
99
-  const { data: testsCatalog } = useQuery('tests', getTest);
100
-  /*
101
-  const formik = useFormik({
102
-    initialValues: {
103
-      id: 1,
104
-      nombrepuesto: "",
105
-      puestosuperior: 1,
106
-      aredepto: 1,
107
-      fecha: now,
108
-      notas: "",
109
-      tests : []
110
-    },
111
-    onSubmit: (fields, { resetForm }) => {
112
-      setOpen(true);
113
-      fields['fecha'] = new Date(fields.fecha).toISOString();
114
-
115
-      puestoMutation.mutate(fields, {
116
-        onSuccess: () => {
117
-          close();
118
-          setOpen(false)
119
-          toast.success("Puesto Actualizado!!")
120
-          queryClient.invalidateQueries('puestos')
121
-        },
122
-        onError:() => {
123
-          close();
124
-          setOpen(false)
125
-          toast.error("Lo sentimos ocurrió error inténtalo más tarde")
126
-        }
127
-      })
128
-
129
-      resetForm();
130
-    },
131
-    validationSchema: NewPlazaSchema,
132
-  });
133
-*/
134
-
135
-  // const { errors, touched, handleSubmit, getFieldProps, setValues, values } = formik;
136
-
137
-  useEffect(() => {
138
-    console.info('use effect edit', props)
139
-  },[props])
140
-
141
-  // useEffect(() => {
142
-  //   if (puesto) {
143
-  //     setValues({
144
-  //       id: puesto.id,
145
-  //       nombrepuesto: puesto.nombrepuesto,
146
-  //       puestosuperior: puesto.puestosuperior,
147
-  //       aredepto: puesto.areadeptoplz_id,
148
-  //       fecha: new Date(puesto.create_day),
149
-  //       notas: puesto.notas,
150
-  //       tests : puesto.tests
151
-  //     })
152
-  //     setChecklist(puesto.tests.map(( {id} ) => id))
153
-  //   }
154
-  // }, [puesto, now, setValues])
1
+import * as React from 'react';
2
+import Table from '@mui/material/Table';
3
+import TableBody from '@mui/material/TableBody';
4
+import TableCell from '@mui/material/TableCell';
5
+import TableContainer from '@mui/material/TableContainer';
6
+import TableHead from '@mui/material/TableHead';
7
+import TableRow from '@mui/material/TableRow';
8
+import Paper from '@mui/material/Paper';
9
+
10
+function createData(name, calories, fat, carbs, protein) {
11
+  return { name, calories, fat, carbs, protein };
12
+}
155 13
 
156
-  const changeTab = (_event, newValue) => {
157
-    setTab(newValue);
158
-  };
14
+const rows = [
15
+  createData('Frozen yoghurt', 159, 6.0, 24, 4.0),
16
+  createData('Ice cream sandwich', 237, 9.0, 37, 4.3),
17
+  createData('Eclair', 262, 16.0, 24, 6.0),
18
+  createData('Cupcake', 305, 3.7, 67, 4.3),
19
+  createData('Gingerbread', 356, 16.0, 49, 3.9),
20
+];
159 21
 
22
+export default function DenseTable() {
160 23
   return (
161
-
162
-    <Modal size="lg" aria-labelledby="contained-modal-title-vcenter" centered show={visible} onHide={close}>
163
-      <Modal.Header>
164
-        <button onClick={close} type="button" className="close" data-dismiss="modal">&times;</button>
165
-        <h4 className="modal-title" style={{ color: '#252525' }}>Editar puesto</h4>
166
-      </Modal.Header>
167
-      <Modal.Body className="modal-body">
168
-
169
-        <Tabs value={tab} onChange={changeTab} aria-label="basic tabs example">
170
-          <Tab label="Información" />
171
-          <Tab label="Pruebas" />
172
-        </Tabs>
173
-
174
-          <form onSubmit={handleSubmit(onSubmit)}>
175
-            <TabPanel value={tab} index={1}>
176
-              <Stack spacing={1}>
177
-<Box style={{ paddingTop :5, paddingLeft :15 }}>
178
-                  <Divider/>
179
-                  <h4 style={{paddingTop :10, paddingBottom:10}}>Seleciona los test a realizar</h4>
180
-                  <Divider/>
181
-                  <FormGroup>
182
-                    {
183
-                    testsCatalog ?
184
-                      testsCatalog.data.map( test => (
185
-                        <FormControlLabel 
186
-                          key={test.id}
187
-                          control={
188
-                          <Checkbox 
189
-                            checked={checklist.includes((test.id))}
190
-                            onChange={(event)=> addPrueba(event.target.checked,test.id)}
191
-                            />
192
-                        } 
193
-                          label={test.nombre} 
194
-                          />
195
-                      )): null
196
-                  }
197
-                  </FormGroup>
198
-                </Box>
199
-              </Stack>
200
-            </TabPanel>
201
-
202
-
203
-            <TabPanel value={tab} index={0} >
204
-              <Stack spacing={3}>
205
-
206
-                <Stack direction={{ xs: 'column', sm: 'row' }} spacing={2}>
207
-
208
-                  <TextField
209
-                    label="Nombre"
210
-                    fullWidth
211
-                    {...register("nombre")}
212
-                    // {...getFieldProps('nombrepuesto')}
213
-                    // error={Boolean(touched.nombrepuesto && errors.nombrepuesto)}
214
-                    // helperText={touched.nombrepuesto && errors.nombrepuesto}
215
-                    />
216
-
217
-                  <TextField
218
-                    label="Puesto Superior"
219
-                    fullWidth
220
-                    {...register("puesto_superior")}
221
-                    //{...getFieldProps('puestosuperior')}
222
-                    //error={Boolean(touched.puestosuperior && errors.puestosuperior)}
223
-                    //helperText={touched.puestosuperior && errors.puestosuperior}
224
-                    />
225
-
226
-                </Stack>
227
-                <Stack direction={{ xs: 'column', sm: 'row' }} spacing={2}>
228
-                  <FormControl fullWidth>
229
-                    <InputLabel id="demo-simple-select-label">Departamento</InputLabel>
230
-                    <Select
231
-                      {...register("departamento")}
232
-                      labelId="departamento"
233
-                      id="departamento"
234
-                      label="Departamento"
235
-                      name={"departamento"}
236
-                      constrol={control}
237
-                      value={1}
238
-                      //value={departamento}
239
-                      //{...getFieldProps('puestosuperior')}
240
-                      // onChange={changeDepartamento}
241
-                      // {...getFieldProps('aredepto')}
242
-                      // error={Boolean(touched.aredepto && errors.aredepto)} 
243
-                      >
244
-                      {
245
-                      categories ?
246
-                        categories.data.map(cate => {
247
-                          return (
248
-                            <MenuItem key={cate.id} value={cate.id}>{cate.nombre}</MenuItem>
249
-                          )
250
-                        })
251
-                        : <MenuItem value={1}>hola</MenuItem>
252
-                    }
253
-                    </Select>
254
-                  </FormControl>
255
-
256
-
257
-                  <LocalizationProvider
258
-                    dateAdapter={DateFnsUtils}>
259
-                    <DesktopDatePicker
260
-                      label="Fecha Creación"
261
-                      fullWidth
262
-                      inputFormat="dd/MM/yyyy"
263
-                      // {...getFieldProps('fecha')}
264
-                      {...register("fecha")}
265
-                      value={date}
266
-                      onChange={setDate}
267
-                      renderInput={(params) =>
268
-                        <TextField
269
-                          disabled={true}
270
-                          label="Fecha Creación"
271
-                          fullWidth
272
-                          {...params}
273
-                          />}
274
-                      />
275
-                  </LocalizationProvider>
276
-
277
-                </Stack>
278
-
279
-                <Stack direction={{ xs: 'column', sm: 'row' }} spacing={1}>
280
-                  <TextField
281
-                    id="filled-multiline-static"
282
-                    multiline
283
-                    rows={4}
284
-                    variant="filled"
285
-                    label="Notas"
286
-                    fullWidth
287
-                    type="text"
288
-                    {...register("notas")}
289
-                    // {...getFieldProps('notas')}
290
-                    // error={Boolean(touched.notas && errors.notas)}
291
-                    // helperText={touched.notas && errors.notas}
292
-                    />
293
-                </Stack>
294
-              </Stack>
295
-            </TabPanel>
296
-
297
-
298
-            <Modal.Footer>
299
-              <Button
300
-                type="submit"
301
-                className="registerBtn"
302
-                variant="contained"
303
-                sx={{ mt: 1, mr: 1 }} >
304
-                {'Actualizar'}
305
-              </Button>
306
-            </Modal.Footer>
307
-
308
-          </form>
309
-
310
-      </Modal.Body>
311
-      <Backdrop
312
-        sx={{ color: '#fd4b4b', zIndex: (theme) => theme.zIndex.drawer + 1 }}
313
-        open={open}
314
-        onClick={() => console.log('backdrop')} >
315
-        <CircularProgress color="inherit" />
316
-      </Backdrop>
317
-      <Toaster position="top-right" />
318
-
319
-    </Modal>
320
-  )
24
+    <TableContainer component={Paper}>
25
+      <Table sx={{ minWidth: 650 }} size="small" aria-label="a dense table">
26
+        <TableHead>
27
+          <TableRow>
28
+            <TableCell>Dessert (100g serving)</TableCell>
29
+            <TableCell align="right">Calories</TableCell>
30
+            <TableCell align="right">Fat&nbsp;(g)</TableCell>
31
+            <TableCell align="right">Carbs&nbsp;(g)</TableCell>
32
+            <TableCell align="right">Protein&nbsp;(g)</TableCell>
33
+          </TableRow>
34
+        </TableHead>
35
+        <TableBody>
36
+          {rows.map((row) => (
37
+            <TableRow
38
+              key={row.name}
39
+              sx={{ '&:last-child td, &:last-child th': { border: 0 } }}
40
+            >
41
+              <TableCell component="th" scope="row">
42
+                {row.name}
43
+              </TableCell>
44
+              <TableCell align="right">{row.calories}</TableCell>
45
+              <TableCell align="right">{row.fat}</TableCell>
46
+              <TableCell align="right">{row.carbs}</TableCell>
47
+              <TableCell align="right">{row.protein}</TableCell>
48
+            </TableRow>
49
+          ))}
50
+        </TableBody>
51
+      </Table>
52
+    </TableContainer>
53
+  );
321 54
 }
322
-
323
-
324
-export default memo(Edit);