| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158 |
- import React, { Component } from "react";
- import ContentWrapper from "@/components/Layout/ContentWrapper";
- import { getOneSanksi, updatePT } from "@/actions/sanksi";
- import Header from "@/components/Main/Header";
- import DetailPT from "@/components/Main/DetailPT";
- import DetailSanksi from "@/components/Main/DetailSanksi";
- import Riwayat from "@/components/PT/Keberatan/Riwayat";
- import ModalPermohonan from "@/components/PT/Keberatan/ModalPermohonan";
- import Link from "next/link";
- import moment from "moment";
- import { Row, Col, Card, CardBody, Button, Modal, ModalBody, ModalFooter } from "reactstrap";
- import { connect } from "react-redux";
- import Router from "next/router";
- import Loader from "@/components/Common/Loader";
- import { ToastContainer, toast } from "react-toastify";
- import { getCsrf } from "../../../actions/security";
- class Sanksi extends Component {
- state = {
- modal: false,
- sanksi: {},
- pt: null,
- };
- static getInitialProps = ({ query }) => ({ query });
- componentDidMount = async () => {
- const getToken = await getCsrf();
- const _csrf = getToken.token;
- const { token, query } = this.props;
- const sanksi = await getOneSanksi(token, query.id);
- updatePT(token, query.id, { is_read: true }, _csrf)
- this.setState({ sanksi, pt: sanksi.data.laporan.pt });
- };
- setModal = (modal) => {
- this.setState({
- modal: !this.state.modal
- })
- }
- render() {
- const { sanksi, pt } = this.state;
- return (
- <ContentWrapper unwrap>
- <Modal isOpen={this.state.modal} toggle={this.props.toggleModal}>
- <ModalBody>Apakah anda akan tidak mengajukan permohonan keberatan atas pengenaan sanksi?</ModalBody>
- <ModalFooter>
- <Button color className="btn-login" onClick={async () => {
- const getToken = await getCsrf();
- const _csrf = getToken.token;
- const toastid = toast.loading("Please wait...");
- try {
- const { token, query } = this.props;
- await updatePT(token, query.id, { is_pengajuan_keberatan: false }, _csrf)
- toast.update(toastid, { render: "All is good", type: "success", isLoading: false, autoClose: true, closeButton: true });
- Router.push(`/pt/sanksi/dokumen-perbaikan/detail?id=${sanksi.data._id}`);
- } catch (error) {
- toast.update(toastid, { render: "All is not good", type: "error", isLoading: false, autoClose: true, closeButton: true });
- }
- }
- }>
- <span className="font-color-white">Ya</span>
- </Button>
- <Button color className="btn-v2" onClick={this.setModal}>
- Tidak
- </Button>
- </ModalFooter>
- </Modal>
- {pt && <Header data={pt} />}
- <div className="p-3">
- <div className="content-heading">
- <span className="font-color-white">
- Sanksi
- </span>
- <div className="ml-auto">
- <Link href="/pt/keberatan">
- <Button className="color-3e3a8e" color>
- <span className="font-color-white">
- < Kembali
- </span>
- </Button>
- </Link>
- </div>
- </div>
- <Row>
- {sanksi.data ? (
- <Col xl="9">
- <Card className="card-default">
- <CardBody>
- <Row>
- <Col lg={12}>
- <DetailSanksi data={sanksi.data} />
- {new Date(sanksi.data.tanggal_akhir_keberatan).getTime() + 86400000 > Date.now() ? (
- <>
- <p style={{ fontSize: '1vw' }}>
- <strong>
- Setelah membaca surat keputusan sanksi tersebut, Apakah Perguruan Tinggi bermaksud mengajukan keberatan?
- </strong>
- </p>
- <p style={{ fontSize: '0.9vw' }}>
- Pengajuan dilakukan paling lambat tanggal {moment(sanksi.data.tanggal_akhir_keberatan).locale("id").format("DD MMMM YYYY")}
- </p>
- <p className="lead">
- <Link href={{ pathname: "/pt/sanksi/keberatan/detail", query: { id: sanksi.data._id } }}>
- <span className="btn-radius">
- <Button color="" className="btn-labeled-notHover" onClick={async () => {
- // const toastid = toast.loading("Please wait...");
- const getToken = await getCsrf();
- const _csrf = getToken.token;
- try {
- const { token, query } = this.props;
- await updatePT(token, query.id, { is_pengajuan_keberatan: true }, _csrf)
- // toast.update(toastid, { render: "Berhasil", type: "success", isLoading: false, autoClose: true, closeButton: true });
- } catch (error) {
- // toast.update(toastid, { render: "Gagal", type: "error", isLoading: false, autoClose: true, closeButton: true });
- }
- }
- }>
- <h4 className="mt-2 mb-md-2 text-center font-color-white pl-3 pr-3">Ya</h4>
- </Button>
- </span>
- </Link>
- <span className="btn-radius">
- <Button disabled={sanksi.data.is_pengajuan_keberatan === true || sanksi.data.is_pengajuan_keberatan === false} color className="btn-labeled-3-notHover" onClick={this.setModal} >
- <h4 className=" mt-1 mb-md-2 text-center">Tidak</h4>
- </Button>
- </span>
- </p>
- </>
- ) : (
- <p>Pengajuan Keberatan Sudah Ditutup</p>
- )}
- </Col>
- </Row>
- </CardBody>
- </Card>
- </Col>
- ) : (
- <Loader />
- )}
- <Col xl="3">{pt && <DetailPT data={pt} />}</Col>
- </Row>
- {/* {sanksi.data && (
- <Row>
- <Col>
- <Riwayat data={sanksi.data?.pengajuan?.keberatan ? sanksi.data.pengajuan.keberatan : null} />
- </Col>
- </Row>
- )} */}
- </div>
- </ContentWrapper >
- );
- }
- }
- const mapStateToProps = (state) => ({ user: state.user, token: state.token });
- export default connect(mapStateToProps)(Sanksi);
|