|  | @@ -11,7 +11,6 @@ import timeGridPlugin from "@fullcalendar/timegrid";
 | 
	
		
			
				|  |  |  import interactionPlugin, { Draggable } from "@fullcalendar/interaction";
 | 
	
		
			
				|  |  |  import listPlugin from "@fullcalendar/list";
 | 
	
		
			
				|  |  |  import bootstrapPlugin from "@fullcalendar/bootstrap";
 | 
	
		
			
				|  |  | -import events from "./calendar.events";
 | 
	
		
			
				|  |  |  import Select from "react-select";
 | 
	
		
			
				|  |  |  import moment from "moment";
 | 
	
		
			
				|  |  |  import { connect } from "react-redux";
 | 
	
	
		
			
				|  | @@ -59,6 +58,7 @@ class Calendar extends Component {
 | 
	
		
			
				|  |  |  			dataEvent: [],
 | 
	
		
			
				|  |  |  			laporan: {},
 | 
	
		
			
				|  |  |  			selectedOption: null,
 | 
	
		
			
				|  |  | +			color: "",
 | 
	
		
			
				|  |  |  		};
 | 
	
		
			
				|  |  |  	}
 | 
	
		
			
				|  |  |  
 | 
	
	
		
			
				|  | @@ -66,18 +66,19 @@ class Calendar extends Component {
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |  	async componentDidMount() {
 | 
	
		
			
				|  |  |  		const { token, query } = this.props;
 | 
	
		
			
				|  |  | -
 | 
	
		
			
				|  |  |  		const laporan = await getOneLaporan(token, query.id);
 | 
	
		
			
				|  |  |  		const dataLaporan = await getPelaporan(token, { jadwal: true });
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  |  		this.setState({ dataLaporan });
 | 
	
		
			
				|  |  |  		this.getDataEvent();
 | 
	
		
			
				|  |  |  		this.defaultStatus();
 | 
	
		
			
				|  |  |  		this.setState({ laporan });
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  |  		let color = "#" + Math.floor(Math.random() * 16777215).toString(16);
 | 
	
		
			
				|  |  |  		if (laporan.data.jadwal) {
 | 
	
		
			
				|  |  |  			color = laporan.data.jadwal.warna;
 | 
	
		
			
				|  |  |  		}
 | 
	
		
			
				|  |  | -		this.setState({ externalEvents: [{ id: query.id, color, name: `Jadwal Pemeriksaan - No.Laporan : ${laporan.data.no_laporan} - ${laporan.data.pt.nama}`, allDay: true }] });
 | 
	
		
			
				|  |  | +		this.setState({ color });
 | 
	
		
			
				|  |  |  	}
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |  	componentShouldUpdate(nextProps, nextState) {
 | 
	
	
		
			
				|  | @@ -117,22 +118,21 @@ class Calendar extends Component {
 | 
	
		
			
				|  |  |  	handleEventCalendar = async (data) => {
 | 
	
		
			
				|  |  |  		const { query, token } = this.props;
 | 
	
		
			
				|  |  |  		const { id } = query;
 | 
	
		
			
				|  |  | -		const { laporan } = this.state;
 | 
	
		
			
				|  |  | -		const warna = "#" + Math.floor(Math.random() * 16777215).toString(16);
 | 
	
		
			
				|  |  | -		const d = {
 | 
	
		
			
				|  |  | -			judul: data.judul,
 | 
	
		
			
				|  |  | -			dari_tanggal: data.dari_tanggal,
 | 
	
		
			
				|  |  | -			sampai_tanggal: data.sampai_tanggal,
 | 
	
		
			
				|  |  | -			warna,
 | 
	
		
			
				|  |  | -		};
 | 
	
		
			
				|  |  | -		if (laporan.data.jadwal) {
 | 
	
		
			
				|  |  | -			d.warna = laporan.data.jadwal.warna;
 | 
	
		
			
				|  |  | -		}
 | 
	
		
			
				|  |  | -		await toast.promise(updateJadwal(token, id, d), {
 | 
	
		
			
				|  |  | -			pending: "Loading",
 | 
	
		
			
				|  |  | -			success: "Success",
 | 
	
		
			
				|  |  | -			error: "Error",
 | 
	
		
			
				|  |  | -		});
 | 
	
		
			
				|  |  | +		const { color } = this.state;
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +		await toast.promise(
 | 
	
		
			
				|  |  | +			updateJadwal(token, id, {
 | 
	
		
			
				|  |  | +				judul: data.judul,
 | 
	
		
			
				|  |  | +				dari_tanggal: data.dari_tanggal,
 | 
	
		
			
				|  |  | +				sampai_tanggal: data.sampai_tanggal,
 | 
	
		
			
				|  |  | +				warna: color,
 | 
	
		
			
				|  |  | +			}),
 | 
	
		
			
				|  |  | +			{
 | 
	
		
			
				|  |  | +				pending: "Loading",
 | 
	
		
			
				|  |  | +				success: "Success",
 | 
	
		
			
				|  |  | +				error: "Error",
 | 
	
		
			
				|  |  | +			}
 | 
	
		
			
				|  |  | +		);
 | 
	
		
			
				|  |  |  		const dataLaporan = await getPelaporan(token, { jadwal: true });
 | 
	
		
			
				|  |  |  		this.setState({ dataLaporan });
 | 
	
		
			
				|  |  |  		this.getDataEvent();
 | 
	
	
		
			
				|  | @@ -149,17 +149,17 @@ class Calendar extends Component {
 | 
	
		
			
				|  |  |  		const toastid = toast.loading("Please wait...");
 | 
	
		
			
				|  |  |  		try {
 | 
	
		
			
				|  |  |  			const { selectedOption } = this.state;
 | 
	
		
			
				|  |  | -			const { user, token, query } = this.props;
 | 
	
		
			
				|  |  | +			const { token, query } = this.props;
 | 
	
		
			
				|  |  |  			const { id } = query;
 | 
	
		
			
				|  |  |  			this.setState({ selectedOption });
 | 
	
		
			
				|  |  |  			if (selectedOption.value === this.getStatus()[1].value) {
 | 
	
		
			
				|  |  | -				await updateLaporan(token, id, { role_data: user.role.id === 2020 ? "lldikti" : "dikti" });
 | 
	
		
			
				|  |  | -				Router.push("/app/penjadwalan");
 | 
	
		
			
				|  |  | +				await updateLaporan(token, id, { change_role: "true" });
 | 
	
		
			
				|  |  |  			}
 | 
	
		
			
				|  |  |  			if (selectedOption.value === this.getStatus()[2].value) {
 | 
	
		
			
				|  |  |  				await updateLaporan(token, id, { aktif: "false" });
 | 
	
		
			
				|  |  | -				Router.push("/app/penjadwalan");
 | 
	
		
			
				|  |  |  			}
 | 
	
		
			
				|  |  | +			Router.push("/app/penjadwalan");
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  |  			toast.update(toastid, { render: "All is good", type: "success", isLoading: false, autoClose: true, closeButton: true });
 | 
	
		
			
				|  |  |  		} catch (error) {
 | 
	
		
			
				|  |  |  			toast.update(toastid, { render: "All is not good", type: "error", isLoading: false, autoClose: true, closeButton: true });
 | 
	
	
		
			
				|  | @@ -168,7 +168,6 @@ class Calendar extends Component {
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |  	render() {
 | 
	
		
			
				|  |  |  		const { externalEvents, laporan, selectedOption, selectedEvent } = this.state;
 | 
	
		
			
				|  |  | -		console.log(this.state.dataLaporan);
 | 
	
		
			
				|  |  |  		return (
 | 
	
		
			
				|  |  |  			<ContentWrapper>
 | 
	
		
			
				|  |  |  				<div className="content-heading">
 | 
	
	
		
			
				|  | @@ -225,8 +224,8 @@ class Calendar extends Component {
 | 
	
		
			
				|  |  |  														enableReinitialize={true}
 | 
	
		
			
				|  |  |  														initialValues={{
 | 
	
		
			
				|  |  |  															judul: laporan.data?.jadwal?.judul || "",
 | 
	
		
			
				|  |  | -															dari_tanggal: moment(laporan.data?.jadwal?.dari_tanggal) || "",
 | 
	
		
			
				|  |  | -															sampai_tanggal: moment(laporan.data?.jadwal?.sampai_tanggal) || "",
 | 
	
		
			
				|  |  | +															dari_tanggal: laporan.data?.jadwal?.dari_tanggal ? moment(laporan.data.jadwal.dari_tanggal) : "",
 | 
	
		
			
				|  |  | +															sampai_tanggal: laporan.data?.jadwal?.sampai_tanggal ? moment(laporan.data.jadwal.sampai_tanggal) : "",
 | 
	
		
			
				|  |  |  														}}
 | 
	
		
			
				|  |  |  														validationSchema={jadwalSchema}
 | 
	
		
			
				|  |  |  														onSubmit={this.handleEventCalendar}
 | 
	
	
		
			
				|  | @@ -270,6 +269,12 @@ class Calendar extends Component {
 | 
	
		
			
				|  |  |  																	</Field>
 | 
	
		
			
				|  |  |  																	<ErrorMessage name="sampai_tanggal" component="div" className="form-text text-danger" />
 | 
	
		
			
				|  |  |  																</FormGroup>
 | 
	
		
			
				|  |  | +																<FormGroup>
 | 
	
		
			
				|  |  | +																	<label className="col-form-label">Warna</label>
 | 
	
		
			
				|  |  | +																	<div className="badge d-block" style={{ backgroundColor: this.state.color, color: "white" }}>
 | 
	
		
			
				|  |  | +																		{this.state.color}
 | 
	
		
			
				|  |  | +																	</div>
 | 
	
		
			
				|  |  | +																</FormGroup>
 | 
	
		
			
				|  |  |  																<FormGroup row>
 | 
	
		
			
				|  |  |  																	<div className="col-xl-12">
 | 
	
		
			
				|  |  |  																		<Button color="primary" block type="submit">
 |