Quellcode durchsuchen

swal (pemantauan,pelaporan)

andifebri vor 3 Jahren
Ursprung
Commit
58352e3ddb
2 geänderte Dateien mit 16 neuen und 8 gelöschten Zeilen
  1. 10 5
      pages/laporan/new/index.js
  2. 6 3
      pages/pemantauan.js

+ 10 - 5
pages/laporan/new/index.js

@@ -154,6 +154,7 @@ class App extends Component {
 		formdata.append("keterangan", data.keterangan);
 		formdata.append("pelanggaran_id", data.pelanggaran_id.join(","));
 		formdata.append("foto", data.foto[0]);
+
 		if (data.dokumen.length > 0) {
 			Array.from(data.dokumen).forEach((e) => {
 				formdata.append("dokumen", e);
@@ -163,9 +164,11 @@ class App extends Component {
 		const toastid = toast.loading("Please wait...");
 		const success = await createLaporanPublic(formdata);
 		if (!success) {
-			toast.update(toastid, { render: "All is not good", type: "error", isLoading: false, autoClose: true, closeButton: true });
+			// toast.update(toastid, { render: "All is not good", type: "error", isLoading: false, autoClose: true, closeButton: true });
+			swal("Data tidak berhasil dikirim", " ", "error");
 		} else {
-			toast.update(toastid, { render: "All is good", type: "success", isLoading: false, autoClose: true, closeButton: true });
+			// toast.update(toastid, { render: "All is good", type: "success", isLoading: false, autoClose: true, closeButton: true });
+			swal("Data berhasil dikirim", " ", "success");
 			Router.push("/laporan/new");
 		}
 	};
@@ -185,13 +188,15 @@ class App extends Component {
 			});
 		}
 
-		const toastid = toast.loading("Please wait...");
+		// const toastid = toast.loading("Please wait...");
 		const success = await createLaporanPublic(token, formdata);
 		if (!success) {
-			toast.update(toastid, { render: "All is not good", type: "error", isLoading: false, autoClose: true, closeButton: true });
+			// toast.update(toastid, { render: "All is not good", type: "error", isLoading: false, autoClose: true, closeButton: true });
+			swal("Data tidak berhasil dikirim", "Kode verifikasi tidak valid", "error");
 			this.setState({ error: "Kode verifikasi tidak valid" });
 		} else {
-			toast.update(toastid, { render: "All is good", type: "success", isLoading: false, autoClose: true, closeButton: true });
+			// toast.update(toastid, { render: "All is good", type: "success", isLoading: false, autoClose: true, closeButton: true });
+			swal("Data berhasil dikirim", " ", "success");
 			this.toggleModal();
 			Router.push("/laporan/new");
 		}

+ 6 - 3
pages/pemantauan.js

@@ -10,6 +10,7 @@ import Timeline from "@/components/Main/Timeline";
 import { Formik, Form, Field, ErrorMessage } from "formik";
 import * as Yup from "yup";
 import { ToastContainer, toast } from "react-toastify";
+import Swal from '@/components/Common/Swal';
 
 import "react-toastify/dist/ReactToastify.css";
 
@@ -55,14 +56,16 @@ class App extends Component {
 
 	handleLihatPemantaun = async (data) => {
 		const { no_hp, no_laporan } = data;
-		const toastid = toast.loading("Please wait...");
+		// const toastid = toast.loading("Please wait...");
 		const log = await getLogPublic({ no_hp, no_laporan });
 		if (log.data) {
 			this.setState({ laporan: log.data.laporan, log: log.data.pemantauan });
-			toast.update(toastid, { render: "Berhasil mendapatkan data Pemantauan", type: "success", isLoading: false, autoClose: true, closeButton: true });
+			// swal.update(toastid, { render: "Berhasil mendapatkan data Pemantauan", type: "success", isLoading: false, autoClose: true, closeButton: true });
+			swal("Data ditemukan", " ", "success");
 		} else {
 			this.setState({ laporan: null, log: null });
-			toast.update(toastid, { render: "Pemantauan tidak ada", type: "error", isLoading: false, autoClose: true, closeButton: true });
+			// swal.update(toastid, { render: "Pemantauan tidak ada", type: "error", isLoading: false, autoClose: true, closeButton: true });
+			swal("Data tidak ditemukan", " ", "error");
 		}
 	};