RiwayatPerbaikan.js 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. import Datatable from "@/components/Tables/Datatable";
  2. import moment from "moment";
  3. import { Card, CardHeader, CardBody, CardTitle } from "reactstrap";
  4. import Swal from "sweetalert2";
  5. import 'moment/locale/id';
  6. moment.locale('id')
  7. function RiwayatPerbaikan({ data, role }) {
  8. const handleOpenAlert = () => {
  9. Swal.fire({
  10. icon: 'error',
  11. title: 'Oops...',
  12. html: 'Maaf anda tidak memiliki akses untuk menyelesaikan<p> proses ini.</p>',
  13. confirmButtonColor: "#3e3a8e",
  14. confirmButtonText: 'Oke'
  15. })
  16. };
  17. return (
  18. <Card className="card-default">
  19. <CardHeader>
  20. <CardTitle>Riwayat Dokumen Perbaikan</CardTitle>
  21. </CardHeader>
  22. <CardBody>
  23. <Datatable options={{ responsive: true }}>
  24. <table className="table table-striped my-4 w-100" data-order='[ [0, "asc"]]'>
  25. <thead>
  26. <tr>
  27. <th>Tanggal</th>
  28. <th>Keterangan</th>
  29. <th>Dokumen</th>
  30. <th>Tahap</th>
  31. </tr>
  32. </thead>
  33. <tbody>
  34. {data.length
  35. ? data.map((value, i) => (
  36. <tr>
  37. <td>{moment(value.createdAt).format("DD MMMM YYYY")}</td>
  38. <td>{value.keterangan}</td>
  39. <td>
  40. {value.dokumen.map((e) => (
  41. <>
  42. <em className="fa-lg far fa-file-code"></em>
  43. {role === 2024 ?
  44. <a className="text-muted" onClick={handleOpenAlert}>
  45. {e.judul}
  46. </a>
  47. :
  48. <a className="text-muted" href={e.path} target="_blank" download={e.judul}>
  49. {e.judul}
  50. </a>
  51. }
  52. </>
  53. ))}
  54. </td>
  55. <td>{value.index+1}</td>
  56. </tr>
  57. ))
  58. : ""}
  59. </tbody>
  60. </table>
  61. </Datatable>
  62. </CardBody>
  63. </Card>
  64. );
  65. }
  66. export default RiwayatPerbaikan;