TableRiwayat.js 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. import Datatable from "@/components/Tables/Datatable";
  2. import moment from "moment";
  3. import 'moment/min/locales';
  4. import Swal from "sweetalert2";
  5. moment.locale('id');
  6. function TableRiwayat({ data, perbaikan, role }) {
  7. const handleOpenAlert = () => {
  8. Swal.fire({
  9. icon: 'error',
  10. title: 'Oops...',
  11. html: 'Maaf anda tidak memiliki akses untuk menyelesaikan<p> proses ini.</p>',
  12. confirmButtonColor: "#3e3a8e",
  13. confirmButtonText: 'Oke'
  14. })
  15. };
  16. return (
  17. // <Datatable options={{ responsive: true }}>
  18. <div className="card-over">
  19. <table className="table table-striped my-4 w-100">
  20. <thead>
  21. <tr>
  22. <th>Tanggal</th>
  23. <th>Keterangan</th>
  24. <th>Nomor Surat Sanksi</th>
  25. <th>Dokumen Surat Sanksi</th>
  26. <th>Dokumen Perbaikan</th>
  27. </tr>
  28. </thead>
  29. <tbody>
  30. <tr>
  31. <td>{moment(data.createdAt).format("D MMMM YYYY")}</td>
  32. <td>{data.keterangan}</td>
  33. <td>{data.no_sanksi}</td>
  34. <td>
  35. {data.dokumen.map((e, index) => (
  36. <>
  37. <em key="index" className="fa-lg far fa-file-code"></em>
  38. <em className="fa-lg far fa-file-code"></em>
  39. {role === 2024 ?
  40. <a className="text-muted" onClick={handleOpenAlert}>
  41. {e.judul}
  42. </a>
  43. :
  44. <a className="text-muted" href={e.path} target="_blank" download={e.judul}>
  45. {e.judul}
  46. </a>
  47. }
  48. <br />
  49. </>
  50. ))}
  51. </td>
  52. {perbaikan.length
  53. ? perbaikan.map((value) => (
  54. <tr>
  55. <td>
  56. {value.dokumen.map((e) => (
  57. <>
  58. <em className="fa-lg far fa-file-code"></em>
  59. {role === 2024 ?
  60. <a className="text-muted" onClick={handleOpenAlert}>
  61. {e.judul}
  62. </a>
  63. :
  64. <a className="text-muted" href={e.path} target="_blank" download={e.judul}>
  65. {e.judul}
  66. </a>
  67. }
  68. </>
  69. ))}
  70. </td>
  71. </tr>
  72. ))
  73. : ""}
  74. </tr>
  75. </tbody>
  76. </table>
  77. </div>
  78. // </Datatable>
  79. );
  80. }
  81. export default TableRiwayat;