You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 

73 rivejä
2.0 KiB

  1. // material-ui
  2. import * as React from 'react';
  3. import {
  4. GridActionsCellItem,
  5. } from "@mui/x-data-grid";
  6. import {FiDataGrid} from "components/FiDataGrid";
  7. import EditIcon from '@mui/icons-material/Edit';
  8. import {useEffect} from "react";
  9. import {useNavigate} from "react-router-dom";
  10. // ==============================|| EVENT TABLE ||============================== //
  11. export default function UserGroupTable({recordList}) {
  12. const [rows, setRows] = React.useState(recordList);
  13. const navigate = useNavigate()
  14. useEffect(() => {
  15. setRows(recordList);
  16. }, [recordList]);
  17. const handleEditClick = (id) => () => {
  18. navigate('/userGroup/'+ id);
  19. };
  20. const columns = [
  21. {
  22. field: 'actions',
  23. type: 'actions',
  24. headerName: 'Actions',
  25. width: 100,
  26. cellClassName: 'actions',
  27. getActions: ({id}) => {
  28. return [
  29. <GridActionsCellItem
  30. key="OutSave"
  31. icon={<EditIcon/>}
  32. label="Edit"
  33. className="textPrimary"
  34. onClick={handleEditClick(id)}
  35. color="primary"
  36. />]
  37. },
  38. },
  39. {
  40. id: 'groupName',
  41. field: 'name',
  42. headerName: 'User Group Name',
  43. flex: 1,
  44. },
  45. {
  46. id: 'description',
  47. field: 'description',
  48. headerName: 'User Group Description',
  49. flex: 1,
  50. },
  51. ];
  52. function handleRowDoubleClick(params) {
  53. navigate('/userGroup/'+ params.id);
  54. }
  55. return (
  56. <div style={{height: "fit-content", width: '100%'}}>
  57. <FiDataGrid
  58. rows={rows}
  59. columns={columns}
  60. customPageSize={10}
  61. pageSizeOptions={[10, 15, 20]}
  62. onRowDoubleClick={handleRowDoubleClick}
  63. />
  64. </div>
  65. );
  66. }