Browse Source

list all pwd of user

amenpunk 2 years ago
parent
commit
dc6829b610
3 changed files with 45 additions and 66 deletions
  1. 26 44
      src/Components/Password/Rows.js
  2. 16 19
      src/Pages/ContrasV2.jsx
  3. 3 3
      src/Pages/Puestos.jsx

+ 26 - 44
src/Components/Password/Rows.js

1
-export const encabezados = [
1
+export const Encabezados = [
2
     {
2
     {
3
-        id: 'pass',
3
+        name: 'pass',
4
         numeric: false,
4
         numeric: false,
5
         disablePadding: true,
5
         disablePadding: true,
6
-        label: 'Contraseñas',
6
+        label: 'Contraseña',
7
     },
7
     },
8
     {
8
     {
9
-        id: 'nivel',
10
-        numeric: true,
11
-        disablePadding: false,
12
-        label: 'Nivel',
13
-    },
14
-    {
15
-        id: 'puesto',
16
-        numeric: true,
17
-        disablePadding: false,
18
-        label: 'Puesto',
19
-    },
20
-    {
21
-        id: 'cui',
22
-        numeric: true,
23
-        disablePadding: false,
24
-        label: 'CUI/Cedula',
25
-    },
26
-    {
27
-        id: 'uso',
28
-        numeric: true,
29
-        disablePadding: false,
30
-        label: 'En uso?',
31
-    },
32
-    {
33
-        id: 'picture',
34
-        numeric: true,
35
-        disablePadding: false,
36
-        label: 'Fotografía',
37
-    },
38
-    {
39
-        id: 'cv',
40
-        numeric: true,
41
-        disablePadding: false,
42
-        label: 'Con CV',
9
+        name: 'name',
10
+        numeric: false,
11
+        disablePadding: true,
12
+        label: 'Nombre',
43
     },
13
     },
44
     {
14
     {
45
-        id: 'estado',
46
-        numeric: true,
47
-        disablePadding: false,
48
-        label: 'Envido?',
15
+        name: 'apell',
16
+        numeric: false,
17
+        disablePadding: true,
18
+        label: 'Apellido',
49
     },
19
     },
50
     {
20
     {
51
-        id: 'ope',
21
+        name: 'mail',
52
         numeric: false,
22
         numeric: false,
53
-        disablePadding: false,
54
-        label: 'Operacion',
23
+        disablePadding: true,
24
+        label: 'Correo',
55
     },
25
     },
56
 ]
26
 ]
57
 
27
 
76
     "Guatemala",
46
     "Guatemala",
77
     "Guatemala",
47
     "Guatemala",
78
 ]
48
 ]
49
+
50
+export function Build(pwds){
51
+    return pwds.map( pwd => {
52
+        let { candidato: user } = pwd
53
+        return {
54
+            pass : pwd.pwd,
55
+            name: user.nombre,
56
+            apell: user.apellidos,
57
+            mail: user.mail,
58
+        }
59
+    })
60
+}

+ 16 - 19
src/Pages/ContrasV2.jsx

3
 import { Paper, Box, ThemeProvider } from '@mui/material';
3
 import { Paper, Box, ThemeProvider } from '@mui/material';
4
 
4
 
5
 import MUIDataTable from "mui-datatables";
5
 import MUIDataTable from "mui-datatables";
6
-import { encabezados } from '../Components/Password/Rows';
6
+import { Encabezados, Build } from '../Components/Password/Rows';
7
 import { TableStyle, TextLabels } from '../Components/Password/TableStyle'
7
 import { TableStyle, TextLabels } from '../Components/Password/TableStyle'
8
 
8
 
9
+import { useQuery } from 'react-query';
10
+import { Service } from '../Utils/HTTP.js'
11
+import useAuth from '../Auth/useAuth'
12
+
9
 export function Contrasv2() {
13
 export function Contrasv2() {
10
 
14
 
11
-    const columns = encabezados.map(({ label }) => label); //["Name", "Company", "City", "State"];
12
-
13
-    const data = [
14
-        ["Joe James", "Test Corp", "Yonkers", "NY"],
15
-        ["John Walsh", "Test Corp", "Hartford", "CT"],
16
-        ["Bob Herm", "Test Corp", "Tampa", "FL"],
17
-        ["James Houston", "Test Corp", "Dallas", "TX"],
18
-        ["Joe James", "Test Corp", "Yonkers", "NY"],
19
-        ["John Walsh", "Test Corp", "Hartford", "CT"],
20
-        ["Bob Herm", "Test Corp", "Tampa", "FL"],
21
-        ["James Houston", "Test Corp", "Dallas", "TX"],
22
-        ["Joe James", "Test Corp", "Yonkers", "NY"],
23
-        ["John Walsh", "Test Corp", "Hartford", "CT"],
24
-        ["Bob Herm", "Test Corp", "Tampa", "FL"],
25
-        ["James Houston", "Test Corp", "Dallas", "TX"],
26
-    ];
15
+    const auth = useAuth();
16
+    const token = React.useRef(auth.getToken())
17
+
18
+    const getAllPwd = async () => {
19
+        let rest = new Service('/contrasenia/getallbyidUsr');
20
+        return await rest.getQuery(token.current)
21
+    }
22
+
23
+    const { data : { data : result} } = useQuery('passwords', getAllPwd );
27
 
24
 
28
     const options = {
25
     const options = {
29
         filterType: 'checkbox',
26
         filterType: 'checkbox',
45
                             <MUIDataTable
42
                             <MUIDataTable
46
                                 sx={{ '& MuiPaper': { elevation: 0, boxShadow: 'none', color: "red" } }}
43
                                 sx={{ '& MuiPaper': { elevation: 0, boxShadow: 'none', color: "red" } }}
47
                                 title={"Contraseñas"}
44
                                 title={"Contraseñas"}
48
-                                data={data}
49
-                                columns={columns}
45
+                                data={Build(result)}
46
+                                columns={Encabezados}
50
                                 options={options}
47
                                 options={options}
51
                             />
48
                             />
52
                         </ThemeProvider>
49
                         </ThemeProvider>

+ 3 - 3
src/Pages/Puestos.jsx

1
-import React, { useState, useCallback} from 'react';
1
+import React, { useState, useCallback, useRef} from 'react';
2
 import { Row, Col } from 'react-bootstrap'
2
 import { Row, Col } from 'react-bootstrap'
3
 import { Toaster } from 'react-hot-toast';
3
 import { Toaster } from 'react-hot-toast';
4
 
4
 
32
 export function Puestos() {
32
 export function Puestos() {
33
 
33
 
34
     const auth = useAuth();
34
     const auth = useAuth();
35
-    const token = auth.getToken();
35
+    const token = useRef(auth.getToken());
36
     const [page, setPage] = useState(1);
36
     const [page, setPage] = useState(1);
37
 
37
 
38
     const getAll = async () => {
38
     const getAll = async () => {
39
         let rest = new Service("/plaza/getall")
39
         let rest = new Service("/plaza/getall")
40
-        let response =  await rest.getQuery(token); 
40
+        let response =  await rest.getQuery(token.current); 
41
         return response;
41
         return response;
42
     }
42
     }
43
 
43