Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.

111 lignes
3.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 { 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. },
  46. {
  47. id: 'enCompanyName',
  48. field: 'enCompanyName',
  49. headerName: 'Name (Eng)',
  50. flex: 1,
  51. },
  52. {
  53. id: 'chCompanyName',
  54. field: 'chCompanyName',
  55. headerName: 'Name (Ch)',
  56. flex: 1,
  57. },
  58. {
  59. id: 'contactTel',
  60. field: 'contactTel',
  61. headerName: 'Phone',
  62. flex: 1,
  63. renderCell: (params) => {
  64. let phone = JSON.parse(params.value);
  65. let contact = "";
  66. if (phone && phone.phoneNumber) {
  67. contact = phone?.countryCode + " " + phone?.phoneNumber
  68. }
  69. return contact;
  70. }
  71. },
  72. {
  73. id: 'brExpiryDate',
  74. field: 'brExpiryDate',
  75. headerName: 'BR Expiry Date',
  76. flex: 1,
  77. valueGetter: (params) => {
  78. return DateUtils.dateStr(params?.value);
  79. }
  80. },
  81. {
  82. id: 'creditor',
  83. field: 'creditor',
  84. headerName: 'Creditor',
  85. width: 100,
  86. valueGetter: (params) => {
  87. return params?.value?"Yes":"";
  88. }
  89. },
  90. ];
  91. function handleRowDoubleClick(params) {
  92. navigate('/org/' + params.id);
  93. }
  94. return (
  95. <div style={{ height: "fit-content", width: '100%' }}>
  96. <FiDataGrid
  97. rows={rows}
  98. columns={columns}
  99. customPageSize={5}
  100. onRowDoubleClick={handleRowDoubleClick}
  101. />
  102. </div>
  103. );
  104. }