|
@@ -170,7 +170,7 @@ class App extends Component {
|
|
|
}
|
|
}
|
|
|
};
|
|
};
|
|
|
|
|
|
|
|
- createLaporan = async (token, kode = "", toastid = null) => {
|
|
|
|
|
|
|
+ createLaporan = async (token, kode = "") => {
|
|
|
const data = this.state.data;
|
|
const data = this.state.data;
|
|
|
const formdata = new FormData();
|
|
const formdata = new FormData();
|
|
|
formdata.append("pt_id", data.pt_id);
|
|
formdata.append("pt_id", data.pt_id);
|
|
@@ -185,14 +185,13 @@ class App extends Component {
|
|
|
});
|
|
});
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- let toastid2 = toastid;
|
|
|
|
|
- if (!toastid) toastid2 = toast.loading("Please wait...");
|
|
|
|
|
|
|
+ const toastid = toast.loading("Please wait...");
|
|
|
const success = await createLaporanPublic(token, formdata);
|
|
const success = await createLaporanPublic(token, formdata);
|
|
|
if (!success) {
|
|
if (!success) {
|
|
|
- toast.update(toastid2, { 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 });
|
|
|
this.setState({ error: "Kode verifikasi tidak valid" });
|
|
this.setState({ error: "Kode verifikasi tidak valid" });
|
|
|
} else {
|
|
} else {
|
|
|
- toast.update(toastid2, { 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 });
|
|
|
this.toggleModal();
|
|
this.toggleModal();
|
|
|
Router.push("/laporan/new");
|
|
Router.push("/laporan/new");
|
|
|
}
|
|
}
|
|
@@ -256,17 +255,11 @@ class App extends Component {
|
|
|
}}
|
|
}}
|
|
|
validationSchema={laporanSchema}
|
|
validationSchema={laporanSchema}
|
|
|
onSubmit={async (data) => {
|
|
onSubmit={async (data) => {
|
|
|
|
|
+ this.toggleModal();
|
|
|
this.setState({ data, no_hp: data.no_hp });
|
|
this.setState({ data, no_hp: data.no_hp });
|
|
|
- const toastid = toast.loading("Please wait...");
|
|
|
|
|
const user = await this.createUser(data);
|
|
const user = await this.createUser(data);
|
|
|
const token = user.data.token;
|
|
const token = user.data.token;
|
|
|
this.setState({ user, token });
|
|
this.setState({ user, token });
|
|
|
- if (user.data.no_hp_aktif) {
|
|
|
|
|
- toast.update(toastid, { render: "All is good", type: "success", isLoading: false, autoClose: true, closeButton: true });
|
|
|
|
|
- this.toggleModal();
|
|
|
|
|
- } else {
|
|
|
|
|
- await this.createLaporan(token, null, toastid);
|
|
|
|
|
- }
|
|
|
|
|
}}
|
|
}}
|
|
|
>
|
|
>
|
|
|
<Form className="form-horizontal">
|
|
<Form className="form-horizontal">
|
|
@@ -439,11 +432,10 @@ class App extends Component {
|
|
|
<Button
|
|
<Button
|
|
|
color="info"
|
|
color="info"
|
|
|
onClick={async () => {
|
|
onClick={async () => {
|
|
|
- this.toggleModal();
|
|
|
|
|
- this.setState({ error: "", kode: "" });
|
|
|
|
|
|
|
+ await this.createLaporan(this.state.token);
|
|
|
}}
|
|
}}
|
|
|
>
|
|
>
|
|
|
- Kembali
|
|
|
|
|
|
|
+ Buat Laporan Tanpa Kode Verifikasi
|
|
|
</Button>
|
|
</Button>
|
|
|
<Button
|
|
<Button
|
|
|
color="primary"
|
|
color="primary"
|