Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.
 
 

148 lignes
4.0 KiB

  1. // material-ui
  2. import * as React from 'react';
  3. import {
  4. DataGrid,
  5. GridActionsCellItem,
  6. } from "@mui/x-data-grid";
  7. import EditIcon from '@mui/icons-material/Edit';
  8. import {useEffect} from "react";
  9. import {useNavigate} from "react-router-dom";
  10. import { useTheme } from '@mui/material/styles';
  11. import Checkbox from '@mui/material/Checkbox';
  12. // ==============================|| EVENT TABLE ||============================== //
  13. export default function UserTable({recordList}) {
  14. const [rows, setRows] = React.useState(recordList);
  15. const [rowModesModel] = React.useState({});
  16. const theme = useTheme();
  17. const navigate = useNavigate()
  18. useEffect(() => {
  19. setRows(recordList);
  20. }, [recordList]);
  21. const handleEditClick = (id) => () => {
  22. navigate('/user/'+ id);
  23. };
  24. const columns = [
  25. {
  26. field: 'actions',
  27. type: 'actions',
  28. headerName: 'Actions',
  29. width: 100,
  30. cellClassName: 'actions',
  31. getActions: ({id}) => {
  32. return [
  33. <GridActionsCellItem
  34. key="OutSave"
  35. icon={<EditIcon/>}
  36. label="Edit"
  37. className="textPrimary"
  38. onClick={handleEditClick(id)}
  39. color="primary"
  40. />]
  41. },
  42. },
  43. {
  44. id: 'username',
  45. field: 'username',
  46. headerName: 'User Name',
  47. flex: 1,
  48. },
  49. {
  50. id: 'name',
  51. field: 'name',
  52. headerName: 'Full Name',
  53. flex: 1,
  54. },
  55. {
  56. id: 'post',
  57. field: 'post',
  58. headerName: 'Post',
  59. flex: 1,
  60. },
  61. {
  62. id: 'email',
  63. field: 'email',
  64. headerName: 'Email',
  65. flex: 1,
  66. },
  67. {
  68. id: 'subDivisionId',
  69. field: 'subDivisionId',
  70. //type: 'date',
  71. //sortable: false,
  72. headerName: 'Sub-Division',
  73. flex: 1,
  74. },
  75. // {
  76. // id: 'subDivisionId',
  77. // field: 'subDivisionId',
  78. // //type: 'date',
  79. // //sortable: false,
  80. // headerName: 'Sub-Division',
  81. // flex: 1,
  82. // },
  83. // {
  84. // id: 'lotusNotesUser',
  85. // field: 'lotusNotesUser',
  86. // type: 'bool',
  87. // headerName: 'Lotus Notes User',
  88. // flex: 1,
  89. // renderCell: (params) => {
  90. // return (
  91. // <Checkbox
  92. // theme={theme}
  93. // key="locked"
  94. // checked={params.row.lotusNotesUser}
  95. // color="primary"
  96. // size="small"
  97. // //onChange={handleChange}
  98. // />
  99. // );
  100. // },
  101. // },
  102. {
  103. id: 'locked',
  104. field: 'locked',
  105. type: 'bool',
  106. headerName: 'Locked',
  107. flex: 1,
  108. renderCell: (params) => {
  109. return (
  110. <Checkbox
  111. theme={theme}
  112. key="locked"
  113. checked={params.row.locked}
  114. color="primary"
  115. size="small"
  116. //onChange={handleChange}
  117. />
  118. );
  119. },
  120. },
  121. ];
  122. return (
  123. <div style={{height: 400, width: '100%'}}>
  124. <DataGrid
  125. rows={rows}
  126. columns={columns}
  127. editMode="row"
  128. rowModesModel={rowModesModel}
  129. initialState={{
  130. pagination: {
  131. paginationModel: {page: 0, pageSize: 5},
  132. },
  133. }}
  134. pageSizeOptions={[5, 10]}
  135. autoHeight
  136. />
  137. </div>
  138. );
  139. }