|  | @@ -24,6 +24,7 @@ import ComponentToPrint from "../../../components/Sanksi/SuratBA_A";
 | 
	
		
			
				|  |  |  import ReactToPrint, { PrintContextConsumer } from 'react-to-print';
 | 
	
		
			
				|  |  |  import { updatePddikti } from "../../../actions/sanksi";
 | 
	
		
			
				|  |  |  import { ENV } from "../../../env";
 | 
	
		
			
				|  |  | +import Swal from "sweetalert2";
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |  
 | 
	
	
		
			
				|  | @@ -65,25 +66,40 @@ class ProsesSanksi extends Component {
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |  	handleAutoSave = async (data, activeStep) => {
 | 
	
		
			
				|  |  | +		if (this.props.user.role.id === 2024) {
 | 
	
		
			
				|  |  | +			""
 | 
	
		
			
				|  |  | +		} else {
 | 
	
		
			
				|  |  | +			const { query, token } = this.props;
 | 
	
		
			
				|  |  | +			const { id } = query;
 | 
	
		
			
				|  |  | +			const { dataSuratBA, dataUpload } = this.state
 | 
	
		
			
				|  |  | +			await inputAutoSave({ data: { PenetapanSanksi: { dataSuratBA, dataUpload, dataPelanggaran: data, activeStep } }, token, id, laporan: true })
 | 
	
		
			
				|  |  | +		}
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | -		const { query, token } = this.props;
 | 
	
		
			
				|  |  | -		const { id } = query;
 | 
	
		
			
				|  |  | -		const { dataSuratBA, dataUpload } = this.state
 | 
	
		
			
				|  |  | -		await inputAutoSave({ data: { PenetapanSanksi: { dataSuratBA, dataUpload, dataPelanggaran: data, activeStep } }, token, id, laporan: true })
 | 
	
		
			
				|  |  |  	}
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |  	done = async () => {
 | 
	
		
			
				|  |  | -		this.setState({
 | 
	
		
			
				|  |  | -			loading: true
 | 
	
		
			
				|  |  | -		})
 | 
	
		
			
				|  |  | -		const sanksi = await this.tambahSanksi()
 | 
	
		
			
				|  |  | -		if (sanksi && ENV === "production") {
 | 
	
		
			
				|  |  | -			await this.updatePddikti(sanksi.data._id)  //kirim sanksiID ke function updatePDDIKTI
 | 
	
		
			
				|  |  | -		}
 | 
	
		
			
				|  |  | +		if (this.props.user.role.id === 2024) {
 | 
	
		
			
				|  |  | +			Swal.fire({
 | 
	
		
			
				|  |  | +				icon: 'error',
 | 
	
		
			
				|  |  | +				title: 'Oops...',
 | 
	
		
			
				|  |  | +				html: 'Maaf anda tidak memiliki akses untuk menyelesaikan<p> proses ini.</p>',
 | 
	
		
			
				|  |  | +				confirmButtonColor: "#3e3a8e",
 | 
	
		
			
				|  |  | +				confirmButtonText: 'Oke'
 | 
	
		
			
				|  |  | +				// footer: '<a href="">Why do I have this issue?</a>'
 | 
	
		
			
				|  |  | +			})
 | 
	
		
			
				|  |  | +		} else {
 | 
	
		
			
				|  |  | +			this.setState({
 | 
	
		
			
				|  |  | +				loading: true
 | 
	
		
			
				|  |  | +			})
 | 
	
		
			
				|  |  | +			const sanksi = await this.tambahSanksi()
 | 
	
		
			
				|  |  | +			if (sanksi && ENV === "production") {
 | 
	
		
			
				|  |  | +				await this.updatePddikti(sanksi.data._id)  //kirim sanksiID ke function updatePDDIKTI
 | 
	
		
			
				|  |  | +			}
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | -		await Router.push({
 | 
	
		
			
				|  |  | -			pathname: "/app/sanksi",
 | 
	
		
			
				|  |  | -		});
 | 
	
		
			
				|  |  | +			await Router.push({
 | 
	
		
			
				|  |  | +				pathname: "/app/sanksi",
 | 
	
		
			
				|  |  | +			});
 | 
	
		
			
				|  |  | +		}
 | 
	
		
			
				|  |  |  	};
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |  	updatePddikti = async (sanksiId) => {
 | 
	
	
		
			
				|  | @@ -129,13 +145,13 @@ class ProsesSanksi extends Component {
 | 
	
		
			
				|  |  |  						formdata.append("dokumen_terima_sanksi", e);
 | 
	
		
			
				|  |  |  					});
 | 
	
		
			
				|  |  |  				}
 | 
	
		
			
				|  |  | -	
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  |  				const sanksi = await createSanksi(token, id, formdata, _csrf)
 | 
	
		
			
				|  |  | -	
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  |  				toast.update(toastid, { render: "Berhasil membuat sanksi", type: "success", isLoading: false, autoClose: true, closeButton: true });
 | 
	
		
			
				|  |  |  				return sanksi
 | 
	
		
			
				|  |  |  			}
 | 
	
		
			
				|  |  | -	
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  |  			catch (error) {
 | 
	
		
			
				|  |  |  				toast.update(toastid, { render: error.response.data.message || error.message, type: "error", isLoading: false, autoClose: true, closeButton: true });
 | 
	
		
			
				|  |  |  				return null
 | 
	
	
		
			
				|  | @@ -147,7 +163,7 @@ class ProsesSanksi extends Component {
 | 
	
		
			
				|  |  |  				const formdata = new FormData();
 | 
	
		
			
				|  |  |  				formdata.append("no_sanksi", this.state.dataUpload.nomorSanksi);
 | 
	
		
			
				|  |  |  				formdata.append("keterangan", this.state.dataUpload.keterangan);
 | 
	
		
			
				|  |  | -	
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  |  				formdata.append("from_date", this.state.dataUpload.awalTMT);
 | 
	
		
			
				|  |  |  				formdata.append("to_date", this.state.dataUpload.akhirTMT);
 | 
	
		
			
				|  |  |  				formdata.append("tanggal_terima_sanksi", this.state.dataUpload.terimaSuratSanksi);
 | 
	
	
		
			
				|  | @@ -163,41 +179,50 @@ class ProsesSanksi extends Component {
 | 
	
		
			
				|  |  |  						formdata.append("dokumen_terima_sanksi", e);
 | 
	
		
			
				|  |  |  					});
 | 
	
		
			
				|  |  |  				}
 | 
	
		
			
				|  |  | -	
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  |  				const sanksi = await createSanksi(token, id, formdata, _csrf)
 | 
	
		
			
				|  |  | -	
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  |  				toast.update(toastid, { render: "Berhasil membuat sanksi", type: "success", isLoading: false, autoClose: true, closeButton: true });
 | 
	
		
			
				|  |  |  				return sanksi
 | 
	
		
			
				|  |  |  			}
 | 
	
		
			
				|  |  | -	
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  |  			catch (error) {
 | 
	
		
			
				|  |  |  				toast.update(toastid, { render: error.response.data.message || error.message, type: "error", isLoading: false, autoClose: true, closeButton: true });
 | 
	
		
			
				|  |  |  				return null
 | 
	
		
			
				|  |  |  			}
 | 
	
		
			
				|  |  |  		}
 | 
	
		
			
				|  |  | -		
 | 
	
		
			
				|  |  | -
 | 
	
		
			
				|  |  | -	}
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | +	}
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |  	handleDelegasi = async (data) => {
 | 
	
		
			
				|  |  | -
 | 
	
		
			
				|  |  | -		const getToken = await getCsrf();
 | 
	
		
			
				|  |  | -		const _csrf = getToken.token;
 | 
	
		
			
				|  |  | -		const { token, query } = this.props;
 | 
	
		
			
				|  |  | -		const { id } = query;
 | 
	
		
			
				|  |  | -		let update = null;
 | 
	
		
			
				|  |  | -		const toastid = toast.loading("Please wait...");
 | 
	
		
			
				|  |  | -		data.change_role = "true";
 | 
	
		
			
				|  |  | -		data.keterangan = "delegasi ke DIKTI"
 | 
	
		
			
				|  |  | -		update = await updateLaporan(token, id, data, _csrf);
 | 
	
		
			
				|  |  | -
 | 
	
		
			
				|  |  | -		if (!update) {
 | 
	
		
			
				|  |  | -			toast.update(toastid, { render: "Laporan gagal didelegasi", type: "error", isLoading: false, autoClose: true, closeButton: true });
 | 
	
		
			
				|  |  | +		if (this.props.user.role.id === 2024) {
 | 
	
		
			
				|  |  | +			Swal.fire({
 | 
	
		
			
				|  |  | +				icon: 'error',
 | 
	
		
			
				|  |  | +				title: 'Oops...',
 | 
	
		
			
				|  |  | +				html: 'Maaf anda tidak memiliki akses untuk menyelesaikan<p> proses ini.</p>',
 | 
	
		
			
				|  |  | +				confirmButtonColor: "#3e3a8e",
 | 
	
		
			
				|  |  | +				confirmButtonText: 'Oke'
 | 
	
		
			
				|  |  | +				// footer: '<a href="">Why do I have this issue?</a>'
 | 
	
		
			
				|  |  | +			})
 | 
	
		
			
				|  |  |  		} else {
 | 
	
		
			
				|  |  | -			toast.update(toastid, { render: "Laporan berhasil didelegasi", type: "success", isLoading: false, autoClose: true, closeButton: true });
 | 
	
		
			
				|  |  | -			Router.push("/app/sanksi");
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +			const getToken = await getCsrf();
 | 
	
		
			
				|  |  | +			const _csrf = getToken.token;
 | 
	
		
			
				|  |  | +			const { token, query } = this.props;
 | 
	
		
			
				|  |  | +			const { id } = query;
 | 
	
		
			
				|  |  | +			let update = null;
 | 
	
		
			
				|  |  | +			const toastid = toast.loading("Please wait...");
 | 
	
		
			
				|  |  | +			data.change_role = "true";
 | 
	
		
			
				|  |  | +			data.keterangan = "delegasi ke DIKTI"
 | 
	
		
			
				|  |  | +			update = await updateLaporan(token, id, data, _csrf);
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +			if (!update) {
 | 
	
		
			
				|  |  | +				toast.update(toastid, { render: "Laporan gagal didelegasi", type: "error", isLoading: false, autoClose: true, closeButton: true });
 | 
	
		
			
				|  |  | +			} else {
 | 
	
		
			
				|  |  | +				toast.update(toastid, { render: "Laporan berhasil didelegasi", type: "success", isLoading: false, autoClose: true, closeButton: true });
 | 
	
		
			
				|  |  | +				Router.push("/app/sanksi");
 | 
	
		
			
				|  |  | +			}
 | 
	
		
			
				|  |  |  		}
 | 
	
		
			
				|  |  |  	};
 | 
	
		
			
				|  |  |  
 | 
	
	
		
			
				|  | @@ -283,11 +308,18 @@ class ProsesSanksi extends Component {
 | 
	
		
			
				|  |  |  				});
 | 
	
		
			
				|  |  |  			}
 | 
	
		
			
				|  |  |  		}
 | 
	
		
			
				|  |  | -
 | 
	
		
			
				|  |  | -
 | 
	
		
			
				|  |  | -
 | 
	
		
			
				|  |  |  	}
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | +	handleOpenAlert = () => {
 | 
	
		
			
				|  |  | +		Swal.fire({
 | 
	
		
			
				|  |  | +			icon: 'error',
 | 
	
		
			
				|  |  | +			title: 'Oops...',
 | 
	
		
			
				|  |  | +			html: 'Maaf anda tidak memiliki akses untuk menyelesaikan<p> proses ini.</p>',
 | 
	
		
			
				|  |  | +			confirmButtonColor: "#3e3a8e",
 | 
	
		
			
				|  |  | +			confirmButtonText: 'Oke'
 | 
	
		
			
				|  |  | +		})
 | 
	
		
			
				|  |  | +	};
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  |  	render() {
 | 
	
		
			
				|  |  |  		const { dataUpload, dataPelanggaran, pelaporan, dataSuratBA } = this.state
 | 
	
		
			
				|  |  |  		return (
 | 
	
	
		
			
				|  | @@ -457,17 +489,25 @@ class ProsesSanksi extends Component {
 | 
	
		
			
				|  |  |  													<div style={{ display: "none" }}>
 | 
	
		
			
				|  |  |  														<ComponentToPrint ref={el => (this.componentRef = el)} query={this.props.query} handleAutoSave={this.handleAutoSave} dataPelanggaran={this.state.dataPelanggaran} setDataSuratBA={this.setDataSuratBA} dataLaporan={pelaporan} dataSuratBA={dataSuratBA} />
 | 
	
		
			
				|  |  |  													</div>
 | 
	
		
			
				|  |  | -													<ReactToPrint
 | 
	
		
			
				|  |  | -														trigger={() => {
 | 
	
		
			
				|  |  | -															return <span>
 | 
	
		
			
				|  |  | -
 | 
	
		
			
				|  |  | -																<Button color className="btn-labeled-4 mt-0">
 | 
	
		
			
				|  |  | -																	<h5 className="p-0 mt-2"><em className="fas fa-download mr-2" />Print dan Download</h5>
 | 
	
		
			
				|  |  | -																</Button>
 | 
	
		
			
				|  |  | -															</span>
 | 
	
		
			
				|  |  | -														}}
 | 
	
		
			
				|  |  | -														content={() => this.componentRef}
 | 
	
		
			
				|  |  | -													/>
 | 
	
		
			
				|  |  | +													{this.props.user.role.id === 2024 ?
 | 
	
		
			
				|  |  | +														<Button color className="btn-labeled-4 mt-0" onClick={this.handleOpenAlert}>
 | 
	
		
			
				|  |  | +															<h5 className="p-0 mt-2"><em className="fas fa-download mr-2" />Print dan Download</h5>
 | 
	
		
			
				|  |  | +														</Button>
 | 
	
		
			
				|  |  | +														:
 | 
	
		
			
				|  |  | +														<ReactToPrint
 | 
	
		
			
				|  |  | +															trigger={() => {
 | 
	
		
			
				|  |  | +																return <span>
 | 
	
		
			
				|  |  | +																	<Button color className="btn-labeled-4 mt-0">
 | 
	
		
			
				|  |  | +																		<h5 className="p-0 mt-2"><em className="fas fa-download mr-2" />Print dan Download</h5>
 | 
	
		
			
				|  |  | +																	</Button>
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +																</span>
 | 
	
		
			
				|  |  | +															}}
 | 
	
		
			
				|  |  | +															content={() => this.componentRef}
 | 
	
		
			
				|  |  | +														/>
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +													}
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  |  												</div>
 | 
	
		
			
				|  |  |  											</FormGroup>
 | 
	
		
			
				|  |  |  											<hr />
 | 
	
	
		
			
				|  | @@ -487,17 +527,22 @@ class ProsesSanksi extends Component {
 | 
	
		
			
				|  |  |  												<FormGroup row>
 | 
	
		
			
				|  |  |  													<Col md="4">Surat Berita Acara:</Col>
 | 
	
		
			
				|  |  |  													<Col md="8">
 | 
	
		
			
				|  |  | -
 | 
	
		
			
				|  |  | -														<ReactToPrint
 | 
	
		
			
				|  |  | -															trigger={() => {
 | 
	
		
			
				|  |  | -																return <span>
 | 
	
		
			
				|  |  | -																	<Button color className="btn-labeled-4 mt-0">
 | 
	
		
			
				|  |  | -																		<h5 className="p-0 mt-2"><em className="fas fa-download mr-2" />Print dan Download</h5>
 | 
	
		
			
				|  |  | -																	</Button>
 | 
	
		
			
				|  |  | -																</span>
 | 
	
		
			
				|  |  | -															}}
 | 
	
		
			
				|  |  | -															content={() => this.componentRef}
 | 
	
		
			
				|  |  | -														/>
 | 
	
		
			
				|  |  | +														{this.props.user.role.id === 2024 ?
 | 
	
		
			
				|  |  | +															<Button color className="btn-labeled-4 mt-0" onClick={this.handleOpenAlert}>
 | 
	
		
			
				|  |  | +																<h5 className="p-0 mt-2"><em className="fas fa-download mr-2" />Print dan Download</h5>
 | 
	
		
			
				|  |  | +															</Button>
 | 
	
		
			
				|  |  | +															:
 | 
	
		
			
				|  |  | +															<ReactToPrint
 | 
	
		
			
				|  |  | +																trigger={() => {
 | 
	
		
			
				|  |  | +																	return <span>
 | 
	
		
			
				|  |  | +																		<Button color className="btn-labeled-4 mt-0">
 | 
	
		
			
				|  |  | +																			<h5 className="p-0 mt-2"><em className="fas fa-download mr-2" />Print dan Download</h5>
 | 
	
		
			
				|  |  | +																		</Button>
 | 
	
		
			
				|  |  | +																	</span>
 | 
	
		
			
				|  |  | +																}}
 | 
	
		
			
				|  |  | +																content={() => this.componentRef}
 | 
	
		
			
				|  |  | +															/>
 | 
	
		
			
				|  |  | +														}
 | 
	
		
			
				|  |  |  														<div style={{ display: "none" }}>
 | 
	
		
			
				|  |  |  															<ComponentToPrint ref={el => (this.componentRef = el)} query={this.props.query} handleAutoSave={this.handleAutoSave} dataPelanggaran={this.state.dataPelanggaran} setDataSuratBA={this.setDataSuratBA} dataLaporan={pelaporan} dataSuratBA={dataSuratBA} />
 | 
	
		
			
				|  |  |  														</div>
 |