|
@@ -1,5 +1,12 @@
|
1
|
1
|
import * as React from 'react';
|
2
|
2
|
// import { useTheme } from '@mui/material/styles';
|
|
3
|
+import {
|
|
4
|
+ rows,
|
|
5
|
+ // descendingComparator,
|
|
6
|
+ Comparar,
|
|
7
|
+ Cuerpo,
|
|
8
|
+ TableHeader as EnhancedTableHead
|
|
9
|
+} from '../Components/Password/config.js';
|
3
|
10
|
|
4
|
11
|
import {
|
5
|
12
|
Table, TableBody, TableCell, TableContainer,
|
|
@@ -7,14 +14,12 @@ import {
|
7
|
14
|
IconButton, Paper, Box,
|
8
|
15
|
Switch, FormControlLabel,Tooltip,
|
9
|
16
|
Checkbox, Typography, Toolbar,
|
10
|
|
- TableSortLabel,TableHead
|
|
17
|
+ // TableSortLabel,TableHead,Card
|
11
|
18
|
} from '@mui/material';
|
12
|
19
|
|
13
|
|
-import { visuallyHidden } from '@mui/utils';
|
14
|
|
-
|
15
|
20
|
import { alpha } from '@mui/material/styles';
|
16
|
21
|
|
17
|
|
-// import { Row, Col, Container } from 'react-bootstrap';
|
|
22
|
+import { Row, Col, Container } from 'react-bootstrap';
|
18
|
23
|
|
19
|
24
|
import {
|
20
|
25
|
Delete as DeleteIcon,
|
|
@@ -22,49 +27,7 @@ import {
|
22
|
27
|
// LastPage as LastPageIcon, FirstPage as FirstPageIcon, KeyboardArrowRight, KeyboardArrowLeft,
|
23
|
28
|
} from '@mui/icons-material/'
|
24
|
29
|
|
25
|
|
-function createData(name, calories, fat, carbs, protein) {
|
26
|
|
- return {
|
27
|
|
- name,
|
28
|
|
- calories,
|
29
|
|
- fat,
|
30
|
|
- carbs,
|
31
|
|
- protein,
|
32
|
|
- };
|
33
|
|
-}
|
34
|
|
-
|
35
|
|
-const rows = [
|
36
|
|
- createData('Cupcake', 305, 3.7, 67, 4.3),
|
37
|
|
- createData('Donut', 452, 25.0, 51, 4.9),
|
38
|
|
- createData('Eclair', 262, 16.0, 24, 6.0),
|
39
|
|
- createData('Frozen yoghurt', 159, 6.0, 24, 4.0),
|
40
|
|
- createData('Gingerbread', 356, 16.0, 49, 3.9),
|
41
|
|
- createData('Honeycomb', 408, 3.2, 87, 6.5),
|
42
|
|
- createData('Ice cream sandwich', 237, 9.0, 37, 4.3),
|
43
|
|
- createData('Jelly Bean', 375, 0.0, 94, 0.0),
|
44
|
|
- createData('KitKat', 518, 26.0, 65, 7.0),
|
45
|
|
- createData('Lollipop', 392, 0.2, 98, 0.0),
|
46
|
|
- createData('Marshmallow', 318, 0, 81, 2.0),
|
47
|
|
- createData('Nougat', 360, 19.0, 9, 37.0),
|
48
|
|
- createData('Oreo', 437, 18.0, 63, 4.0),
|
49
|
|
-];
|
50
|
|
-
|
51
|
|
-function descendingComparator(a, b, orderBy) {
|
52
|
|
- if (b[orderBy] < a[orderBy]) {
|
53
|
|
- return -1;
|
54
|
|
- }
|
55
|
|
- if (b[orderBy] > a[orderBy]) {
|
56
|
|
- return 1;
|
57
|
|
- }
|
58
|
|
- return 0;
|
59
|
|
-}
|
60
|
|
-
|
61
|
|
-function getComparator(order, orderBy) {
|
62
|
|
- return order === 'desc'
|
63
|
|
- ? (a, b) => descendingComparator(a, b, orderBy)
|
64
|
|
- : (a, b) => -descendingComparator(a, b, orderBy);
|
65
|
|
-}
|
66
|
|
-
|
67
|
|
-const EnhancedTableToolbar = (props) => {
|
|
30
|
+const TableEncabezadoOperation = (props) => {
|
68
|
31
|
|
69
|
32
|
const { numSelected } = props;
|
70
|
33
|
return (
|
|
@@ -94,7 +57,7 @@ const EnhancedTableToolbar = (props) => {
|
94
|
57
|
id="tableTitle"
|
95
|
58
|
component="div"
|
96
|
59
|
>
|
97
|
|
- Nutrition
|
|
60
|
+ Contraseñas
|
98
|
61
|
</Typography>
|
99
|
62
|
)}
|
100
|
63
|
|
|
@@ -116,101 +79,6 @@ const EnhancedTableToolbar = (props) => {
|
116
|
79
|
|
117
|
80
|
}
|
118
|
81
|
|
119
|
|
-function EnhancedTableHead(props) {
|
120
|
|
- const { onSelectAllClick, order, orderBy, numSelected, rowCount, onRequestSort } =
|
121
|
|
- props;
|
122
|
|
- const createSortHandler = (property) => (event) => {
|
123
|
|
- onRequestSort(event, property);
|
124
|
|
- };
|
125
|
|
-
|
126
|
|
- return (
|
127
|
|
- <TableHead>
|
128
|
|
- <TableRow>
|
129
|
|
- <TableCell padding="checkbox">
|
130
|
|
- <Checkbox
|
131
|
|
- color="primary"
|
132
|
|
- indeterminate={numSelected > 0 && numSelected < rowCount}
|
133
|
|
- checked={rowCount > 0 && numSelected === rowCount}
|
134
|
|
- onChange={onSelectAllClick}
|
135
|
|
- inputProps={{
|
136
|
|
- 'aria-label': 'select all desserts',
|
137
|
|
- }}
|
138
|
|
- />
|
139
|
|
- </TableCell>
|
140
|
|
- {headCells.map((headCell) => (
|
141
|
|
- <TableCell
|
142
|
|
- key={headCell.id}
|
143
|
|
- align={headCell.numeric ? 'right' : 'left'}
|
144
|
|
- padding={headCell.disablePadding ? 'none' : 'normal'}
|
145
|
|
- sortDirection={orderBy === headCell.id ? order : false}
|
146
|
|
- >
|
147
|
|
- <TableSortLabel
|
148
|
|
- style={{ fontWeight:'bold' }}
|
149
|
|
- active={orderBy === headCell.id}
|
150
|
|
- direction={orderBy === headCell.id ? order : 'asc'}
|
151
|
|
- onClick={createSortHandler(headCell.id)}
|
152
|
|
- >
|
153
|
|
- {headCell.label}
|
154
|
|
- {orderBy === headCell.id ? (
|
155
|
|
- <Box component="span" sx={visuallyHidden}>
|
156
|
|
- {order === 'desc' ? 'sorted descending' : 'sorted ascending'}
|
157
|
|
- </Box>
|
158
|
|
- ) : null}
|
159
|
|
- </TableSortLabel>
|
160
|
|
- </TableCell>
|
161
|
|
- ))}
|
162
|
|
- </TableRow>
|
163
|
|
- </TableHead>
|
164
|
|
- );
|
165
|
|
-}
|
166
|
|
-
|
167
|
|
-function stableSort(array, comparator) {
|
168
|
|
- const stabilizedThis = array.map((el, index) => [el, index]);
|
169
|
|
- stabilizedThis.sort((a, b) => {
|
170
|
|
- const order = comparator(a[0], b[0]);
|
171
|
|
- if (order !== 0) {
|
172
|
|
- return order;
|
173
|
|
- }
|
174
|
|
- return a[1] - b[1];
|
175
|
|
- });
|
176
|
|
- return stabilizedThis.map((el) => el[0]);
|
177
|
|
-}
|
178
|
|
-
|
179
|
|
-const headCells = [
|
180
|
|
- {
|
181
|
|
- id: 'name',
|
182
|
|
- numeric: false,
|
183
|
|
- disablePadding: true,
|
184
|
|
- label: 'Dessert (100g serving)',
|
185
|
|
- },
|
186
|
|
- {
|
187
|
|
- id: 'calories',
|
188
|
|
- numeric: true,
|
189
|
|
- disablePadding: false,
|
190
|
|
- label: 'Calories',
|
191
|
|
- },
|
192
|
|
- {
|
193
|
|
- id: 'fat',
|
194
|
|
- numeric: true,
|
195
|
|
- disablePadding: false,
|
196
|
|
- label: 'Fat (g)',
|
197
|
|
- },
|
198
|
|
- {
|
199
|
|
- id: 'carbs',
|
200
|
|
- numeric: true,
|
201
|
|
- disablePadding: false,
|
202
|
|
- label: 'Carbs (g)',
|
203
|
|
- },
|
204
|
|
- {
|
205
|
|
- id: 'protein',
|
206
|
|
- numeric: true,
|
207
|
|
- disablePadding: false,
|
208
|
|
- label: 'Protein (g)',
|
209
|
|
- },
|
210
|
|
-];
|
211
|
|
-
|
212
|
|
-
|
213
|
|
-
|
214
|
82
|
export function Contras() {
|
215
|
83
|
|
216
|
84
|
const [order, setOrder] = React.useState('asc');
|
|
@@ -218,7 +86,7 @@ export function Contras() {
|
218
|
86
|
const [selected, setSelected] = React.useState([]);
|
219
|
87
|
const [page, setPage] = React.useState(0);
|
220
|
88
|
const [dense, setDense] = React.useState(false);
|
221
|
|
- const [rowsPerPage, setRowsPerPage] = React.useState(5);
|
|
89
|
+ const [rowsPerPage, setRowsPerPage] = React.useState(15);
|
222
|
90
|
|
223
|
91
|
const handleRequestSort = (event, property) => {
|
224
|
92
|
const isAsc = orderBy === property && order === 'asc';
|
|
@@ -228,7 +96,7 @@ export function Contras() {
|
228
|
96
|
|
229
|
97
|
const handleSelectAllClick = (event) => {
|
230
|
98
|
if (event.target.checked) {
|
231
|
|
- const newSelecteds = rows.map((n) => n.name);
|
|
99
|
+ const newSelecteds = rows.map( (n) => n.name);
|
232
|
100
|
setSelected(newSelecteds);
|
233
|
101
|
return;
|
234
|
102
|
}
|
|
@@ -269,102 +137,106 @@ export function Contras() {
|
269
|
137
|
};
|
270
|
138
|
|
271
|
139
|
const isSelected = (name) => selected.indexOf(name) !== -1;
|
272
|
|
-
|
|
140
|
+
|
273
|
141
|
const emptyRows = page > 0 ? Math.max(0, (1 + page) * rowsPerPage - rows.length) : 0;
|
274
|
142
|
|
275
|
143
|
return (
|
276
|
|
-
|
277
|
144
|
<div className="content-section">
|
278
|
145
|
<div className="main">
|
279
|
|
-
|
280
|
|
- <Box sx={{ width: '100%' }}>
|
281
|
|
- <Paper sx={{ width: '100%', mb: 2 }}>
|
282
|
|
- <EnhancedTableToolbar numSelected={selected.length} />
|
283
|
|
- <TableContainer>
|
284
|
|
- <Table
|
285
|
|
- sx={{ minWidth: 750 }}
|
286
|
|
- aria-labelledby="tableTitle"
|
287
|
|
- size={dense ? 'small' : 'medium'}
|
288
|
|
- >
|
289
|
|
- <EnhancedTableHead
|
290
|
|
- numSelected={selected.length}
|
291
|
|
- order={order}
|
292
|
|
- orderBy={orderBy}
|
293
|
|
- onSelectAllClick={handleSelectAllClick}
|
294
|
|
- onRequestSort={handleRequestSort}
|
295
|
|
- rowCount={rows.length}
|
296
|
|
- />
|
297
|
|
- <TableBody>
|
298
|
|
- {/* if you don't need to support IE11, you can replace the `stableSort` call with:
|
299
|
|
-rows.slice().sort(getComparator(order, orderBy)) */}
|
300
|
|
- {stableSort(rows, getComparator(order, orderBy))
|
301
|
|
- .slice(page * rowsPerPage, page * rowsPerPage + rowsPerPage)
|
302
|
|
- .map((row, index) => {
|
303
|
|
- const isItemSelected = isSelected(row.name);
|
304
|
|
- const labelId = `enhanced-table-checkbox-${index}`;
|
305
|
|
-
|
306
|
|
- return (
|
307
|
|
- <TableRow
|
308
|
|
- hover
|
309
|
|
- onClick={(event) => handleClick(event, row.name)}
|
310
|
|
- role="checkbox"
|
311
|
|
- aria-checked={isItemSelected}
|
312
|
|
- tabIndex={-1}
|
313
|
|
- key={row.name}
|
314
|
|
- selected={isItemSelected}
|
315
|
|
- >
|
316
|
|
- <TableCell padding="checkbox">
|
317
|
|
- <Checkbox
|
318
|
|
- color="primary"
|
319
|
|
- checked={isItemSelected}
|
320
|
|
- inputProps={{
|
321
|
|
- 'aria-labelledby': labelId,
|
322
|
|
- }}
|
323
|
|
- />
|
324
|
|
- </TableCell>
|
325
|
|
- <TableCell
|
326
|
|
- component="th"
|
327
|
|
- id={labelId}
|
328
|
|
- scope="row"
|
329
|
|
- padding="none"
|
330
|
|
- >
|
331
|
|
- {row.name}
|
332
|
|
- </TableCell>
|
333
|
|
- <TableCell align="right">{row.calories}</TableCell>
|
334
|
|
- <TableCell align="right">{row.fat}</TableCell>
|
335
|
|
- <TableCell align="right">{row.carbs}</TableCell>
|
336
|
|
- <TableCell align="right">{row.protein}</TableCell>
|
337
|
|
- </TableRow>
|
338
|
|
- );
|
339
|
|
- })}
|
340
|
|
- {emptyRows > 0 && (
|
341
|
|
- <TableRow
|
342
|
|
- style={{
|
343
|
|
- height: (dense ? 33 : 53) * emptyRows,
|
344
|
|
- }}
|
|
146
|
+ <Container>
|
|
147
|
+ <Row>
|
|
148
|
+ <Col>
|
|
149
|
+ <Box sx={{ width: '100%' }}>
|
|
150
|
+ <Paper sx={{ width: '100%', mb: 2 }}>
|
|
151
|
+ <TableEncabezadoOperation numSelected={selected.length} />
|
|
152
|
+ <TableContainer>
|
|
153
|
+ <Table
|
|
154
|
+ sx={{ minWidth: 750 }}
|
|
155
|
+ aria-labelledby="tableTitle"
|
|
156
|
+ size={dense ? 'small' : 'medium'}
|
345
|
157
|
>
|
346
|
|
- <TableCell colSpan={6} />
|
347
|
|
- </TableRow>
|
348
|
|
- )}
|
349
|
|
- </TableBody>
|
350
|
|
- </Table>
|
351
|
|
- </TableContainer>
|
352
|
|
- <TablePagination
|
353
|
|
- rowsPerPageOptions={[5, 10, 25]}
|
354
|
|
- component="div"
|
355
|
|
- count={rows.length}
|
356
|
|
- rowsPerPage={rowsPerPage}
|
357
|
|
- page={page}
|
358
|
|
- onPageChange={handleChangePage}
|
359
|
|
- onRowsPerPageChange={handleChangeRowsPerPage}
|
360
|
|
- />
|
361
|
|
- </Paper>
|
362
|
|
- <FormControlLabel
|
363
|
|
- control={<Switch checked={dense} onChange={handleChangeDense} />}
|
364
|
|
- label="Dense padding"
|
365
|
|
- />
|
366
|
|
- </Box>
|
367
|
|
-
|
|
158
|
+ <EnhancedTableHead
|
|
159
|
+ numSelected={selected.length}
|
|
160
|
+ order={order}
|
|
161
|
+ orderBy={orderBy}
|
|
162
|
+ onSelectAllClick={handleSelectAllClick}
|
|
163
|
+ onRequestSort={handleRequestSort}
|
|
164
|
+ rowCount={rows.length}
|
|
165
|
+ />
|
|
166
|
+ <TableBody>
|
|
167
|
+ {Cuerpo(rows, Comparar(order, orderBy))
|
|
168
|
+ .slice(page * rowsPerPage, page * rowsPerPage + rowsPerPage)
|
|
169
|
+ .map( (row, index) => {
|
|
170
|
+ const isItemSelected = isSelected(row.name);
|
|
171
|
+ const labelId = `enhanced-table-checkbox-${index}`;
|
|
172
|
+
|
|
173
|
+ console.log('INDEX >> ',row)
|
|
174
|
+ return (
|
|
175
|
+ <TableRow
|
|
176
|
+ hover
|
|
177
|
+ onClick={(event) => handleClick(event, row.name)}
|
|
178
|
+ role="checkbox"
|
|
179
|
+ aria-checked={isItemSelected}
|
|
180
|
+ tabIndex={-1}
|
|
181
|
+ key={row.name}
|
|
182
|
+ selected={isItemSelected}
|
|
183
|
+ >
|
|
184
|
+ <TableCell padding="checkbox">
|
|
185
|
+ <Checkbox
|
|
186
|
+ color="primary"
|
|
187
|
+ checked={isItemSelected}
|
|
188
|
+ inputProps={{
|
|
189
|
+ 'aria-labelledby': labelId,
|
|
190
|
+ }}
|
|
191
|
+ />
|
|
192
|
+ </TableCell>
|
|
193
|
+ <TableCell
|
|
194
|
+ component="th"
|
|
195
|
+ id={labelId}
|
|
196
|
+ scope="row"
|
|
197
|
+ padding="none"
|
|
198
|
+ >
|
|
199
|
+ {row.name}
|
|
200
|
+ </TableCell>
|
|
201
|
+ <TableCell align="right">{row.calories}</TableCell>
|
|
202
|
+ <TableCell align="right">{row.fat}</TableCell>
|
|
203
|
+ <TableCell align="right">{row.carbs}</TableCell>
|
|
204
|
+ <TableCell align="right">{row.protein}</TableCell>
|
|
205
|
+ <TableCell align="right">{row.protein}</TableCell>
|
|
206
|
+ <TableCell align="right">{row.protein}</TableCell>
|
|
207
|
+ </TableRow>
|
|
208
|
+ );
|
|
209
|
+ })}
|
|
210
|
+ {emptyRows > 0 && (
|
|
211
|
+ <TableRow
|
|
212
|
+ style={{
|
|
213
|
+ height: (dense ? 33 : 53) * emptyRows,
|
|
214
|
+ }}
|
|
215
|
+ >
|
|
216
|
+ <TableCell colSpan={6} />
|
|
217
|
+ </TableRow>
|
|
218
|
+ )}
|
|
219
|
+ </TableBody>
|
|
220
|
+ </Table>
|
|
221
|
+ </TableContainer>
|
|
222
|
+ <TablePagination
|
|
223
|
+ rowsPerPageOptions={[5, 10, 25]}
|
|
224
|
+ component="div"
|
|
225
|
+ count={rows.length}
|
|
226
|
+ rowsPerPage={rowsPerPage}
|
|
227
|
+ page={page}
|
|
228
|
+ onPageChange={handleChangePage}
|
|
229
|
+ onRowsPerPageChange={handleChangeRowsPerPage}
|
|
230
|
+ />
|
|
231
|
+ </Paper>
|
|
232
|
+ <FormControlLabel
|
|
233
|
+ control={<Switch checked={dense} onChange={handleChangeDense} />}
|
|
234
|
+ label="Comprimir"
|
|
235
|
+ />
|
|
236
|
+ </Box>
|
|
237
|
+ </Col>
|
|
238
|
+ </Row>
|
|
239
|
+ </Container>
|
368
|
240
|
</div>
|
369
|
241
|
</div>
|
370
|
242
|
);
|