Ви не можете вибрати більше 25 тем Теми мають розпочинатися з літери або цифри, можуть містити дефіси (-) і не повинні перевищувати 35 символів.

160 рядки
5.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/Visibility';
  8. import { useNavigate } from "react-router-dom";
  9. import * as DateUtils from "utils/DateUtils";
  10. import { clickableLink} from 'utils/CommonFunction';
  11. import {GET_ORG_PATH} from "utils/ApiPathConst";
  12. import { useIntl } from "react-intl";
  13. // ==============================|| EVENT TABLE ||============================== //
  14. export default function OrganizationTable({ searchCriteria, applyGridOnReady, applySearch}) {
  15. const [_searchCriteria, set_searchCriteria] = React.useState(searchCriteria);
  16. const navigate = useNavigate()
  17. const intl = useIntl();
  18. React.useEffect(() => {
  19. set_searchCriteria(searchCriteria);
  20. }, [searchCriteria]);
  21. // const handleActionClick = (id) => () => {
  22. // navigate('/org/' + 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={handleActionClick(id)}
  39. // color="primary"
  40. // />]
  41. // },
  42. // },
  43. {
  44. id: 'brNo',
  45. field: 'brNo',
  46. headerName: 'BR No.',
  47. flex: 1,
  48. minWidth: 150,
  49. renderCell: (params) => {
  50. return clickableLink('/org/'+ params.row.id, params.row.brNo);
  51. },
  52. },
  53. {
  54. id: 'enCompanyName',
  55. field: 'enCompanyName',
  56. headerName: 'Name (Eng)',
  57. flex: 1,
  58. minWidth: 200,
  59. },
  60. {
  61. id: 'chCompanyName',
  62. field: 'chCompanyName',
  63. headerName: 'Name (Ch)',
  64. flex: 1,
  65. minWidth: 150,
  66. },
  67. {
  68. id: 'contactTel',
  69. field: 'contactTel',
  70. headerName: 'Phone',
  71. flex: 1,
  72. minWidth: 150,
  73. renderCell: (params) => {
  74. let phone = JSON.parse(params.value);
  75. let contact = "";
  76. if (phone && phone.phoneNumber) {
  77. contact = phone?.countryCode + " " + phone?.phoneNumber
  78. }
  79. return contact;
  80. }
  81. },
  82. {
  83. id: 'brExpiryDate',
  84. field: 'brExpiryDate',
  85. headerName: 'BR Expiry Date',
  86. flex: 1,
  87. minWidth: 150,
  88. valueGetter: (params) => {
  89. return DateUtils.dateValue(params?.value);
  90. }
  91. },
  92. {
  93. id: 'brStatus',
  94. field: 'brStatus',
  95. headerName: 'BR Status',
  96. flex: 1,
  97. minWidth: 110,
  98. valueGetter: (params) => {
  99. const status = params?.row?.brStatus;
  100. if (status === 'Invalid') {
  101. return intl.formatMessage({ id: 'brStatusInvalid' });
  102. }
  103. if (status === 'Valid') {
  104. return intl.formatMessage({ id: 'brStatusValid' });
  105. }
  106. return status || '';
  107. }
  108. },
  109. {
  110. id: 'newBrSubmitted',
  111. field: 'newBrSubmitted',
  112. headerName: intl.formatMessage({ id: 'newBr' }),
  113. width: 120,
  114. minWidth: 120,
  115. valueGetter: (params) => {
  116. const value = params?.value;
  117. return value === true || value === 1 || value === '1' ? intl.formatMessage({ id: 'newBr' }) : '';
  118. }
  119. },
  120. {
  121. id: 'creditor',
  122. field: 'creditor',
  123. headerName: 'Credit Client',
  124. width: 150,
  125. minWidth: 150,
  126. valueGetter: (params) => {
  127. return params?.value?"Yes":"";
  128. }
  129. },
  130. ];
  131. function handleRowDoubleClick(params) {
  132. navigate('/org/' + params.id);
  133. }
  134. return (
  135. <div style={{ height: "fit-content", width: '100%' }}>
  136. <FiDataGrid
  137. columns={columns}
  138. customPageSize={10}
  139. onRowDoubleClick={handleRowDoubleClick}
  140. applyGridOnReady={applyGridOnReady}
  141. applySearch={applySearch}
  142. // doLoad={{
  143. // url: GET_ORG_PATH,
  144. // params: _searchCriteria,
  145. // }}
  146. doLoad={React.useMemo(() => ({
  147. url: GET_ORG_PATH,
  148. params: _searchCriteria,
  149. }), [_searchCriteria])}
  150. />
  151. </div>
  152. );
  153. }