| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190 | 
							- import React, { Component } from "react";
 
- import { Row, Col, Input, FormGroup } from "reactstrap";
 
- import Select from "react-select";
 
- 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 data = [
 
- 	{
 
- 		value: 'Sanksi Administratif Sedang',
 
- 		// label_sanksi: "- Sanksi Administratif ringan"
 
- 	},
 
- 	{
 
- 		sanksi: "Penghentian Pembinaan PT",
 
- 		value: "Penghentian Pembinaan PT",
 
- 		label_sanksi: "- Sanksi Administratif Berat"
 
- 	},
 
- 	{
 
- 		sanksi: "Pencabutan Izin Perguruan Tinggi Swasta",
 
- 		value: "Pencabutan Izin Perguruan Tinggi Swasta",
 
- 		label_sanksi: "- Sanksi Administratif Berat"
 
- 	},
 
- 	{
 
- 		sanksi: "Penghentian Pembinaan Program Studi",
 
- 		value: "Penghentian Pembinaan Program Studi",
 
- 		label_sanksi: "- Sanksi Administratif Berat"
 
- 	},
 
- 	{
 
- 		sanksi: "Pencabutan Izin Program Studi",
 
- 		value: "Pencabutan Izin Program Studi",
 
- 		label_sanksi: "- Sanksi Administratif Berat"
 
- 	},
 
- 	{
 
- 		sanksi: "Pembubaran Perguruan Tinggi Negeri",
 
- 		value: "Pembubaran Perguruan Tinggi Negeri",
 
- 		label_sanksi: "- Sanksi Administratif Berat"
 
- 	}
 
- ];
 
- const listSanksi = data.map(d => ({
 
- 	"value": d.value,
 
- 	"label": d.sanksi,
 
- 	"label_sanksi": d.label_sanksi
 
- }))
 
- const formatOptionLabel = ({ value, sanksi, label_sanksi }) => (
 
- 	<div style={{ display: "flex" }}>
 
- 		<span className="">{value}</span>
 
- 		<div style={{ marginLeft: "10px", color: "#ccc" }}>
 
- 			{label_sanksi}
 
- 		</div>
 
- 	</div>
 
- );
 
- export class UploadSurat extends Component {
 
- 	constructor(props) {
 
- 		super(props);
 
- 		this.state = {
 
- 			files: [],
 
- 			nomorSanksi: "",
 
- 			keterangan: "",
 
- 		};
 
- 	}
 
- 	onDrop = (files) => {
 
- 		this.setState({
 
- 			files: files.map((file) =>
 
- 				Object.assign(file, {
 
- 					preview: URL.createObjectURL(file),
 
- 				})
 
- 			),
 
- 			stat: "Added " + files.length + " file(s)",
 
- 		});
 
- 		this.props.setUploadSuratSanksi(this.state);
 
- 	};
 
- 	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.",
 
- 		});
 
- 		this.props.setUploadSuratSanksi(this.state);
 
- 	};
 
- 	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: [],
 
- 		});
 
- 		this.props.setUploadSuratSanksi(this.state);
 
- 	};
 
- 	setNomorSanksi = (e) => {
 
- 		this.setState({ nomorSanksi: e.target.value });
 
- 		this.props.setUploadSuratSanksi(this.state);
 
- 	};
 
- 	setKeterangan = (e) => {
 
- 		this.setState({ keterangan: e.target.value });
 
- 		this.props.setUploadSuratSanksi(this.state);
 
- 	};
 
- 	render() {
 
- 		const { files } = this.state;
 
- 		const thumbs = files.map((file, index) => (
 
- 			<div md={3} key={index}>
 
- 				{/* <img className="img-fluid mb-2" src={file.preview} alt="Item" /> */}
 
- 				<span className="text-left">{index + 1}.	{file.name}</span>
 
- 			</div>
 
- 		));
 
- 		return (
 
- 			<form className="form-horizontal" method="get" action="/" onSubmit={this.onSubmit}>
 
- 				<FormGroup row>
 
- 					<label className="col-md-2 col-form-label">Nomor Surat:</label>
 
- 					<div className="col-md-10">
 
- 						<Input type="text" value={this.state.nomorSanksi} onChange={this.setNomorSanksi} />
 
- 					</div>
 
- 				</FormGroup>
 
- 				<FormGroup row className="mt-3">
 
- 					<label className="col-md-2 col-form-label">Keterangan</label>
 
- 					<div className="col-md-10">
 
- 						<Input type="textarea" value={this.state.keterangan} onChange={this.setKeterangan} required />
 
- 						{/* <span className="form-text">Deskripsi pelaporan minimum karakter 50 maksimum 200 karakter</span> */}
 
- 					</div>
 
- 				</FormGroup>
 
- 				<FormGroup row className="mt-3">
 
- 					<label className="col-md-2 col-form-label">List sanksi	</label>
 
- 					<div className="col-md-10">
 
- 						<Select
 
- 							options={listSanksi}
 
- 							formatOptionLabel={formatOptionLabel}
 
- 							isMulti
 
- 						/>
 
- 					</div>
 
- 				</FormGroup>
 
- 				<FormGroup row>
 
- 					<label className="col-md-2 col-form-label">Dokumen Surat Sanksi<span className="text-danger">*</span>:</label>
 
- 					<div className="col-md-10">
 
- 						<DropzoneWrapper className="" onDrop={this.onDrop}>
 
- 							{({ getRootProps, getInputProps, isDragActive }) => {
 
- 								return (
 
- 									<div {...getRootProps()} className={"dropzone card" + (isDragActive ? "dropzone-drag-active" : "")}>
 
- 										<input {...getInputProps()} />
 
- 										<div className="dropzone-style-1">
 
- 											<div className="center-ver-hor dropzone-previews flex">{this.state.files.length > 0 ? <Row><span className="text-left">{thumbs}</span></Row> :
 
- 												<div className="text-center fa-2x icon-cloud-upload mr-2 ">
 
- 													<h5 className="text-center dz-default dz-message">Klik untuk upload dokumen</h5>
 
- 												</div>
 
- 											}
 
- 											</div>
 
- 										</div>
 
- 										<div className="d-flex align-items-center">
 
- 											<small className="ml-auto">
 
- 												<button type="button" className="btn btn-link" onClick={this.clearFiles}>
 
- 													Reset dokumen
 
- 												</button>
 
- 											</small>
 
- 										</div>
 
- 									</div>
 
- 								);
 
- 							}}
 
- 						</DropzoneWrapper>
 
- 						{/* <span className="form-text">Multiple files upload</span> */}
 
- 						<p className="mrgn-top-5">
 
- 							Ukuran setiap dokumen maksimal 15mb
 
- 						</p>
 
- 					</div>
 
- 				</FormGroup>
 
- 			</form>
 
- 		);
 
- 	}
 
- }
 
- export default UploadSurat;
 
 
  |