Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.

148 строки
4.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 VisibilityIcon from '@mui/icons-material/Visibility';
  8. import {useEffect} from "react";
  9. import {useNavigate} from "react-router-dom";
  10. import HighlightOff from '@mui/icons-material/HighlightOff';
  11. import CheckCircleOutline from '@mui/icons-material/CheckCircleOutline';
  12. import * as DateUtils from '../../../utils/DateUtils';
  13. // ==============================|| EVENT TABLE ||============================== //
  14. export default function UserTable_Organization({recordList}) {
  15. const [rows, setRows] = React.useState(recordList);
  16. const navigate = useNavigate()
  17. useEffect(() => {
  18. setRows(recordList);
  19. }, [recordList]);
  20. const handleActionClick = (id) => () => {
  21. navigate('/orgUser/'+ id);
  22. };
  23. const columns = [
  24. {
  25. field: 'actions',
  26. type: 'actions',
  27. headerName: 'Actions',
  28. width: 100,
  29. cellClassName: 'actions',
  30. getActions: ({id}) => {
  31. return [
  32. <GridActionsCellItem
  33. key="OutSave"
  34. icon={<VisibilityIcon/>}
  35. label="View"
  36. className="textPrimary"
  37. onClick={handleActionClick(id)}
  38. color="primary"
  39. />]
  40. },
  41. },
  42. {
  43. id: 'username',
  44. field: 'username',
  45. headerName: 'User Name',
  46. flex: 1,
  47. },
  48. {
  49. id: 'contactPerson',
  50. field: 'contactPerson',
  51. headerName: 'Name',
  52. flex: 1,
  53. },
  54. {
  55. id: 'enCompanyName',
  56. field: 'enCompanyName',
  57. headerName: 'Company(Eng)',
  58. flex: 1,
  59. },
  60. {
  61. id: 'chCompanyName',
  62. field: 'chCompanyName',
  63. headerName: 'Company(Ch)',
  64. flex: 1,
  65. },
  66. {
  67. id: 'brNo',
  68. field: 'brNo',
  69. headerName: 'Br No',
  70. flex: 1,
  71. },
  72. {
  73. id: 'lastLogin',
  74. field: 'lastLogin',
  75. headerName: 'Last Login',
  76. flex: 1,
  77. valueGetter:(params)=>{
  78. if(params.value){
  79. return DateUtils.datetimeStr(params.value);
  80. }
  81. }
  82. },
  83. {
  84. id: 'locked',
  85. field: 'locked',
  86. headerName: 'Status',
  87. flex: 1,
  88. valueGetter:(params)=>{
  89. if(params.value){
  90. return "Locked";
  91. }else{
  92. return "Active";
  93. }
  94. }
  95. },
  96. {
  97. field: 'verifiedDate',
  98. type: 'actions',
  99. headerName: 'Verified',
  100. width: 100,
  101. cellClassName: 'actions',
  102. getActions: (params) => {
  103. if(params.row.verifiedDate)
  104. return [
  105. <GridActionsCellItem
  106. key=""
  107. icon={<CheckCircleOutline/>}
  108. color="success"
  109. />];
  110. return [
  111. <GridActionsCellItem
  112. key=""
  113. icon={<HighlightOff/>}
  114. color="error"
  115. />];
  116. },
  117. },
  118. ];
  119. function handleRowDoubleClick(params) {
  120. navigate('/orgUser/'+ params.id);
  121. }
  122. return (
  123. <div style={{height: "fit-content", width: '100%'}}>
  124. <FiDataGrid
  125. rows={rows}
  126. columns={columns}
  127. initialState={{
  128. pagination: {
  129. paginationModel: {page: 0, pageSize: 5},
  130. },
  131. }}
  132. onRowDoubleClick={handleRowDoubleClick}
  133. />
  134. </div>
  135. );
  136. }