Riwayat.js 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  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 Riwayat({ 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</CardTitle>
  21. </CardHeader>
  22. <CardBody>
  23. <Datatable options={{ responsive: true }}>
  24. <table className="table table-striped my-4 w-100" data-order='[[0, "desc"]]'>
  25. <thead>
  26. <tr>
  27. <th>Tanggal</th>
  28. <th>Keterangan</th>
  29. <th>Dokumen</th>
  30. </tr>
  31. </thead>
  32. <tbody>
  33. {data.length
  34. ? data.map((value) => (
  35. <tr>
  36. <td>{moment(value.createdAt).format("DD MMMM YYYY")}</td>
  37. <td>{value.keterangan}</td>
  38. <td>
  39. {value.dokumen.map((e) => (
  40. <>
  41. <em className="fa-lg far fa-file-code"></em>
  42. {role === 2071 ?
  43. <a className="text-muted" onClick={handleOpenAlert}>
  44. {e.judul}
  45. </a>
  46. :
  47. <a className="text-muted" href={e.path} target="_blank" download={e.judul}>
  48. {e.judul}
  49. </a>
  50. }
  51. </>
  52. ))}
  53. </td>
  54. </tr>
  55. ))
  56. : ""}
  57. </tbody>
  58. </table>
  59. </Datatable>
  60. </CardBody>
  61. </Card>
  62. );
  63. }
  64. export default Riwayat;