|
|
@@ -16,6 +16,7 @@ import { toast } from "react-toastify";
|
|
|
import { Formik, Form, Field, ErrorMessage } from "formik";
|
|
|
import * as Yup from "yup";
|
|
|
import { getCsrf } from "../../../../actions/security";
|
|
|
+import { FinalisasiPerbaikan } from "../../../../actions/docPerbaikan";
|
|
|
const checkIfFilesAreTooBig = (files) => {
|
|
|
let valid = true;
|
|
|
if (files) {
|
|
|
@@ -156,14 +157,29 @@ class DetailPerbaikanDoc extends Component {
|
|
|
<span className="text-left">{index + 1}.{file.name}</span>
|
|
|
</div>
|
|
|
));
|
|
|
- console.log(sanksi.data)
|
|
|
+ // console.log(sanksi.data.perbaikan.find((e)=>(e.length)))\
|
|
|
+ const data = sanksi.data?.perbaikan
|
|
|
+ const lastDatePerbaikan = data?.slice(-1)[0]
|
|
|
return (
|
|
|
<ContentWrapper unwrap>
|
|
|
<Modal isOpen={this.state.modal} >
|
|
|
<ModalBody>jika klik Ya maka tidak bisa upload dokumen perbaikan lagi dan segera dilakukan permohonan pencabutan sanksi</ModalBody>
|
|
|
<ModalFooter>
|
|
|
|
|
|
- <Button color className="btn-login" >
|
|
|
+ <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 FinalisasiPerbaikan(token, query.id, { is_finalisasi: "true" }, _csrf)
|
|
|
+ toast.update(toastid, { render: "All is good", type: "success", isLoading: false, autoClose: true, closeButton: true });
|
|
|
+ Router.push(`/pt/pencabutan-sanksi/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}>
|
|
|
@@ -260,12 +276,12 @@ class DetailPerbaikanDoc extends Component {
|
|
|
</FormGroup>
|
|
|
<FormGroup row>
|
|
|
<div className="ml-3 mr-3">
|
|
|
- <Button color className="color-3e3a8e" type="submit" disabled={isSubmitting}>
|
|
|
+ <Button color className="color-3e3a8e" type="submit" disabled={isSubmitting || sanksi.data.is_finalisasi === true}>
|
|
|
<span className="font-color-white">Upload</span>
|
|
|
</Button>
|
|
|
</div>
|
|
|
<div className=" inline float-right ml-auto mr-3">
|
|
|
- <Button color="success" className=" float-right" onClick={this.setModal} disabled={!sanksi.data?.perbaikan.length}>
|
|
|
+ <Button color="success" className=" float-right" onClick={this.setModal} disabled={!sanksi.data?.perbaikan.length || sanksi.data.is_finalisasi === true||lastDatePerbaikan?.index + 1 === sanksi?.data?.index_perbaikan}>
|
|
|
<span className="font-color-white">Finalisasi upload dokumen perbaikan</span>
|
|
|
</Button>
|
|
|
</div>
|