Du kannst nicht mehr als 25 Themen auswählen Themen müssen entweder mit einem Buchstaben oder einer Ziffer beginnen. Sie können Bindestriche („-“) enthalten und bis zu 35 Zeichen lang sein.
 
 

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