andi 1 rok pred
rodič
commit
e31ed75109

+ 4 - 0
actions/docPerbaikan.js

@@ -24,3 +24,7 @@ const logErrorAddDocPerbaikan = async (token, id) => {
 	const _csrf = getToken.token;
 	await createLog(token, { aktivitas: `Gagal melakukan perbaikan dokumen, id: ${id}`, menu: "Dokuemen Perbaikan", _csrf: _csrf });
 }
+export const FinalisasiPerbaikan = async (token, id, data, _csrf) => {
+	const res = await axios.put(`/sanksi/perbaikan/finalisasi/${id}?_csrf=${_csrf}`, data, { headers: { Authorization: token } });
+	return res.data;
+};

+ 13 - 4
components/PT/CabutSanksi/Riwayat.js

@@ -13,6 +13,7 @@ function Riwayat({ data, role }) {
 			confirmButtonText: 'Oke'
 		})
 	};
+	console.log(data)
 	return (
 		<Card className="card-default">
 			<CardHeader>
@@ -25,14 +26,19 @@ function Riwayat({ data, role }) {
 							<tr>
 								<th>Tanggal</th>
 								<th>Dokumen</th>
+								<th>index</th>
 							</tr>
 						</thead>
+						
 						<tbody>
-							{data ? (
+							{data?.length
+								? data.map((data, i) => (
 								<tr>
-									<td>{moment(data?.createdAt).format("DD MMMM YYYY")}</td>
+									<td>{moment(data.createdAt).format("DD MMMM YYYY")}</td>
+									{/* <td>{data.status}</td>
+									<td>{data.keterangan}</td> */}
 									<td>
-										{data?.dokumen?.map((e) => (
+										{data.dokumen?.map((e) => (
 											<>
 												<em className="fa-lg far fa-file-code"></em>
 												{role === 2024 ?
@@ -40,16 +46,19 @@ function Riwayat({ data, role }) {
 														{e.judul}
 													</a>
 													:
+													<>
 													<a className="text-muted" href={e.path} target="_blank" download={e.judul}>
 														{e.judul}
 													</a>
+												</>
 
 												}
 											</>
 										))}
 									</td>
+									<td>{data.index +1}</td>
 								</tr>
-							) : (
+							)) : (
 								""
 							)}
 						</tbody>

+ 3 - 2
components/PT/DocPerbaikan/Riwayat.js

@@ -3,7 +3,6 @@ import moment from "moment";
 import { Card, CardHeader, CardBody, CardTitle } from "reactstrap";
 
 function Riwayat({ data }) {
-	console.log(data)
 	return (
 		<Card className="card-default">
 			<CardHeader>
@@ -11,12 +10,13 @@ function Riwayat({ data }) {
 			</CardHeader>
 			<CardBody>
 				<Datatable options={{ responsive: true }}>
-					<table className="table table-striped my-4 w-100" data-order='[[0, "desc"]]'> 
+					<table className="table table-striped my-4 w-100" data-order='[[0, "desc"]]'>
 						<thead>
 							<tr>
 								<th>Tanggal</th>
 								<th>Ketarangan</th>
 								<th>Dokumen</th>
+								<th>Index</th>
 							</tr>
 						</thead>
 						<tbody>
@@ -35,6 +35,7 @@ function Riwayat({ data }) {
 												</>
 											))}
 										</td>
+										<td>{value.index+ 1}</td>
 									</tr>
 								))
 								: ""}

+ 2 - 1
components/PT/JawabanPencabutanSanksi/TableSanksiJawaban.js

@@ -3,6 +3,7 @@ import { Button, Table } from "reactstrap";
 import Link from "next/link";
 
 function TableSanksi({ listData, to, linkName }) {
+	console.log(listData)
 	return (
 		<div className="card b">
 			<div className="card-body card-over">
@@ -35,7 +36,7 @@ function TableSanksi({ listData, to, linkName }) {
 											</div>
 
 
-										) : (
+										) :  (
 											<div>
 												<div className="badge-info badge">Menunggu Jawaban</div>
 												<p className="w-105">Menunggu jawaban terkait permohonan pencabutan sanksi</p>

+ 9 - 2
components/PencabutanSanksi/Riwayat.js

@@ -14,6 +14,7 @@ function Riwayat({ data, role }) {
 			confirmButtonText: 'Oke'
 		})
 	};
+	// console.log(data.map((e)=> e.dokumen))
 	return (
 		<Card className="card-default">
 			<CardHeader>
@@ -28,10 +29,13 @@ function Riwayat({ data, role }) {
 								<th>Status</th>
 								<th>Keterangan</th>
 								<th>Dokumen</th>
+								<th>index</th>
+
 							</tr>
 						</thead>
 						<tbody>
-							{data ? (
+							{data?.length
+								? data.map((data, i) => (
 								<tr>
 									<td>{moment(data.createdAt).format("DD MMMM YYYY")}</td>
 									<td>{data.status}</td>
@@ -45,16 +49,19 @@ function Riwayat({ data, role }) {
 														{e.judul}
 													</a>
 													:
+													<>
 													<a className="text-muted" href={e.path} target="_blank" download={e.judul}>
 														{e.judul}
 													</a>
+												</>
 
 												}
 											</>
 										))}
 									</td>
+									<td>{data.index}</td>
 								</tr>
-							) : (
+							)) : (
 								""
 							)}
 						</tbody>

+ 3 - 1
components/PencabutanSanksi/RiwayatPerbaikan.js

@@ -13,6 +13,8 @@ function RiwayatPerbaikan({ data, role }) {
 			confirmButtonText: 'Oke'
 		})
 	};
+	console.log(data.map((e)=> e.dokumen))
+
 	return (
 		<Card className="card-default">
 			<CardHeader>
@@ -52,7 +54,7 @@ function RiwayatPerbaikan({ data, role }) {
 												</>
 											))}
 										</td>
-										<td>{++i}</td>
+										<td>{value.index+1}</td>
 									</tr>
 								))
 								: ""}

+ 4 - 4
pages/app/pencabutan-sanksi/detail.js

@@ -87,7 +87,6 @@ class JawabanPencabutanSanksi extends Component {
 		const sanksi = await getOneSanksi(token, query.id);
 		const pt = sanksi.data?.laporan?.pt;
 		this.setState({ sanksi, pt });
-		console.log(sanksi)
 	};
 
 	toggleModal = () => {
@@ -188,7 +187,8 @@ class JawabanPencabutanSanksi extends Component {
 				<button className="bg-transparent button-transparent border-0 fas fa-trash text-danger float-right" onClick={removeFile(file)} />
 			</p>
 		));
-
+		const data = sanksi.data?.riwayat_pengajuan_cabut_sanksi
+		const lastPengajuan = data?.slice(-1)[0]
 		return (
 			<ContentWrapper unwrap>
 				{/* <Header /> */}
@@ -383,7 +383,7 @@ class JawabanPencabutanSanksi extends Component {
 															)}
 															<FormGroup>
 																<div className="row-xl-10">
-																	<Button color className="color-3e3a8e" type="submit" disabled={isSubmitting}>
+																	<Button color className="color-3e3a8e" type="submit" disabled={isSubmitting||lastPengajuan?.index + 1 === sanksi?.data?.index_perbaikan}>
 																		<span className="font-color-white">
 																			Simpan
 																		</span>
@@ -406,7 +406,7 @@ class JawabanPencabutanSanksi extends Component {
 					{sanksi.data && (
 						<Row>
 							<Col>
-								<Riwayat data={sanksi.data.jawaban?.cabut_sanksi} role={this.props.user.role.id} />
+								<Riwayat data={sanksi.data.riwayat_jawaban_cabut_sanksi} role={this.props.user.role.id} />
 							</Col>
 						</Row>
 					)}

+ 8 - 3
pages/pt/pencabutan-sanksi/detail.js

@@ -15,6 +15,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;
@@ -65,7 +66,7 @@ class DetailPencabutanSanksi extends Component {
 			sanksi: {},
 			pt: null,
 			error: null,
-			selectedFile:{},
+			selectedFile: {},
 		};
 	}
 
@@ -122,6 +123,7 @@ class DetailPencabutanSanksi extends Component {
 			formdata.append("dokumen", e);
 		});
 		const id = toast.loading("Please wait...");
+		// await FinalisasiPerbaikan(token, query.id, { is_finalisasi: "true" }, _csrf)
 		const added = await addCabutSanksi(token, query.id, formdata, _csrf);
 		if (!added) {
 			toast.update(id, { render: "Error", type: "error", isLoading: false, autoClose: true, closeButton: true });
@@ -132,6 +134,7 @@ class DetailPencabutanSanksi extends Component {
 			});
 		}
 	};
+	
 
 	render() {
 		const { files, sanksi, pt } = this.state;
@@ -142,6 +145,8 @@ class DetailPencabutanSanksi extends Component {
 				<span className="text-left">{index + 1}.{file.name}</span>
 			</div>
 		));
+		const data = sanksi.data?.riwayat_pengajuan_cabut_sanksi
+		const lastPengajuan = data?.slice(-1)[0]
 		return (
 			<ContentWrapper unwrap>
 				{pt && <Header data={pt} />}
@@ -222,7 +227,7 @@ class DetailPencabutanSanksi extends Component {
 															</FormGroup>
 															<FormGroup>
 																<div className="row-xl-10">
-																	<Button color className="color-3e3a8e" disabled={sanksi.data?.pengajuan?.cabut_sanksi || false} type="submit">
+																	<Button color className="color-3e3a8e" disabled={ sanksi.data.is_finalisasi === false || false||lastPengajuan?.index + 1 === sanksi?.data?.index_perbaikan} type="submit">
 																		<span className="font-color-white">
 																			Kirim
 																		</span>
@@ -245,7 +250,7 @@ class DetailPencabutanSanksi extends Component {
 					{sanksi.data && (
 						<Row>
 							<Col>
-								<Riwayat data={sanksi.data?.pengajuan?.cabut_sanksi || null} />
+								<Riwayat data={sanksi.data?.riwayat_pengajuan_cabut_sanksi } />
 							</Col>
 						</Row>
 					)}

+ 20 - 4
pages/pt/sanksi/dokumen-perbaikan/detail.js

@@ -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>

+ 1 - 1
pages/pt/sanksi/keberatan/detail.js

@@ -61,7 +61,7 @@ class Keberatan extends Component {
 							const toastid = toast.loading("Please wait...");
 							try {
 								const { token, query } = this.props;
-								await updatePT(token, query.id, { is_pengajuan_keberatan: "false" }, _csrf)
+								await updatePT(token, query.id, { is_pengajuan_keberatan: "false",is_pengajuan_banding:"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) {