yazid138 před 3 roky
rodič
revize
1da319b7fc

+ 6 - 0
actions/sanksi.js

@@ -27,8 +27,14 @@ export const getSanksi = async (query = {}) => {
 			url += `?ptId=${query.ptId}&keberatan=true&jawaban=true`; // untuk PT Jawaban Keberatan
 		} else if (query.ptId && query.keberatan) {
 			url += `?ptId=${query.ptId}&keberatan=true`; // untuk PT Keberatan & Detail
+		} else if (query.ptId && query.banding && query.jawaban) {
+			url += `?ptId=${query.ptId}&banding=true&jawaban=true`; // untuk PT Jawaban Keberatan
+		} else if (query.ptId && query.banding) {
+			url += `?ptId=${query.ptId}&banding=true`; // untuk PT Keberatan & Detail
 		} else if (query.keberatan) {
 			url += `?keberatan=true`;
+		} else if (query.banding) {
+			url += `?banding=true`;
 		} else if (query.ptId) {
 			url += `?ptId=${query.ptId}`; // Untuk LLDIKTI
 		}

+ 49 - 0
components/Banding/Riwayat.js

@@ -0,0 +1,49 @@
+import Datatable from "@/components/Tables/Datatable";
+import moment from "moment";
+import { Card, CardHeader, CardBody, CardTitle } from "reactstrap";
+
+function Riwayat({ data }) {
+	const jawaban = data.sanksi.banding.jawaban;
+	return (
+		<Card className="card-default">
+			<CardHeader>
+				<CardTitle>Riwayat</CardTitle>
+			</CardHeader>
+			<CardBody>
+				<Datatable options={{ responsive: true }}>
+					<table className="table table-striped my-4 w-100">
+						<thead>
+							<tr>
+								<th>Tanggal</th>
+								<th>Status</th>
+								<th>Dokumen Jawaban</th>
+							</tr>
+						</thead>
+						<tbody>
+							{jawaban ? (
+								<tr>
+									<td>{moment(jawaban.createAt).format("DD MMMM YYYY")}</td>
+									<td>{jawaban.status}</td>
+									<td>
+										{jawaban.files.map((e) => (
+											<>
+												<em className="fa-lg far fa-file-code"></em>
+												<a className="text-muted" href={`data:${e.type};base64, ${Buffer.from(e.data).toString("base64")}`} download={e.name}>
+													{e.name}
+												</a>
+											</>
+										))}
+									</td>
+								</tr>
+							) : (
+								""
+							)}
+						</tbody>
+					</table>
+				</Datatable>
+			</CardBody>
+		</Card>
+	);
+}
+
+export default Riwayat;

+ 1 - 1
components/Keberatan/PermohonanPT.js → components/Main/PermohonanPT.js

@@ -4,7 +4,7 @@ import { Col, FormGroup } from "reactstrap";
 function PermohonanPT({ data }) {
 	return (
 		<>
-			<p className="lead bb">Permohonan PT</p>
+			<p className="lead bb">Permohonan dari PT</p>
 			<form className="form-horizontal">
 				<FormGroup row>
 					<Col md="4">Dokumen Permohonan:</Col>

+ 22 - 1
components/PT/JawabanKeberatan/ModalPermohonan.js

@@ -1,5 +1,7 @@
 import React, { Component } from "react";
+import Router from "next/router";
 import { Row, Col, FormGroup, Button, Modal, ModalHeader, ModalBody, ModalFooter } from "reactstrap";
+import { addBanding } from "@/actions/banding";
 
 let Dropzone = null;
 class DropzoneWrapper extends Component {
@@ -61,10 +63,29 @@ export class ModalPermohonan extends Component {
 		});
 	};
 
-	handleKirim = () => {
+	onSubmit = async (e) => {
+		e.preventDefault();
+		const { noSanksi } = this.props.query;
+		const formdata = new FormData();
+		if (this.state.files.length > 0) {
+			this.state.files.forEach((e) => {
+				formdata.append("files", e);
+			});
+		}
+
+		const added = await addBanding({ noSanksi, ptId: "0BCE4DB7-B207-445D-8D03-0C54B7688252" }, formdata);
+		if (added) {
+			Router.push({
+				pathname: "/app/pt/jawaban-keberatan",
+			});
+		}
+	};
+
+	handleKirim = (e) => {
 		this.setState({
 			modal1: !this.state.modal1,
 		});
+		this.onSubmit(e);
 	};
 
 	render() {

+ 102 - 288
pages/app/banding/detail.js

@@ -2,32 +2,15 @@ import React, { Component } from "react";
 import Router from "next/router";
 import Link from "next/link";
 import Select from "react-select";
-import Scrollable from "@/components/Common/Scrollable";
-import Datatable from "@/components/Tables/Datatable";
-
+import DetailSanksi from "@/components/Main/DetailSanksi";
+import Header from "@/components/Main/Header";
+import DetailPT from "@/components/Main/DetailPT";
+import PermohonanPT from "@/components/Main/PermohonanPT";
+import Riwayat from "@/components/Banding/Riwayat";
+import { getSanksi } from "@/actions/sanksi";
+import { addJawabanBanding } from "@/actions/banding";
 import ContentWrapper from "@/components/Layout/ContentWrapper";
-import {
-	Row,
-	Col,
-	Card,
-	CardHeader,
-	CardBody,
-	CardTitle,
-	FormGroup,
-	FormFeedback,
-	FormText,
-	Label,
-	InputGroup,
-	InputGroupAddon,
-	InputGroupButtonDropdown,
-	InputGroupText,
-	Input,
-	Button,
-	DropdownToggle,
-	DropdownMenu,
-	CustomInput,
-	DropdownItem,
-} from "reactstrap";
+import { Row, Col, Card, CardBody, FormGroup, Button } from "reactstrap";
 
 let Dropzone = null;
 class DropzoneWrapper extends Component {
@@ -43,10 +26,6 @@ class DropzoneWrapper extends Component {
 	}
 }
 
-const styleHeaderText = {
-	color: "brown",
-};
-
 const selectInstanceId = 1;
 
 class JawabanBanding extends Component {
@@ -58,6 +37,11 @@ class JawabanBanding extends Component {
 		};
 	}
 
+	static getInitialProps = async ({ query }) => {
+		const sanksi = await getSanksi(query);
+		return { sanksi, query };
+	};
+
 	handleChangeSelect = (selectedOption) => {
 		this.setState({ selectedOption });
 	};
@@ -92,8 +76,29 @@ class JawabanBanding extends Component {
 		});
 	};
 
+	handelSimpan = async (e) => {
+		e.preventDefault();
+		const { selectedOption } = this.state;
+		const { noSanksi, ptId } = this.props.query;
+		const formdata = new FormData();
+		formdata.append("status", selectedOption.value);
+		if (this.state.files.length > 0) {
+			this.state.files.forEach((e) => {
+				formdata.append("files", e);
+			});
+		}
+
+		const added = await addJawabanBanding({ noSanksi, ptId }, formdata);
+		if (added) {
+			Router.push({
+				pathname: "/app/banding",
+			});
+		}
+	};
+
 	render() {
 		const { files } = this.state;
+		const { sanksi } = this.props;
 
 		const thumbs = files.map((file, index) => (
 			<Col md={3} key={index}>
@@ -103,287 +108,96 @@ class JawabanBanding extends Component {
 
 		return (
 			<ContentWrapper unwrap>
-				<div className="bg-cover" style={{ backgroundImage: "url(/static/img/profile-bg.png)" }}>
-					<div className="p-4 text-center" style={styleHeaderText}>
-						<img className="img-thumbnail rounded-circle thumb128" src="/static/img/univ-avatar.png" alt="Avatar" />
-						<h3 className="m-0">Universitas Satyagama</h3>
-						<p>0742/O/1990</p>
-						<p>Jalan Kamal Raya No 2-A Cengkareng</p>
-					</div>
-				</div>
+				<Header />
 				<div className="p-3">
 					<div className="content-heading">
-						<div>
-							Permohonan Banding
-							{/* <small>Form pembuatan laporan baru v.0.1</small> */}
-						</div>
+						<div>Jawaban Permohonan Banding</div>
 						<div className="ml-auto">
-							<Link href="/app/pt/keberatan">
+							<Link href="/app/banding">
 								<button className="btn btn-sm btn-secondary text-sm">&lt; back</button>
 							</Link>
 						</div>
 					</div>
 					<Row>
-						<Col xl="9">
+						<Col xl={9}>
 							<Card className="card-default">
-								{/* <CardHeader>
-									<label>Informasi Dokumen</label>
-								</CardHeader> */}
 								<CardBody>
 									<Row>
-										<Col lg="6">
-											<p className="lead bb">Detail Laporan</p>
-											<form className="form-horizontal">
-												<FormGroup row>
-													<Col md="4">Nomor Laporan:</Col>
-													<Col md="8">
-														<strong>987654</strong>
-													</Col>
-												</FormGroup>
-												<FormGroup row>
-													<Col md="4">Nama Perguruan Tinggi:</Col>
-													<Col md="8">
-														<strong>Universitas Satyagama</strong>
-													</Col>
-												</FormGroup>
-												<FormGroup row>
-													<Col md="4">Jenis Pelanggaran:</Col>
-													<Col md="8">
-														<Scrollable height="75px" className="list-group">
-															<ul>
-																<li>Lorem ipsum dolor sit amet.</li>
-																<li>Lorem, ipsum dolor.</li>
-																<li>Lorem ipsum dolor sit.</li>
-															</ul>
-														</Scrollable>
-													</Col>
-												</FormGroup>
-												<FormGroup row>
-													<Col md="4">Keterangan Laporan:</Col>
-													<Col md="8">
-														<Scrollable height="100px" className="list-group">
-															<p>
-																Lorem ipsum dolor sit, amet consectetur adipisicing elit. Amet dicta placeat enim illo aspernatur adipisci neque repellendus itaque blanditiis fugit. Quam obcaecati sed
-																perferendis facere.
-															</p>
-														</Scrollable>
-													</Col>
-												</FormGroup>
-												<FormGroup row>
-													<Col md="4">Dibuat Pada:</Col>
-													<Col md="8">
-														<strong>23 Januari 2022</strong>
-													</Col>
-												</FormGroup>
-												<FormGroup row>
-													<Col md="4">Status</Col>
-													<Col md="8">
-														<div className="badge badge-info">Ditindaklanjuti</div>
-													</Col>
-												</FormGroup>
-												<FormGroup row>
-													<Col md="4">File Pendukung</Col>
-													<Col md="8">
-														<Scrollable height="120px" className="list-group">
-															<table className="table table-bordered bg-transparent">
-																<tbody>
-																	<tr>
-																		<td>
-																			<em className="fa-lg far fa-file-code"></em>
-																		</td>
-																		<td>
-																			<a className="text-muted" href="">
-																				database.controller.js
-																			</a>
-																		</td>
-																	</tr>
-																	<tr>
-																		<td>
-																			<em className="fa-lg far fa-file-image"></em>
-																		</td>
-																		<td>
-																			<a className="text-muted" href="">
-																				baground-lg.png
-																			</a>
-																		</td>
-																	</tr>
-																	<tr>
-																		<td>
-																			<em className="fa-lg far fa-file-code"></em>
-																		</td>
-																		<td>
-																			<a className="text-muted" href="">
-																				picture.controller.js
-																			</a>
-																		</td>
-																	</tr>
-																	<tr>
-																		<td>
-																			<em className="fa-lg far fa-file-word"></em>
-																		</td>
-																		<td>
-																			<a className="text-muted" href="">
-																				applicat-diagrams.docx
-																			</a>
-																		</td>
-																	</tr>
-																	<tr>
-																		<td>
-																			<em className="fa-lg far fa-file-code"></em>
-																		</td>
-																		<td>
-																			<a className="text-muted" href="">
-																				database.controller.js
-																			</a>
-																		</td>
-																	</tr>
-																	<tr>
-																		<td>
-																			<em className="fa-lg far fa-file-code"></em>
-																		</td>
-																		<td>
-																			<a className="text-muted" href="">
-																				database.controller.js
-																			</a>
-																		</td>
-																	</tr>
-																</tbody>
-															</table>
-														</Scrollable>
-													</Col>
-												</FormGroup>
-											</form>
+										<Col lg={6}>
+											<DetailSanksi data={sanksi.data[0]} />
 										</Col>
 										<Col lg={6}>
-											<p className="lead bb">Jawaban</p>
-											<form className="form-horizontal" method="get" action="/" onSubmit={this.onSubmit}>
-												<FormGroup>
-													<label className="row-form-label">Status:</label>
-													<div className="row-md-10">
-														<Select
-															instanceId={selectInstanceId + 1}
-															value={this.state.selectedOption}
-															onChange={this.handleChangeSelect}
-															options={[
-																{ value: "diterima", label: "Diterima", className: "State-ACT" },
-																{ value: "ditolak", label: "Ditolak", className: "State-ACT" },
-															]}
-															required
-														/>
-														{/* <span className="form-text">Pilih Jenis Pelanggaran</span> */}
-													</div>
-												</FormGroup>
-												<FormGroup>
-													<label className="row-form-label">Dokumen Jawaban:</label>
-													<div className="row-md-10">
-														<DropzoneWrapper className="" onDrop={this.onDrop}>
-															{({ getRootProps, getInputProps, isDragActive }) => {
-																return (
-																	<div {...getRootProps()} className={"dropzone card p-3 " + (isDragActive ? "dropzone-drag-active" : "")}>
-																		<input {...getInputProps()} />
-																		<div className="dropzone-previews flex">
-																			{this.state.files.length > 0 ? <Row>{thumbs}</Row> : <div className="text-center dz-default dz-message">Drop files here to upload</div>}
-																		</div>
-																		<div className="d-flex align-items-center">
-																			<small className="ml-auto">
-																				<button type="button" className="btn btn-link" onClick={this.clearFiles}>
-																					Clear files
-																				</button>
-																			</small>
-																		</div>
-																	</div>
-																);
-															}}
-														</DropzoneWrapper>
-													</div>
-												</FormGroup>
-												<FormGroup>
-													<div className="row-xl-10">
-														<button className="btn btn-sm btn-primary" type="submit">
-															Simpan
-														</button>
-													</div>
-												</FormGroup>
-											</form>
+											<Row>
+												<Col>
+													<PermohonanPT data={sanksi.data[0]} />
+												</Col>
+											</Row>
+											<Row>
+												<Col>
+													<p className="lead bb">Jawaban</p>
+													<form className="form-horizontal" method="get" action="/" onSubmit={this.onSubmit}>
+														<FormGroup>
+															<label className="row-form-label">Status:</label>
+															<div className="row-md-10">
+																<Select
+																	instanceId={selectInstanceId + 1}
+																	value={this.state.selectedOption}
+																	onChange={this.handleChangeSelect}
+																	options={[
+																		{ value: "diterima", label: "Diterima", className: "State-ACT" },
+																		{ value: "ditolak", label: "Ditolak", className: "State-ACT" },
+																	]}
+																	required
+																/>
+																{/* <span className="form-text">Pilih Jenis Pelanggaran</span> */}
+															</div>
+														</FormGroup>
+														<FormGroup>
+															<label className="row-form-label">Dokumen Jawaban:</label>
+															<div className="row-md-10">
+																<DropzoneWrapper className="" onDrop={this.onDrop}>
+																	{({ getRootProps, getInputProps, isDragActive }) => {
+																		return (
+																			<div {...getRootProps()} className={"dropzone card p-3 " + (isDragActive ? "dropzone-drag-active" : "")}>
+																				<input {...getInputProps()} />
+																				<div className="dropzone-previews flex">
+																					{this.state.files.length > 0 ? <Row>{thumbs}</Row> : <div className="text-center dz-default dz-message">Drop files here to upload</div>}
+																				</div>
+																				<div className="d-flex align-items-center">
+																					<small className="ml-auto">
+																						<button type="button" className="btn btn-link" onClick={this.clearFiles}>
+																							Clear files
+																						</button>
+																					</small>
+																				</div>
+																			</div>
+																		);
+																	}}
+																</DropzoneWrapper>
+															</div>
+														</FormGroup>
+														<FormGroup>
+															<div className="row-xl-10">
+																<Button color="primary" onClick={this.handelSimpan} type="submit">
+																	Simpan
+																</Button>
+															</div>
+														</FormGroup>
+													</form>
+												</Col>
+											</Row>
 										</Col>
 									</Row>
 								</CardBody>
 							</Card>
-							{/* END card */}
 						</Col>
-						<Col xl="3">
-							<div className="card card-default">
-								<div className="card-body">
-									<div className="text-center">
-										<h3 className="mt-0">Universitas Satyagama</h3>
-										<p>0742/O/1990</p>
-									</div>
-									<hr />
-									<ul className="list-unstyled px-4">
-										<li>
-											<em className="fa fa-globe fa-fw mr-3"></em>www.satyagama.ac.id
-										</li>
-										<li>
-											<em className="fa fa-graduation-cap fa-fw mr-3"></em>Status Pelanggaran : Tidak Ada
-										</li>
-									</ul>
-								</div>
-							</div>
+						<Col xl={3}>
+							<DetailPT />
 						</Col>
 					</Row>
 					<Row>
 						<Col>
-							<Card className="card-default">
-								<CardHeader>
-									<CardTitle>Riwayat</CardTitle>
-									{/* <div className="text-sm">DataTables has most features enabled by default, so all you need to do to use it with your own tables is to call the construction function: $().DataTable();.</div> */}
-								</CardHeader>
-								<CardBody>
-									<Datatable options={{ responsive: true }}>
-										<table className="table table-striped my-4 w-100">
-											<thead>
-												<tr>
-													<th>Tanggal</th>
-													<th>Status</th>
-													<th>Dokumen Jawaban</th>
-												</tr>
-											</thead>
-											<tbody>
-												<tr>
-													<td>23/01/2022</td>
-													<td>Ditolak</td>
-													<td>
-														<em className="fa-lg far fa-file-code"></em>
-														<a className="text-muted" href="">
-															database.controller.js
-														</a>
-													</td>
-												</tr>
-												<tr>
-													<td>23/01/2022</td>
-													<td>Ditolak</td>
-													<td>
-														<em className="fa-lg far fa-file-code"></em>
-														<a className="text-muted" href="">
-															database.controller.js
-														</a>
-													</td>
-												</tr>
-												<tr>
-													<td>23/01/2022</td>
-													<td>Ditolak</td>
-													<td>
-														<em className="fa-lg far fa-file-code"></em>
-														<a className="text-muted" href="">
-															database.controller.js
-														</a>
-													</td>
-												</tr>
-											</tbody>
-										</table>
-									</Datatable>
-								</CardBody>
-							</Card>
+							<Riwayat data={sanksi.data[0]} />
 						</Col>
 					</Row>
 				</div>

+ 9 - 146
pages/app/banding/index.js

@@ -1,12 +1,9 @@
 import React, { Component } from "react";
-import Router from "next/router";
 import ContentWrapper from "@/components/Layout/ContentWrapper";
-import { Row, Col, Progress, Button } from "reactstrap";
-import { getPelaporan } from "../../../actions/pelaporan";
-
-import Sparkline from "@/components/Common/Sparklines";
-import Datatable from "@/components/Tables/Datatable";
-import moment from "moment";
+import { Row, Col } from "reactstrap";
+import CaseProgress from "@/components/Main/CaseProgress";
+import TableSanksi from "@/components/Main/TableSanksi";
+import { getSanksi } from "@/actions/sanksi";
 
 class Banding extends Component {
 	constructor(props) {
@@ -14,155 +11,21 @@ class Banding extends Component {
 	}
 
 	static getInitialProps = async () => {
-		const pelaporan = await getPelaporan();
-		return { pelaporan };
-	};
-
-	newReportClick = (e) => {
-		e.preventDefault();
-		Router.push({
-			pathname: "/app/pelaporan/search",
-		});
-	};
-
-	detailBandingClick = (e, ptId, number) => {
-		e.preventDefault();
-		Router.push({
-			pathname: "/app/banding/detail",
-			query: { ptId, number },
-		});
+		const sanksi = await getSanksi({ banding: true });
+		return { sanksi };
 	};
 
 	render() {
-		const { pelaporan } = this.props;
+		const { sanksi } = this.props;
 		return (
 			<ContentWrapper>
 				<div className="content-heading">Banding</div>
 				<Row>
 					<Col lg="4">
-						<div className="card b">
-							<div className="card-body bb">
-								<p>Overvall progress</p>
-								<div className="d-flex align-items-center mb-2">
-									<div className="w-100">
-										<Progress className="progress-xs m0" color="info" value={20} />
-									</div>
-									<div className="ml-auto">
-										<div className="col wd-xxs text-right">
-											<div className="text-bold text-muted">20%</div>
-										</div>
-									</div>
-								</div>
-							</div>
-							<div className="card-body">
-								<p>Metrics</p>
-								<div className="row text-center">
-									<div className="col-6 col-lg-6 col-xl-6">
-										<Sparkline
-											values={[20, 80]}
-											options={{
-												type: "pie",
-												height: "50",
-												sliceColors: ["#edf1f2", "#23b7e5"],
-											}}
-											className="sparkline"
-										/>
-										<p className="mt-3">Open Case</p>
-									</div>
-									<div className="col-6 col-lg-6 col-xl-6">
-										<Sparkline
-											values={[80, 20]}
-											options={{
-												type: "pie",
-												height: "50",
-												sliceColors: ["#edf1f2", "#27c24c"],
-											}}
-											className="sparkline"
-										/>
-										<p className="mt-3">Close Case</p>
-									</div>
-								</div>
-							</div>
-							<table className="table bb">
-								<tbody>
-									<tr>
-										<td>
-											<strong>Open Case</strong>
-										</td>
-										<td>80</td>
-									</tr>
-									<tr>
-										<td>
-											<strong>Close Case</strong>
-										</td>
-										<td>20</td>
-									</tr>
-									<tr>
-										<td>
-											<strong>Performance</strong>
-										</td>
-										<td>
-											<em className="far fa-smile fa-lg text-warning"></em>
-										</td>
-									</tr>
-									<tr>
-										<td>
-											<strong>Last Case Closed</strong>
-										</td>
-										<td>BI:1107 - 12/01/2016</td>
-									</tr>
-								</tbody>
-							</table>
-						</div>
+						<CaseProgress />
 					</Col>
 					<Col lg="8">
-						<div className="card b">
-							<div className="card-body">
-								<Datatable options={{ responsive: true }}>
-									<table className="table w-100">
-										<thead>
-											<tr>
-												<th>#ID</th>
-												<th>Description</th>
-												<th>Created</th>
-												<th>Status</th>
-												{/* <th></th> */}
-											</tr>
-										</thead>
-										<tbody>
-											{pelaporan.data.map((value) => {
-												return (
-													<tr key={value._id}>
-														<td>BI:{value._number}</td>
-														<td className="text-nowrap">
-															<div className="media align-items-center">
-																<img className="img-fluid rounded thumb64" src="/static/img/dummy-search.png" alt="Dummy" />
-																<div className="media-body d-flex">
-																	<div>
-																		<h4 className="m-0">Universitas Satyagama</h4>
-																		<small className="text-muted">0742/O/1990 - www.satyagama.ac.id - info@satyagama.ac.id</small>
-																		<p>{value.description}</p>
-																	</div>
-																</div>
-															</div>
-														</td>
-														<td>{moment(value.createdAt).fromNow()}</td>
-														{/* <td>
-															<div className="inline wd-xxs badge badge-success">open</div>
-														</td> */}
-														<td>
-															<Button color="primary" onClick={(e) => this.detailBandingClick(e, value.pt_id, value.number)}>
-																Detail
-															</Button>
-														</td>
-													</tr>
-												);
-											})}
-										</tbody>
-									</table>
-								</Datatable>
-							</div>
-						</div>
+						<TableSanksi listData={sanksi.data} to="/app/banding/detail" linkName="Detail" />
 					</Col>
 				</Row>
 			</ContentWrapper>

+ 1 - 2
pages/app/keberatan/detail.js

@@ -5,11 +5,10 @@ import Select from "react-select";
 import DetailSanksi from "@/components/Main/DetailSanksi";
 import Header from "@/components/Main/Header";
 import DetailPT from "@/components/Main/DetailPT";
-import PermohonanPT from "@/components/Keberatan/PermohonanPT";
+import PermohonanPT from "@/components/Main/PermohonanPT";
 import Riwayat from "@/components/Keberatan/Riwayat";
 import { getSanksi } from "@/actions/sanksi";
 import { addJawabanKeberatan } from "@/actions/keberatan";
-
 import ContentWrapper from "@/components/Layout/ContentWrapper";
 import { Row, Col, Card, CardBody, FormGroup, Input, Button } from "reactstrap";