Você não pode selecionar mais de 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.
 
 

117 linhas
3.2 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 { useEffect } from "react";
  9. import { useNavigate } from "react-router-dom";
  10. import * as DateUtils from "utils/DateUtils";
  11. // ==============================|| EVENT TABLE ||============================== //
  12. export default function OrganizationTable({ 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('/org/' + 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={<EditIcon />}
  33. label="Edit"
  34. className="textPrimary"
  35. onClick={handleActionClick(id)}
  36. color="primary"
  37. />]
  38. },
  39. },
  40. {
  41. id: 'brNo',
  42. field: 'brNo',
  43. headerName: 'BR No.',
  44. flex: 1,
  45. minWidth: 150,
  46. },
  47. {
  48. id: 'enCompanyName',
  49. field: 'enCompanyName',
  50. headerName: 'Name (Eng)',
  51. flex: 1,
  52. minWidth: 200,
  53. },
  54. {
  55. id: 'chCompanyName',
  56. field: 'chCompanyName',
  57. headerName: 'Name (Ch)',
  58. flex: 1,
  59. minWidth: 150,
  60. },
  61. {
  62. id: 'contactTel',
  63. field: 'contactTel',
  64. headerName: 'Phone',
  65. flex: 1,
  66. minWidth: 150,
  67. renderCell: (params) => {
  68. let phone = JSON.parse(params.value);
  69. let contact = "";
  70. if (phone && phone.phoneNumber) {
  71. contact = phone?.countryCode + " " + phone?.phoneNumber
  72. }
  73. return contact;
  74. }
  75. },
  76. {
  77. id: 'brExpiryDate',
  78. field: 'brExpiryDate',
  79. headerName: 'BR Expiry Date',
  80. flex: 1,
  81. minWidth: 150,
  82. valueGetter: (params) => {
  83. return DateUtils.dateValue(params?.value);
  84. }
  85. },
  86. {
  87. id: 'creditor',
  88. field: 'creditor',
  89. headerName: 'Credit Client',
  90. width: 150,
  91. minWidth: 150,
  92. valueGetter: (params) => {
  93. return params?.value?"Yes":"";
  94. }
  95. },
  96. ];
  97. function handleRowDoubleClick(params) {
  98. navigate('/org/' + params.id);
  99. }
  100. return (
  101. <div style={{ height: "fit-content", width: '100%' }}>
  102. <FiDataGrid
  103. rows={rows}
  104. columns={columns}
  105. customPageSize={5}
  106. onRowDoubleClick={handleRowDoubleClick}
  107. />
  108. </div>
  109. );
  110. }