|
|
@@ -24,6 +24,7 @@ import 'moment/locale/id';
|
|
|
import { getCsrf } from "../../actions/security";
|
|
|
import { createLog } from "../../actions/log";
|
|
|
moment.locale('id')
|
|
|
+import Swal from "sweetalert2";
|
|
|
|
|
|
|
|
|
const status = [
|
|
|
@@ -135,47 +136,43 @@ class Calendar extends Component {
|
|
|
}
|
|
|
|
|
|
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",
|
|
|
- error: "Error",
|
|
|
- }
|
|
|
+ if (this.props.user.role.id === 2024) {
|
|
|
+ Swal.fire({
|
|
|
+ icon: 'error',
|
|
|
+ title: 'Oops...',
|
|
|
+ text: 'Maaf anda tidak memiliki akses untuk menyelesaikan proses ini.',
|
|
|
+ confirmButtonColor: "#3e3a8e",
|
|
|
+ confirmButtonText: 'Kembali'
|
|
|
+ // footer: '<a href="">Why do I have this issue?</a>'
|
|
|
+ })
|
|
|
+ } else {
|
|
|
+ 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",
|
|
|
+ error: "Error",
|
|
|
+ }
|
|
|
+
|
|
|
+ );
|
|
|
+ Router.push("/app/penjadwalan");
|
|
|
+ const dataLaporan = await getPelaporan(token, { jadwal: true });
|
|
|
+ this.setState({ dataLaporan });
|
|
|
+ this.getDataEvent();
|
|
|
+ }
|
|
|
|
|
|
- );
|
|
|
- // 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 });
|
|
|
- this.getDataEvent();
|
|
|
};
|
|
|
|
|
|
defaultStatus = async () => {
|
|
|
@@ -201,35 +198,47 @@ class Calendar extends Component {
|
|
|
}
|
|
|
|
|
|
handleSimpan = async (value) => {
|
|
|
- const getToken = await getCsrf();
|
|
|
- const _csrf = getToken.token;
|
|
|
- const { token, query } = this.props;
|
|
|
- const { id } = query;
|
|
|
- let update = null;
|
|
|
- if (value.status.value === this.getStatus()[1].value || value.status.value === this.getStatus()[2].value) {
|
|
|
- const toastid = toast.loading("Please wait...");
|
|
|
- const data = { keterangan: value.keterangan };
|
|
|
- if (value.status.value === this.getStatus()[1].value) {
|
|
|
- data.change_role = "true";
|
|
|
- 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, _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()
|
|
|
+ if (this.props.user.role.id === 2024) {
|
|
|
+ Swal.fire({
|
|
|
+ icon: 'error',
|
|
|
+ title: 'Oops...',
|
|
|
+ text: 'Maaf anda tidak memiliki akses untuk menyelesaikan proses ini.',
|
|
|
+ confirmButtonColor: "#3e3a8e",
|
|
|
+ confirmButtonText: 'Kembali'
|
|
|
+ // footer: '<a href="">Why do I have this issue?</a>'
|
|
|
+ })
|
|
|
+ } else {
|
|
|
+ const getToken = await getCsrf();
|
|
|
+ const _csrf = getToken.token;
|
|
|
+ const { token, query } = this.props;
|
|
|
+ const { id } = query;
|
|
|
+ let update = null;
|
|
|
+ if (value.status.value === this.getStatus()[1].value || value.status.value === this.getStatus()[2].value) {
|
|
|
+ const toastid = toast.loading("Please wait...");
|
|
|
+ const data = { keterangan: value.keterangan };
|
|
|
+ if (value.status.value === this.getStatus()[1].value) {
|
|
|
+ data.change_role = "true";
|
|
|
+ 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, _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");
|
|
|
}
|
|
|
Router.push("/app/penjadwalan");
|
|
|
}
|
|
|
- Router.push("/app/penjadwalan");
|
|
|
+
|
|
|
};
|
|
|
|
|
|
render() {
|