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.
 
 

164 lines
4.8 KiB

  1. // material-ui
  2. import * as React from 'react';
  3. import { GridActionsCellItem } from "@mui/x-data-grid";
  4. import { FiDataGrid } from "components/FiDataGrid";
  5. //import VisibilityIcon from '@mui/icons-material/Visibility';
  6. import HighlightOff from '@mui/icons-material/HighlightOff';
  7. import CheckCircleOutline from '@mui/icons-material/CheckCircleOutline';
  8. import { useEffect } from "react";
  9. import { useNavigate } from "react-router-dom";
  10. import * as DateUtils from "utils/DateUtils";
  11. import { GET_IND_USER_PATH } from "utils/ApiPathConst";
  12. import { clickableLink} from 'utils/CommonFunction';
  13. // ==============================|| EVENT TABLE ||============================== //
  14. export default function UserTable_Individual({ searchCriteria }) {
  15. const [_searchCriteria, set_searchCriteria] = React.useState(searchCriteria);
  16. const navigate = useNavigate()
  17. useEffect(() => {
  18. set_searchCriteria(searchCriteria);
  19. }, [searchCriteria]);
  20. // const handleActionClick = (id) => () => {
  21. // navigate('/indUser/' + 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: 'Username',
  46. flex: 1,
  47. minWidth: 150,
  48. renderCell: (params) => {
  49. return clickableLink('/indUser/'+ params.row.id, params.row.username);
  50. },
  51. },
  52. {
  53. id: 'enName',
  54. field: 'enName',
  55. headerName: 'Name (Eng)',
  56. flex: 1,
  57. minWidth: 150,
  58. },
  59. {
  60. id: 'chName',
  61. field: 'chName',
  62. headerName: 'Name (Ch)',
  63. flex: 1,
  64. minWidth: 150,
  65. },
  66. {
  67. id: 'mobileNumber',
  68. field: 'mobileNumber',
  69. headerName: 'Phone',
  70. flex: 1,
  71. minWidth: 150,
  72. valueGetter: (params) => {
  73. if (params.value) {
  74. let tel = JSON.parse(params.value);
  75. if(tel?.phoneNumber)
  76. return "+" + tel?.countryCode + " " + tel?.phoneNumber;
  77. else return "";
  78. }
  79. }
  80. },
  81. {
  82. id: 'emailAddress',
  83. field: 'emailAddress',
  84. headerName: 'Email',
  85. flex: 1,
  86. minWidth: 150,
  87. },
  88. {
  89. id: 'lastLogin',
  90. field: 'lastLogin',
  91. headerName: 'Last Login',
  92. flex: 1,
  93. minWidth: 200,
  94. valueGetter: (params) => {
  95. if (params.value) {
  96. return DateUtils.datetimeStr(params.value);
  97. }
  98. }
  99. },
  100. {
  101. id: 'locked',
  102. field: 'locked',
  103. headerName: 'Status',
  104. flex: 1,
  105. minWidth: 100,
  106. valueGetter: (params) => {
  107. if (params.value) {
  108. return "Locked";
  109. } else {
  110. return "Active";
  111. }
  112. }
  113. },
  114. {
  115. field: 'verifiedDate',
  116. type: 'actions',
  117. headerName: 'Verified',
  118. width: 100,
  119. cellClassName: 'actions',
  120. getActions: (params) => {
  121. if (params.row.verifiedDate)
  122. return [
  123. <GridActionsCellItem
  124. key=""
  125. icon={<CheckCircleOutline />}
  126. color="success"
  127. />];
  128. return [
  129. <GridActionsCellItem
  130. key=""
  131. icon={<HighlightOff />}
  132. color="error"
  133. />];
  134. },
  135. },
  136. ];
  137. function handleRowDoubleClick(params) {
  138. navigate('/indUser/' + params.id);
  139. }
  140. return (
  141. <div style={{ height: "fit-content", width: '100%' }}>
  142. <FiDataGrid
  143. columns={columns}
  144. customPageSize={10}
  145. onRowDoubleClick={handleRowDoubleClick}
  146. doLoad={{
  147. url: GET_IND_USER_PATH,
  148. params: _searchCriteria,
  149. }}
  150. />
  151. </div>
  152. );
  153. }