Reac front end for psicometric app

ContrasV2.jsx 1.6KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. import * as React from 'react';
  2. import { default as CustomToolbar } from '../Components/Password/CustomToolbar';
  3. import { Paper, Box, ThemeProvider } from '@mui/material';
  4. import MUIDataTable from "mui-datatables";
  5. import { Encabezados, Build } from '../Components/Password/Rows';
  6. import { TableStyle, TextLabels } from '../Components/Password/TableStyle'
  7. import { useQuery } from 'react-query';
  8. import { Service } from '../Utils/HTTP.js'
  9. import { useSelector } from 'react-redux';
  10. export function Contrasv2() {
  11. const auth = useSelector((state) => state.token)
  12. const getAllPwd = async () => {
  13. let rest = new Service('/contrasenia/getallbyidUsr');
  14. return await rest.getQuery(auth.token)
  15. }
  16. const { data, status } = useQuery('passwords', getAllPwd );
  17. const options = {
  18. filterType: 'checkbox',
  19. customToolbar: () => {
  20. return (
  21. <CustomToolbar />
  22. );
  23. },
  24. textLabels: TextLabels
  25. };
  26. return (
  27. <div className="content-section">
  28. <div className="main">
  29. <Box sx={{ width: '100%' }}>
  30. <Paper elevation={0} sx={{ mb: 2, padding: 2, height: '100%', minHeight: '95vh', boxShadow: 'none !important' }}>
  31. <ThemeProvider theme={TableStyle}>
  32. <MUIDataTable
  33. sx={{ '& MuiPaper': { elevation: 0, boxShadow: 'none', color: "red" } }}
  34. title={"Contraseñas"}
  35. data={Build( status ==='success' ? data.data : [])}
  36. columns={Encabezados}
  37. options={options}
  38. />
  39. </ThemeProvider>
  40. </Paper>
  41. </Box>
  42. </div>
  43. </div>
  44. );
  45. }