Riwayat.js 1.6 KB

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