| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269 | import React, { Component } from "react";import Link from "next/link";import Select from "react-select";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 { getSanksi } from "@/actions/sanksi";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";let Dropzone = null;class DropzoneWrapper extends Component {	state = {		isClient: false,	};	componentDidMount = () => {		Dropzone = require("react-dropzone").default;		this.setState({ isClient: true });	};	render() {		return Dropzone ? <Dropzone {...this.props}>{this.props.children}</Dropzone> : null;	}}const selectInstanceId = 1;class UploadKeberatan extends Component {	constructor(props) {		super(props);		this.state = {			selectedOption: null,			files: [],		};	}	static getInitialProps = async ({ query }) => {		const sanksi = await getSanksi(query);		return { sanksi, query };	};	handleChangeSelect = (selectedOption) => {		this.setState({ selectedOption });	};	onDrop = (files) => {		this.setState({			files: files.map((file) =>				Object.assign(file, {					preview: URL.createObjectURL(file),				})			),			stat: "Added " + files.length + " file(s)",		});	};	uploadFiles = (e) => {		e.preventDefault();		e.stopPropagation();		this.setState({			stat: this.state.files.length ? "Dropzone ready to upload " + this.state.files.length + " file(s)" : "No files added.",		});	};	clearFiles = (e) => {		e.preventDefault();		e.stopPropagation();		this.setState({			stat: this.state.files.length ? this.state.files.length + " file(s) cleared." : "No files to clear.",		});		this.setState({			files: [],		});	};	render() {		const { files } = this.state;		const { sanksi } = this.props;		console.log(sanksi);		const thumbs = files.map((file, index) => (			<Col md={3} key={index}>				<img className="img-fluid mb-2" src={file.preview} alt="Item" />			</Col>		));		return (			<ContentWrapper unwrap>				<Header />				<div className="p-3">					<div className="content-heading">						<div>							Permohonan Keberatan							{/* <small>Form pembuatan laporan baru v.0.1</small> */}						</div>						<div className="ml-auto">							<Link href="/app/pt/keberatan">								<button className="btn btn-sm btn-secondary text-sm">< back</button>							</Link>						</div>					</div>					<Row>						<Col xl="9">							<Card className="card-default">								{/* <CardHeader>									<label>Informasi Dokumen</label>								</CardHeader> */}								<CardBody>									<Row>										<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: "ditolak", label: "Ditolak", className: "State-ACT" },																{ value: "mengubah sanksi", label: "Mengubah Sanksi", className: "State-ACT" },																{ value: "mencabut sanksi", label: "Mencabut Sanksi", className: "State-ACT" },															]}															required														/>														{/* <span className="form-text">Pilih Jenis Pelanggaran</span> */}													</div>												</FormGroup>												<FormGroup>													<label className="row-form-label">Keterangan Dokumen:</label>													<div className="row-md-10">														<Input type="textarea" value={this.state.keteranganLaporan} onChange={this.setKeteranganPelaporan} required />														{/* <span className="form-text">Deskripsi pelaporan minimum karakter 50 maksimum 200 karakter</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>										</Col>									</Row>								</CardBody>							</Card>							{/* END card */}						</Col>						<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>Keterangan Dokumen</th>													<th>Dokumen Jawaban</th>												</tr>											</thead>											<tbody>												<tr>													<td>23/01/2022</td>													<td>Ditolak</td>													<td>Lorem ipsum dolor sit amet consectetur adipisicing elit. Quos, maxime.</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>Lorem ipsum dolor sit amet consectetur adipisicing.</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>Lorem ipsum dolor sit.</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>						</Col>					</Row>				</div>			</ContentWrapper>		);	}}export default UploadKeberatan;
 |