detail.js 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152
  1. import React, { Component } from "react";
  2. import ContentWrapper from "@/components/Layout/ContentWrapper";
  3. import { getOneSanksi, updatePT } from "@/actions/sanksi";
  4. import Header from "@/components/Main/Header";
  5. import DetailPT from "@/components/Main/DetailPT";
  6. import DetailSanksi from "@/components/Main/DetailSanksi";
  7. import Riwayat from "@/components/PT/Keberatan/Riwayat";
  8. import ModalPermohonan from "@/components/PT/Keberatan/ModalPermohonan";
  9. import Link from "next/link";
  10. import moment from "moment";
  11. import { Row, Col, Card, CardBody, Button, Modal, ModalBody, ModalFooter } from "reactstrap";
  12. import { connect } from "react-redux";
  13. import Router from "next/router";
  14. import Loader from "@/components/Common/Loader";
  15. import { ToastContainer, toast } from "react-toastify";
  16. class Sanksi extends Component {
  17. state = {
  18. modal: false,
  19. sanksi: {},
  20. pt: null,
  21. };
  22. static getInitialProps = ({ query }) => ({ query });
  23. componentDidMount = async () => {
  24. const { token, query } = this.props;
  25. const sanksi = await getOneSanksi(token, query.id);
  26. updatePT(token, query.id, { is_read: true })
  27. this.setState({ sanksi, pt: sanksi.data.laporan.pt });
  28. };
  29. setModal = (modal) => {
  30. this.setState({
  31. modal: !this.state.modal
  32. })
  33. }
  34. render() {
  35. const { sanksi, pt } = this.state;
  36. console.log(sanksi)
  37. return (
  38. <ContentWrapper unwrap>
  39. <Modal isOpen={this.state.modal} toggle={this.props.toggleModal}>
  40. <ModalBody>Apakah anda akan tidak mengajukan permohonan keberatan atas pengenaan sanksi?</ModalBody>
  41. <ModalFooter>
  42. <Button color className="btn-login" onClick={async () => {
  43. const toastid = toast.loading("Please wait...");
  44. try {
  45. const { token, query } = this.props;
  46. await updatePT(token, query.id, { is_pengajuan_keberatan: false })
  47. toast.update(toastid, { render: "All is good", type: "success", isLoading: false, autoClose: true, closeButton: true });
  48. Router.push("/pt/dokumen-perbaikan");
  49. } catch (error) {
  50. toast.update(toastid, { render: "All is not good", type: "error", isLoading: false, autoClose: true, closeButton: true });
  51. }
  52. }
  53. }>
  54. <span className="font-color-white">Ya</span>
  55. </Button>
  56. <Button color className="btn-v2" onClick={this.setModal}>
  57. Tidak
  58. </Button>
  59. </ModalFooter>
  60. </Modal>
  61. {pt && <Header data={pt} />}
  62. <div className="p-3">
  63. <div className="content-heading">
  64. <span className="font-color-white">
  65. Sanksi
  66. </span>
  67. <div className="ml-auto">
  68. <Link href="/pt/keberatan">
  69. <Button className="color-3e3a8e" color>
  70. <span className="font-color-white">
  71. &lt; Kembali
  72. </span>
  73. </Button>
  74. </Link>
  75. </div>
  76. </div>
  77. <Row>
  78. {sanksi.data ? (
  79. <Col xl="9">
  80. <Card className="card-default">
  81. <CardBody>
  82. <Row>
  83. <Col lg={12}>
  84. <DetailSanksi data={sanksi.data} />
  85. {new Date(sanksi.data.tanggal_akhir_keberatan).getTime() + 86400000 > Date.now() ? (
  86. <>
  87. <p style={{ fontSize: '1vw' }}>
  88. <strong>
  89. Setelah membaca surat keputusan sanksi tersebut, Apakah Perguruan Tinggi bermaksud mengajukan keberatan?
  90. </strong>
  91. </p>
  92. <p style={{ fontSize: '0.9vw' }}>
  93. Pengajuan dilakukan paling lambat tanggal {moment(sanksi.data.tanggal_akhir_keberatan).locale("id").format("DD MMMM YYYY")}
  94. </p>
  95. <p className="lead">
  96. <Link href={{ pathname: "/pt/keberatan/detail", query: { id: sanksi.data._id } }}>
  97. <span className="btn-radius">
  98. <Button color="" className="btn-labeled-notHover" onClick={async () => {
  99. // const toastid = toast.loading("Please wait...");
  100. try {
  101. const { token, query } = this.props;
  102. await updatePT(token, query.id, { is_pengajuan_keberatan: true })
  103. // toast.update(toastid, { render: "Berhasil", type: "success", isLoading: false, autoClose: true, closeButton: true });
  104. } catch (error) {
  105. // toast.update(toastid, { render: "Gagal", type: "error", isLoading: false, autoClose: true, closeButton: true });
  106. }
  107. }
  108. }>
  109. <h4 className="mt-2 mb-md-2 text-center font-color-white pl-3 pr-3">Ya</h4>
  110. </Button>
  111. </span>
  112. </Link>
  113. <span className="btn-radius">
  114. <Button disabled={sanksi.data.is_pengajuan_keberatan === true || sanksi.data.is_pengajuan_keberatan === false} color className="btn-labeled-3-notHover" onClick={this.setModal} >
  115. <h4 className=" mt-1 mb-md-2 text-center">Tidak</h4>
  116. </Button>
  117. </span>
  118. </p>
  119. </>
  120. ) : (
  121. <p>Pengajuan Keberatan Sudah Ditutup</p>
  122. )}
  123. </Col>
  124. </Row>
  125. </CardBody>
  126. </Card>
  127. </Col>
  128. ) : (
  129. <Loader />
  130. )}
  131. <Col xl="3">{pt && <DetailPT data={pt} />}</Col>
  132. </Row>
  133. {/* {sanksi.data && (
  134. <Row>
  135. <Col>
  136. <Riwayat data={sanksi.data?.pengajuan?.keberatan ? sanksi.data.pengajuan.keberatan : null} />
  137. </Col>
  138. </Row>
  139. )} */}
  140. </div>
  141. </ContentWrapper >
  142. );
  143. }
  144. }
  145. const mapStateToProps = (state) => ({ user: state.user, token: state.token });
  146. export default connect(mapStateToProps)(Sanksi);