Reac front end for psicometric app

config.js 5.0KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172
  1. import {
  2. TableHead, TableRow, TableCell,
  3. Checkbox, TableSortLabel, Box,
  4. IconButton,Typography,Toolbar,
  5. Tooltip
  6. } from '@mui/material'
  7. import { alpha } from '@mui/material/styles';
  8. import { visuallyHidden } from '@mui/utils';
  9. import { encabezados } from './Rows';
  10. import {
  11. Delete as DeleteIcon,
  12. FilterList as FilterListIcon,
  13. // LastPage as LastPageIcon, FirstPage as FirstPageIcon, KeyboardArrowRight, KeyboardArrowLeft,
  14. } from '@mui/icons-material/'
  15. export const rows = [
  16. createData('Cupcake', 305, 'Analista',109238109238, 'SI', 'SI', 'Nice', 'Good'),
  17. ]
  18. for(let x of new Array(50)){
  19. console.log(x)
  20. rows.push(rows[0])
  21. }
  22. export const TableEncabezadoOperation = (props) => {
  23. const { numSelected } = props;
  24. return (
  25. <Toolbar
  26. sx={{
  27. pl: { sm: 2 },
  28. pr: { xs: 1, sm: 1 },
  29. ...(numSelected > 0 && {
  30. bgcolor: (theme) =>
  31. alpha(theme.palette.primary.main, theme.palette.action.activatedOpacity),
  32. }),
  33. }}
  34. >
  35. {numSelected > 0 ? (
  36. <Typography
  37. sx={{ flex: '1 1 100%' }}
  38. color="inherit"
  39. variant="subtitle1"
  40. component="div"
  41. >
  42. {numSelected} selected
  43. </Typography>
  44. ) : (
  45. <Typography
  46. sx={{ flex: '1 1 100%' }}
  47. variant="h6"
  48. id="tableTitle"
  49. component="div"
  50. >
  51. Contraseñas
  52. </Typography>
  53. )}
  54. {numSelected > 0 ? (
  55. <Tooltip title="Delete">
  56. <IconButton>
  57. <DeleteIcon />
  58. </IconButton>
  59. </Tooltip>
  60. ) : (
  61. <Tooltip title="Filter list">
  62. <IconButton>
  63. <FilterListIcon />
  64. </IconButton>
  65. </Tooltip>
  66. )}
  67. </Toolbar>
  68. );
  69. }
  70. export function createData(name, calories, fat, carbs, protein) {
  71. return {
  72. name,
  73. calories,
  74. fat,
  75. carbs,
  76. protein,
  77. };
  78. }
  79. function descendingComparator(a, b, orderBy) {
  80. if (b[orderBy] < a[orderBy]) {
  81. return -1;
  82. }
  83. if (b[orderBy] > a[orderBy]) {
  84. return 1;
  85. }
  86. return 0;
  87. }
  88. export function Comparar(order, orderBy) {
  89. return order === 'desc'
  90. ? (a, b) => descendingComparator(a, b, orderBy)
  91. : (a, b) => -descendingComparator(a, b, orderBy);
  92. }
  93. export function Cuerpo(array, comparator) {
  94. const stabilizedThis = array.map((el, index) => [el, index]);
  95. stabilizedThis.sort((a, b) => {
  96. const order = comparator(a[0], b[0]);
  97. if (order !== 0) {
  98. return order;
  99. }
  100. return a[1] - b[1];
  101. });
  102. return stabilizedThis.map((el) => el[0]);
  103. }
  104. export function TableHeader(props){
  105. const { onSelectAllClick, order, orderBy, numSelected, rowCount, onRequestSort } =
  106. props;
  107. const createSortHandler = (property) => (event) => {
  108. onRequestSort(event, property);
  109. };
  110. return (
  111. <TableHead>
  112. <TableRow>
  113. <TableCell padding="checkbox">
  114. <Checkbox
  115. color="primary"
  116. indeterminate={numSelected > 0 && numSelected < rowCount}
  117. checked={rowCount > 0 && numSelected === rowCount}
  118. onChange={onSelectAllClick}
  119. inputProps={{
  120. 'aria-label': 'select all desserts',
  121. }}
  122. />
  123. </TableCell>
  124. { encabezados.map( (headCell, index) => (
  125. <TableCell
  126. key={index}
  127. align={headCell.numeric ? 'right' : 'left'}
  128. padding={headCell.disablePadding ? 'none' : 'normal'}
  129. sortDirection={orderBy === headCell.id ? order : false}
  130. >
  131. <TableSortLabel
  132. style={{ fontWeight:'bold' }}
  133. active={orderBy === headCell.id}
  134. direction={orderBy === headCell.id ? order : 'asc'}
  135. onClick={createSortHandler(headCell.id)}
  136. >
  137. {headCell.label}
  138. {orderBy === headCell.id ? (
  139. <Box component="span" sx={visuallyHidden}>
  140. {order === 'desc' ? 'sorted descending' : 'sorted ascending'}
  141. </Box>
  142. ) : null}
  143. </TableSortLabel>
  144. </TableCell>
  145. ))}
  146. </TableRow>
  147. </TableHead>
  148. );
  149. }