Non puoi selezionare più di 25 argomenti Gli argomenti devono iniziare con una lettera o un numero, possono includere trattini ('-') e possono essere lunghi fino a 35 caratteri.

129 righe
3.9 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. // ==============================|| EVENT TABLE ||============================== //
  13. export default function OrganizationTable({ searchCriteria, applyGridOnReady }) {
  14. const [_searchCriteria, set_searchCriteria] = React.useState(searchCriteria);
  15. const navigate = useNavigate()
  16. React.useEffect(() => {
  17. set_searchCriteria(searchCriteria);
  18. }, [searchCriteria]);
  19. // const handleActionClick = (id) => () => {
  20. // navigate('/org/' + id);
  21. // };
  22. const columns = [
  23. // {
  24. // field: 'actions',
  25. // type: 'actions',
  26. // headerName: 'Actions',
  27. // width: 100,
  28. // cellClassName: 'actions',
  29. // getActions: ({ id }) => {
  30. // return [
  31. // <GridActionsCellItem
  32. // key="OutSave"
  33. // icon={<EditIcon />}
  34. // label="Edit"
  35. // className="textPrimary"
  36. // onClick={handleActionClick(id)}
  37. // color="primary"
  38. // />]
  39. // },
  40. // },
  41. {
  42. id: 'brNo',
  43. field: 'brNo',
  44. headerName: 'BR No.',
  45. flex: 1,
  46. minWidth: 150,
  47. renderCell: (params) => {
  48. return clickableLink('/org/'+ params.row.id, params.row.brNo);
  49. },
  50. },
  51. {
  52. id: 'enCompanyName',
  53. field: 'enCompanyName',
  54. headerName: 'Name (Eng)',
  55. flex: 1,
  56. minWidth: 200,
  57. },
  58. {
  59. id: 'chCompanyName',
  60. field: 'chCompanyName',
  61. headerName: 'Name (Ch)',
  62. flex: 1,
  63. minWidth: 150,
  64. },
  65. {
  66. id: 'contactTel',
  67. field: 'contactTel',
  68. headerName: 'Phone',
  69. flex: 1,
  70. minWidth: 150,
  71. renderCell: (params) => {
  72. let phone = JSON.parse(params.value);
  73. let contact = "";
  74. if (phone && phone.phoneNumber) {
  75. contact = phone?.countryCode + " " + phone?.phoneNumber
  76. }
  77. return contact;
  78. }
  79. },
  80. {
  81. id: 'brExpiryDate',
  82. field: 'brExpiryDate',
  83. headerName: 'BR Expiry Date',
  84. flex: 1,
  85. minWidth: 150,
  86. valueGetter: (params) => {
  87. return DateUtils.dateValue(params?.value);
  88. }
  89. },
  90. {
  91. id: 'creditor',
  92. field: 'creditor',
  93. headerName: 'Credit Client',
  94. width: 150,
  95. minWidth: 150,
  96. valueGetter: (params) => {
  97. return params?.value?"Yes":"";
  98. }
  99. },
  100. ];
  101. function handleRowDoubleClick(params) {
  102. navigate('/org/' + params.id);
  103. }
  104. return (
  105. <div style={{ height: "fit-content", width: '100%' }}>
  106. <FiDataGrid
  107. columns={columns}
  108. customPageSize={10}
  109. onRowDoubleClick={handleRowDoubleClick}
  110. applyGridOnReady={applyGridOnReady}
  111. // doLoad={{
  112. // url: GET_ORG_PATH,
  113. // params: _searchCriteria,
  114. // }}
  115. doLoad={React.useMemo(() => ({
  116. url: GET_ORG_PATH,
  117. params: _searchCriteria,
  118. }), [_searchCriteria])}
  119. />
  120. </div>
  121. );
  122. }