123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172 |
- import {
- TableHead, TableRow, TableCell,
- Checkbox, TableSortLabel, Box,
- IconButton,Typography,Toolbar,
- Tooltip
- } from '@mui/material'
- import { alpha } from '@mui/material/styles';
- import { visuallyHidden } from '@mui/utils';
- import { encabezados } from './Rows';
- import {
- Delete as DeleteIcon,
- FilterList as FilterListIcon,
- // LastPage as LastPageIcon, FirstPage as FirstPageIcon, KeyboardArrowRight, KeyboardArrowLeft,
- } from '@mui/icons-material/'
- export const rows = [
- createData('Cupcake', 305, 'Analista',109238109238, 'SI', 'SI', 'Nice', 'Good'),
- ]
- for(let x of new Array(50)){
- console.log(x)
- rows.push(rows[0])
- }
- export const TableEncabezadoOperation = (props) => {
- const { numSelected } = props;
- return (
- <Toolbar
- sx={{
- pl: { sm: 2 },
- pr: { xs: 1, sm: 1 },
- ...(numSelected > 0 && {
- bgcolor: (theme) =>
- alpha(theme.palette.primary.main, theme.palette.action.activatedOpacity),
- }),
- }}
- >
- {numSelected > 0 ? (
- <Typography
- sx={{ flex: '1 1 100%' }}
- color="inherit"
- variant="subtitle1"
- component="div"
- >
- {numSelected} selected
- </Typography>
- ) : (
- <Typography
- sx={{ flex: '1 1 100%' }}
- variant="h6"
- id="tableTitle"
- component="div"
- >
- Contraseñas
- </Typography>
- )}
- {numSelected > 0 ? (
- <Tooltip title="Delete">
- <IconButton>
- <DeleteIcon />
- </IconButton>
- </Tooltip>
- ) : (
- <Tooltip title="Filter list">
- <IconButton>
- <FilterListIcon />
- </IconButton>
- </Tooltip>
- )}
- </Toolbar>
- );
- }
- export function createData(name, calories, fat, carbs, protein) {
- return {
- name,
- calories,
- fat,
- carbs,
- protein,
- };
- }
- function descendingComparator(a, b, orderBy) {
- if (b[orderBy] < a[orderBy]) {
- return -1;
- }
- if (b[orderBy] > a[orderBy]) {
- return 1;
- }
- return 0;
- }
- export function Comparar(order, orderBy) {
- return order === 'desc'
- ? (a, b) => descendingComparator(a, b, orderBy)
- : (a, b) => -descendingComparator(a, b, orderBy);
- }
- export function Cuerpo(array, comparator) {
- const stabilizedThis = array.map((el, index) => [el, index]);
- stabilizedThis.sort((a, b) => {
- const order = comparator(a[0], b[0]);
- if (order !== 0) {
- return order;
- }
- return a[1] - b[1];
- });
- return stabilizedThis.map((el) => el[0]);
- }
- export function TableHeader(props){
- const { onSelectAllClick, order, orderBy, numSelected, rowCount, onRequestSort } =
- props;
- const createSortHandler = (property) => (event) => {
- onRequestSort(event, property);
- };
- return (
- <TableHead>
- <TableRow>
- <TableCell padding="checkbox">
- <Checkbox
- color="primary"
- indeterminate={numSelected > 0 && numSelected < rowCount}
- checked={rowCount > 0 && numSelected === rowCount}
- onChange={onSelectAllClick}
- inputProps={{
- 'aria-label': 'select all desserts',
- }}
- />
- </TableCell>
- { encabezados.map( (headCell, index) => (
- <TableCell
- key={index}
- align={headCell.numeric ? 'right' : 'left'}
- padding={headCell.disablePadding ? 'none' : 'normal'}
- sortDirection={orderBy === headCell.id ? order : false}
- >
- <TableSortLabel
- style={{ fontWeight:'bold' }}
- active={orderBy === headCell.id}
- direction={orderBy === headCell.id ? order : 'asc'}
- onClick={createSortHandler(headCell.id)}
- >
- {headCell.label}
- {orderBy === headCell.id ? (
- <Box component="span" sx={visuallyHidden}>
- {order === 'desc' ? 'sorted descending' : 'sorted ascending'}
- </Box>
- ) : null}
- </TableSortLabel>
- </TableCell>
- ))}
- </TableRow>
- </TableHead>
- );
- }
|