Riwayat.js 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  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>Dokumen</th>
  27. </tr>
  28. </thead>
  29. <tbody>
  30. {data ? (
  31. <tr>
  32. <td>{moment(data?.createdAt).format("DD MMMM YYYY")}</td>
  33. <td>
  34. {data?.dokumen?.map((e) => (
  35. <>
  36. <em className="fa-lg far fa-file-code"></em>
  37. {role === 2024 ?
  38. <a className="text-muted" onClick={handleOpenAlert}>
  39. {e.judul}
  40. </a>
  41. :
  42. <a className="text-muted" href={e.path} target="_blank" download={e.judul}>
  43. {e.judul}
  44. </a>
  45. }
  46. </>
  47. ))}
  48. </td>
  49. </tr>
  50. ) : (
  51. ""
  52. )}
  53. </tbody>
  54. </table>
  55. </Datatable>
  56. </CardBody>
  57. </Card>
  58. );
  59. }
  60. export default Riwayat;