|
|
@@ -21,8 +21,11 @@ import { Formik, Form, Field, ErrorMessage } from "formik";
|
|
|
import * as Yup from "yup";
|
|
|
import Datetime from "react-datetime";
|
|
|
import 'moment/locale/id';
|
|
|
+import { getCsrf } from "../../actions/security";
|
|
|
+import { createLog } from "../../actions/log";
|
|
|
moment.locale('id')
|
|
|
|
|
|
+
|
|
|
const status = [
|
|
|
{ value: "Ditindaklanjuti DIKTI", label: "Ditindaklanjuti DIKTI", className: "State-ACT" },
|
|
|
{ value: "Delegasi ke LLDIKTI", label: "Delegasi ke LLDIKTI", className: "State-ACT" },
|
|
|
@@ -122,19 +125,30 @@ class Calendar extends Component {
|
|
|
info.event.setProp("borderColor", styles.borderColor);
|
|
|
this.handleEventCalendar(info);
|
|
|
};
|
|
|
+ logSuccessUpdateJadwal = async () => {
|
|
|
+ const { query, token } = this.props;
|
|
|
+ const { id } = query;
|
|
|
+ const getToken = await getCsrf();
|
|
|
+ const _csrf = getToken.token;
|
|
|
+ await createLog(token, { aktivitas: `Berhasil menetapkan jadwal, id: ${id}`, _csrf: _csrf });
|
|
|
+
|
|
|
+ }
|
|
|
|
|
|
handleEventCalendar = async (data) => {
|
|
|
const { query, token } = this.props;
|
|
|
const { id } = query;
|
|
|
const { color, laporan } = this.state;
|
|
|
-
|
|
|
+ const getToken = await getCsrf();
|
|
|
+ const _csrf = getToken.token;
|
|
|
await toast.promise(
|
|
|
+
|
|
|
updateJadwal(token, id, {
|
|
|
judul: "No.Laporan " + laporan.data.no_laporan + " - " + data.judul,
|
|
|
dari_tanggal: data.dari_tanggal,
|
|
|
sampai_tanggal: data.sampai_tanggal,
|
|
|
warna: color,
|
|
|
- }),
|
|
|
+ }, _csrf),
|
|
|
+
|
|
|
{
|
|
|
pending: "Loading",
|
|
|
success: "Success",
|
|
|
@@ -142,6 +156,22 @@ class Calendar extends Component {
|
|
|
}
|
|
|
|
|
|
);
|
|
|
+ // const toastid = toast.loading("Please wait...");
|
|
|
+ // const added = await updateJadwal(token, id, {
|
|
|
+ // judul: "No.Laporan " + laporan.data.no_laporan + " - " + data.judul,
|
|
|
+ // dari_tanggal: data.dari_tanggal,
|
|
|
+ // sampai_tanggal: data.sampai_tanggal,
|
|
|
+ // warna: color,
|
|
|
+ // }, _csrf)
|
|
|
+ // if (!added) {
|
|
|
+ // toast.update(toastid, { render: "Gagal menetapkan jadwal", type: "error", isLoading: false, autoClose: true, closeButton: true });
|
|
|
+ // } else {
|
|
|
+ // toast.update(toastid, { render: "Berhasil menetapkan jadwal", type: "success", isLoading: false, autoClose: true, closeButton: true });
|
|
|
+
|
|
|
+ // this.logSuccessUpdateJadwal()
|
|
|
+
|
|
|
+
|
|
|
+ // }
|
|
|
Router.push("/app/penjadwalan");
|
|
|
const dataLaporan = await getPelaporan(token, { jadwal: true });
|
|
|
this.setState({ dataLaporan });
|
|
|
@@ -154,8 +184,25 @@ class Calendar extends Component {
|
|
|
};
|
|
|
|
|
|
handleChangeSelect = (selectedOption) => this.setState({ selectedOption });
|
|
|
+ logUpdateLaporanSuccess = async () => {
|
|
|
+ const getToken = await getCsrf();
|
|
|
+ const _csrf = getToken.token;
|
|
|
+ const { token, query } = this.props;
|
|
|
+ const { id } = query;
|
|
|
+ await createLog(token, { aktivitas: `Berhasil mengubah data laporan, id: ${id}`, _csrf: _csrf });
|
|
|
+
|
|
|
+ }
|
|
|
+ logUpdateLaporanError = async () => {
|
|
|
+ const getToken = await getCsrf();
|
|
|
+ const _csrf = getToken.token;
|
|
|
+ const { token, query } = this.props;
|
|
|
+ const { id } = query;
|
|
|
+ await createLog(token, { aktivitas: `Berhasil mengubah data laporan, id: ${id}`, _csrf: _csrf });
|
|
|
+ }
|
|
|
|
|
|
handleSimpan = async (value) => {
|
|
|
+ const getToken = await getCsrf();
|
|
|
+ const _csrf = getToken.token;
|
|
|
const { token, query } = this.props;
|
|
|
const { id } = query;
|
|
|
let update = null;
|
|
|
@@ -164,18 +211,20 @@ class Calendar extends Component {
|
|
|
const data = { keterangan: value.keterangan };
|
|
|
if (value.status.value === this.getStatus()[1].value) {
|
|
|
data.change_role = "true";
|
|
|
- update = await updateLaporan(token, id, data);
|
|
|
+ update = await updateLaporan(token, id, data, _csrf);
|
|
|
Router.push("/app/penjadwalan");
|
|
|
} else if (value.status.value === this.getStatus()[2].value) {
|
|
|
data.aktif = "false";
|
|
|
- update = await updateLaporan(token, id, data);
|
|
|
+ update = await updateLaporan(token, id, data, _csrf);
|
|
|
Router.push("/app/penjadwalan");
|
|
|
}
|
|
|
if (!update) {
|
|
|
toast.update(toastid, { render: "Gagal simpan jadwal", type: "error", isLoading: false, autoClose: true, closeButton: true });
|
|
|
+ this.logUpdateLaporanError()
|
|
|
|
|
|
} else {
|
|
|
toast.update(toastid, { render: "Input jadwal berhasil", type: "success", isLoading: false, autoClose: true, closeButton: true });
|
|
|
+ this.logUpdateLaporanSuccess()
|
|
|
Router.push("/app/penjadwalan");
|
|
|
}
|
|
|
Router.push("/app/penjadwalan");
|