Browse Source

separete the logic behind the pwd table

amenpunk 3 years ago
parent
commit
c36932a433
3 changed files with 138 additions and 138 deletions
  1. 56 0
      src/Components/Password/Rows.js
  2. 73 68
      src/Components/Password/config.js
  3. 9 70
      src/Pages/Contras.jsx

+ 56 - 0
src/Components/Password/Rows.js

1
+export const encabezados = [
2
+    {
3
+        id: 'pass',
4
+        numeric: false,
5
+        disablePadding: true,
6
+        label: 'Contraseñas',
7
+    },
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',
43
+    },
44
+    {
45
+        id: 'replic',
46
+        numeric: true,
47
+        disablePadding: false,
48
+        label: 'Replicar',
49
+    },
50
+    {
51
+        id: 'ope',
52
+        numeric: true,
53
+        disablePadding: false,
54
+        label: 'Operacion',
55
+    },
56
+]

+ 73 - 68
src/Components/Password/config.js

1
 import { 
1
 import { 
2
-    TableHead,
3
-    TableRow,
4
-    TableCell,
5
-    Checkbox,
6
-    TableSortLabel,
7
-    Box,
2
+    TableHead, TableRow, TableCell,
3
+    Checkbox, TableSortLabel, Box,
4
+    IconButton,Typography,Toolbar,
5
+    Tooltip
8
 } from '@mui/material'
6
 } from '@mui/material'
9
 
7
 
8
+import { alpha } from '@mui/material/styles';
10
 import { visuallyHidden } from '@mui/utils';
9
 import { visuallyHidden } from '@mui/utils';
10
+import { encabezados } from './Rows';
11
+
12
+import {
13
+    Delete as DeleteIcon,
14
+    FilterList as FilterListIcon,
15
+    // LastPage as LastPageIcon, FirstPage as FirstPageIcon, KeyboardArrowRight, KeyboardArrowLeft,
16
+} from '@mui/icons-material/'
11
 
17
 
12
 export const rows = [
18
 export const rows = [
13
-    createData('Cupcake', 305, 3.7, 67, 4.3, 'Nice', 'Good'),
14
-    createData('Cupcake 1', 305, 3.7, 67, 4.3, 'Nice', 'Good'),
15
-    createData('Cupcake 2', 305, 3.7, 67, 4.3, 'Nice', 'Good'),
16
-    createData('Cupcake 3', 305, 3.7, 67, 4.3, 'Nice', 'Good'),
17
-    createData('Cupcake 4', 305, 3.7, 67, 4.3, 'Nice', 'Good'),
19
+    createData('Cupcake', 305, 'Analista',109238109238, 'SI', 'SI', 'Nice', 'Good'),
18
 ]
20
 ]
19
 
21
 
22
+for(let x of new Array(50)){
23
+    console.log(x)
24
+    rows.push(rows[0])
25
+}
26
+
27
+
28
+export const TableEncabezadoOperation = (props) => {
29
+
30
+    const { numSelected } = props;
31
+    return (
32
+        <Toolbar
33
+            sx={{
34
+                pl: { sm: 2 },
35
+                pr: { xs: 1, sm: 1 },
36
+                ...(numSelected > 0 && {
37
+                    bgcolor: (theme) =>
38
+                        alpha(theme.palette.primary.main, theme.palette.action.activatedOpacity),
39
+                }),
40
+            }}
41
+        >
42
+            {numSelected > 0 ? (
43
+                <Typography
44
+                    sx={{ flex: '1 1 100%' }}
45
+                    color="inherit"
46
+                    variant="subtitle1"
47
+                    component="div"
48
+                >
49
+                    {numSelected} selected
50
+                </Typography>
51
+            ) : (
52
+                    <Typography
53
+                        sx={{ flex: '1 1 100%' }}
54
+                        variant="h6"
55
+                        id="tableTitle"
56
+                        component="div"
57
+                    >
58
+                        Contraseñas
59
+                    </Typography>
60
+                )}
61
+
62
+            {numSelected > 0 ? (
63
+                <Tooltip title="Delete">
64
+                    <IconButton>
65
+                        <DeleteIcon />
66
+                    </IconButton>
67
+                </Tooltip>
68
+            ) : (
69
+                    <Tooltip title="Filter list">
70
+                        <IconButton>
71
+                            <FilterListIcon />
72
+                        </IconButton>
73
+                    </Tooltip>
74
+                )}
75
+        </Toolbar>
76
+    );
77
+
78
+}
79
+
80
+
81
+
20
 export function createData(name, calories, fat, carbs, protein) {
82
 export function createData(name, calories, fat, carbs, protein) {
21
     return {
83
     return {
22
         name,
84
         name,
55
     return stabilizedThis.map((el) => el[0]);
117
     return stabilizedThis.map((el) => el[0]);
56
 }
118
 }
57
 
119
 
58
-export const encabezados = [
59
-    {
60
-        id: 'pass',
61
-        numeric: false,
62
-        disablePadding: true,
63
-        label: 'Contraseñas',
64
-    },
65
-    {
66
-        id: 'nivel',
67
-        numeric: true,
68
-        disablePadding: false,
69
-        label: 'Nivel',
70
-    },
71
-    {
72
-        id: 'puesto',
73
-        numeric: true,
74
-        disablePadding: false,
75
-        label: 'Puesto',
76
-    },
77
-    {
78
-        id: 'cui',
79
-        numeric: true,
80
-        disablePadding: false,
81
-        label: 'CUI/Cedula',
82
-    },
83
-    {
84
-        id: 'uso',
85
-        numeric: true,
86
-        disablePadding: false,
87
-        label: 'En uso?',
88
-    },
89
-    {
90
-        id: 'picture',
91
-        numeric: true,
92
-        disablePadding: false,
93
-        label: 'Fotografía',
94
-    },
95
-    {
96
-        id: 'cv',
97
-        numeric: true,
98
-        disablePadding: false,
99
-        label: 'Con CV',
100
-    },
101
-    {
102
-        id: 'replic',
103
-        numeric: true,
104
-        disablePadding: false,
105
-        label: 'Replicar',
106
-    },
107
-    {
108
-        id: 'ope',
109
-        numeric: true,
110
-        disablePadding: false,
111
-        label: 'Operacion',
112
-    },
113
-]
114
-
115
 export function TableHeader(props){
120
 export function TableHeader(props){
116
 
121
 
117
     const { onSelectAllClick, order, orderBy, numSelected, rowCount, onRequestSort } =
122
     const { onSelectAllClick, order, orderBy, numSelected, rowCount, onRequestSort } =

+ 9 - 70
src/Pages/Contras.jsx

1
 import * as React from 'react';
1
 import * as React from 'react';
2
-// import { useTheme } from '@mui/material/styles';
2
+
3
 import { 
3
 import { 
4
-    rows,
5
     // descendingComparator,
4
     // descendingComparator,
5
+    rows,
6
     Comparar,
6
     Comparar,
7
     Cuerpo,
7
     Cuerpo,
8
-    TableHeader as EnhancedTableHead
8
+    TableHeader as EnhancedTableHead,
9
+    TableEncabezadoOperation
9
 } from '../Components/Password/config.js';
10
 } from '../Components/Password/config.js';
10
 
11
 
11
 import { 
12
 import { 
12
     Table, TableBody, TableCell, TableContainer, 
13
     Table, TableBody, TableCell, TableContainer, 
13
     TableRow, TablePagination,
14
     TableRow, TablePagination,
14
-    IconButton, Paper, Box,
15
-    Switch, FormControlLabel,Tooltip,
16
-    Checkbox, Typography, Toolbar,
15
+    Paper, Box, Switch, FormControlLabel,
16
+    Checkbox,
17
     // TableSortLabel,TableHead,Card
17
     // TableSortLabel,TableHead,Card
18
 } from '@mui/material';
18
 } from '@mui/material';
19
 
19
 
20
-import { alpha } from '@mui/material/styles';
21
-
22
 import { Row, Col, Container } from 'react-bootstrap';
20
 import { Row, Col, Container } from 'react-bootstrap';
23
 
21
 
24
-import {
25
-    Delete as DeleteIcon,
26
-    FilterList as FilterListIcon,
27
-    // LastPage as LastPageIcon, FirstPage as FirstPageIcon, KeyboardArrowRight, KeyboardArrowLeft,
28
-} from '@mui/icons-material/'
29
-
30
-const TableEncabezadoOperation = (props) => {
31
-
32
-    const { numSelected } = props;
33
-    return (
34
-        <Toolbar
35
-            sx={{
36
-                pl: { sm: 2 },
37
-                pr: { xs: 1, sm: 1 },
38
-                ...(numSelected > 0 && {
39
-                    bgcolor: (theme) =>
40
-                        alpha(theme.palette.primary.main, theme.palette.action.activatedOpacity),
41
-                }),
42
-            }}
43
-        >
44
-            {numSelected > 0 ? (
45
-                <Typography
46
-                    sx={{ flex: '1 1 100%' }}
47
-                    color="inherit"
48
-                    variant="subtitle1"
49
-                    component="div"
50
-                >
51
-                    {numSelected} selected
52
-                </Typography>
53
-            ) : (
54
-                    <Typography
55
-                        sx={{ flex: '1 1 100%' }}
56
-                        variant="h6"
57
-                        id="tableTitle"
58
-                        component="div"
59
-                    >
60
-                        Contraseñas
61
-                    </Typography>
62
-                )}
63
-
64
-            {numSelected > 0 ? (
65
-                <Tooltip title="Delete">
66
-                    <IconButton>
67
-                        <DeleteIcon />
68
-                    </IconButton>
69
-                </Tooltip>
70
-            ) : (
71
-                    <Tooltip title="Filter list">
72
-                        <IconButton>
73
-                            <FilterListIcon />
74
-                        </IconButton>
75
-                    </Tooltip>
76
-                )}
77
-        </Toolbar>
78
-    );
79
-
80
-}
81
-
82
 export function Contras() {
22
 export function Contras() {
83
 
23
 
84
     const [order, setOrder] = React.useState('asc');
24
     const [order, setOrder] = React.useState('asc');
88
     const [dense, setDense] = React.useState(false);
28
     const [dense, setDense] = React.useState(false);
89
     const [rowsPerPage, setRowsPerPage] = React.useState(15);
29
     const [rowsPerPage, setRowsPerPage] = React.useState(15);
90
 
30
 
91
-    const handleRequestSort = (event, property) => {
31
+    const handleRequestSort = (_event, property) => {
92
         const isAsc = orderBy === property && order === 'asc';
32
         const isAsc = orderBy === property && order === 'asc';
93
         setOrder(isAsc ? 'desc' : 'asc');
33
         setOrder(isAsc ? 'desc' : 'asc');
94
         setOrderBy(property);
34
         setOrderBy(property);
103
         setSelected([]);
43
         setSelected([]);
104
     };
44
     };
105
 
45
 
106
-    const handleClick = (event, name) => {
46
+    const handleClick = (__event, name) => {
107
         const selectedIndex = selected.indexOf(name);
47
         const selectedIndex = selected.indexOf(name);
108
         let newSelected = [];
48
         let newSelected = [];
109
 
49
 
123
         setSelected(newSelected);
63
         setSelected(newSelected);
124
     };
64
     };
125
 
65
 
126
-    const handleChangePage = (event, newPage) => {
66
+    const handleChangePage = (_event, newPage) => {
127
         setPage(newPage);
67
         setPage(newPage);
128
     };
68
     };
129
 
69
 
170
                                                     const isItemSelected = isSelected(row.name);
110
                                                     const isItemSelected = isSelected(row.name);
171
                                                     const labelId = `enhanced-table-checkbox-${index}`;
111
                                                     const labelId = `enhanced-table-checkbox-${index}`;
172
 
112
 
173
-                                                    console.log('INDEX >> ',row)
174
                                                     return (
113
                                                     return (
175
                                                         <TableRow
114
                                                         <TableRow
176
                                                             hover
115
                                                             hover