瀏覽代碼

list all pwd of user

amenpunk 2 年之前
父節點
當前提交
dc6829b610
共有 3 個文件被更改,包括 45 次插入66 次删除
  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,57 +1,27 @@
1
-export const encabezados = [
1
+export const Encabezados = [
2 2
     {
3
-        id: 'pass',
3
+        name: 'pass',
4 4
         numeric: false,
5 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 22
         numeric: false,
53
-        disablePadding: false,
54
-        label: 'Operacion',
23
+        disablePadding: true,
24
+        label: 'Correo',
55 25
     },
56 26
 ]
57 27
 
@@ -76,3 +46,15 @@ export const departamentos = [
76 46
     "Guatemala",
77 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,27 +3,24 @@ import { default as CustomToolbar } from '../Components/Password/CustomToolbar';
3 3
 import { Paper, Box, ThemeProvider } from '@mui/material';
4 4
 
5 5
 import MUIDataTable from "mui-datatables";
6
-import { encabezados } from '../Components/Password/Rows';
6
+import { Encabezados, Build } from '../Components/Password/Rows';
7 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 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 25
     const options = {
29 26
         filterType: 'checkbox',
@@ -45,8 +42,8 @@ export function Contrasv2() {
45 42
                             <MUIDataTable
46 43
                                 sx={{ '& MuiPaper': { elevation: 0, boxShadow: 'none', color: "red" } }}
47 44
                                 title={"Contraseñas"}
48
-                                data={data}
49
-                                columns={columns}
45
+                                data={Build(result)}
46
+                                columns={Encabezados}
50 47
                                 options={options}
51 48
                             />
52 49
                         </ThemeProvider>

+ 3 - 3
src/Pages/Puestos.jsx

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