Explorar o código

swal kirim laporan

andifebri %!s(int64=3) %!d(string=hai) anos
pai
achega
3d5ed31b43
Modificáronse 1 ficheiros con 21 adicións e 7 borrados
  1. 21 7
      pages/laporan/new/index.js

+ 21 - 7
pages/laporan/new/index.js

@@ -14,7 +14,7 @@ import { createPublicUser } from "@/actions/user";
 import { ToastContainer, toast } from "react-toastify";
 import { Formik, Form, Field, ErrorMessage } from "formik";
 import * as Yup from "yup";
-import swal from "sweetalert";
+import swal from "sweetalert2";
 
 import "react-toastify/dist/ReactToastify.css";
 
@@ -164,11 +164,17 @@ 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 });
-			swal("Data tidak berhasil dikirim", " ", "error");
+			swal.fire({
+				title: 'Data tidak berhasil dikirim',
+				icon: 'error',
+				confirmButtonColor: '#6FB9DE',
+			})
 		} else {
-			// toast.update(toastid, { render: "All is good", type: "success", isLoading: false, autoClose: true, closeButton: true });
-			swal("Data berhasil dikirim", " ", "success");
+			swal.fire({
+				title: 'Data berhasil dikirim',
+				icon: 'success',
+				confirmButtonColor: '#6FB9DE',
+			})
 			Router.push("/laporan/new");
 		}
 	};
@@ -192,11 +198,19 @@ class App extends Component {
 		const success = await createLaporanPublic(token, formdata);
 		if (!success) {
 			// 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");
+			swal.fire({
+				title: 'Kode verifikasi salah',
+				icon: 'error',
+				confirmButtonColor: '#6FB9DE',
+			})
 			this.setState({ error: "Kode verifikasi tidak valid" });
 		} else {
 			// toast.update(toastid, { render: "All is good", type: "success", isLoading: false, autoClose: true, closeButton: true });
-			swal("Data berhasil dikirim", " ", "success");
+			swal.fire({
+				title: 'Data berhasil dikirim',
+				icon: 'success',
+				confirmButtonColor: '#6FB9DE',
+			})
 			this.toggleModal();
 			Router.push("/laporan/new");
 		}