|
|
@@ -46,14 +46,14 @@ const laporanSchema = Yup.object().shape({
|
|
|
no_laporan: Yup.string().required("Harap Diisi"),
|
|
|
no_hp: Yup.number().required("Harap Diisi"),
|
|
|
nama: Yup.string().notRequired(),
|
|
|
- setuju: Yup.boolean().isTrue(),
|
|
|
+ setuju: Yup.boolean().isTrue("Harap diceklis"),
|
|
|
alamat: Yup.string().min(3).max(200).notRequired(),
|
|
|
keterangan: Yup.string().min(3).max(200).required("Harap Diisi"),
|
|
|
email: Yup.string().email().notRequired(),
|
|
|
pelanggaran_id: Yup.array().min(1).required("Harap Diisi"),
|
|
|
pt_id: Yup.string().required("Harap Diisi"),
|
|
|
foto: Yup.array().notRequired().test("filesize", "Maksimal ukuran foto 15mb", checkIfFilesAreTooBig).test("type", "harus jpeg/png", checkIfFilesAreCorrectType),
|
|
|
- dokumen: Yup.array().nullable().notRequired().test("filesize", "Maksimal ukuran dokumen 15mb", checkIfFilesAreTooBig),
|
|
|
+ dokumen: Yup.array().min(1, "Minimal terdapat 1 dokumen").required().test("filesize", "Maksimal ukuran dokumen 15mb", checkIfFilesAreTooBig),
|
|
|
is_private: Yup.boolean().notRequired(),
|
|
|
});
|
|
|
|
|
|
@@ -170,7 +170,7 @@ class App extends Component {
|
|
|
}
|
|
|
};
|
|
|
|
|
|
- createLaporan = async (token, kode = "", toastid = null) => {
|
|
|
+ createLaporan = async (token, kode = "") => {
|
|
|
const data = this.state.data;
|
|
|
const formdata = new FormData();
|
|
|
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);
|
|
|
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" });
|
|
|
} 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();
|
|
|
Router.push("/laporan/new");
|
|
|
}
|
|
|
@@ -256,17 +255,11 @@ class App extends Component {
|
|
|
}}
|
|
|
validationSchema={laporanSchema}
|
|
|
onSubmit={async (data) => {
|
|
|
+ this.toggleModal();
|
|
|
this.setState({ data, no_hp: data.no_hp });
|
|
|
- const toastid = toast.loading("Please wait...");
|
|
|
const user = await this.createUser(data);
|
|
|
const token = user.data.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">
|
|
|
@@ -282,7 +275,9 @@ class App extends Component {
|
|
|
</div>
|
|
|
</FormGroup>
|
|
|
<FormGroup row>
|
|
|
- <label className="col-md-2 col-form-label">Nomor Aktif</label>
|
|
|
+ <label className="col-md-2 col-form-label">
|
|
|
+ Nomor Aktif<span className="text-warning">*</span>
|
|
|
+ </label>
|
|
|
<div className="col-md-10">
|
|
|
<Field name="no_hp">{({ field, form }) => <Input type="tel" {...field} />}</Field>
|
|
|
<ErrorMessage name="no_hp" component="div" className="form-text text-danger" />
|
|
|
@@ -313,7 +308,7 @@ class App extends Component {
|
|
|
<label>
|
|
|
<Field name="is_private">{({ field }) => <Input type="checkbox" {...field} />}</Field>
|
|
|
<span className="fa fa-check"></span>
|
|
|
- <text>*</text>Klik jika ingin merahasiakan identitas anda
|
|
|
+ <text>Klik jika ingin merahasiakan identitas anda</text>
|
|
|
</label>
|
|
|
</div>
|
|
|
</div>
|
|
|
@@ -330,7 +325,9 @@ class App extends Component {
|
|
|
</div>
|
|
|
</FormGroup>
|
|
|
<FormGroup row>
|
|
|
- <label className="col-md-2 col-form-label">Perguruan Tinggi yang Dilaporkan</label>
|
|
|
+ <label className="col-md-2 col-form-label">
|
|
|
+ Perguruan Tinggi yang Dilaporkan<span className="text-warning">*</span>
|
|
|
+ </label>
|
|
|
<div className="col-md-10">
|
|
|
<Field name="pt_id">
|
|
|
{({ field, form }) => (
|
|
|
@@ -350,7 +347,9 @@ class App extends Component {
|
|
|
</div>
|
|
|
</FormGroup>
|
|
|
<FormGroup row>
|
|
|
- <label className="col-md-2 col-form-label">Jenis Pelanggaran</label>
|
|
|
+ <label className="col-md-2 col-form-label">
|
|
|
+ Jenis Pelanggaran<span className="text-warning">*</span>
|
|
|
+ </label>
|
|
|
<div className="col-md-10">
|
|
|
<Field name="pelanggaran_id">
|
|
|
{({ field, form }) => (
|
|
|
@@ -374,16 +373,21 @@ class App extends Component {
|
|
|
</div>
|
|
|
</FormGroup>
|
|
|
<FormGroup row>
|
|
|
- <label className="col-md-2 col-form-label">Keterangan Laporan</label>
|
|
|
+ <label className="col-md-2 col-form-label">
|
|
|
+ Keterangan Laporan<span className="text-warning">*</span>
|
|
|
+ </label>
|
|
|
<div className="col-md-10">
|
|
|
<Field name="keterangan">{({ field }) => <Input type="textarea" {...field} />}</Field>
|
|
|
<ErrorMessage name="keterangan" component="div" className="form-text text-danger" />
|
|
|
</div>
|
|
|
</FormGroup>
|
|
|
<FormGroup row>
|
|
|
- <label className="col-md-2 col-form-label">File Pendukung</label>
|
|
|
+ <label className="col-md-2 col-form-label">
|
|
|
+ File Pendukung<span className="text-warning">*</span>
|
|
|
+ </label>
|
|
|
<div className="col-md-10">
|
|
|
<Field name="dokumen">{({ field, form }) => <Input type="file" multiple onChange={(e) => form.setFieldValue(field.name, Array.from(e.currentTarget.files))} />}</Field>
|
|
|
+ <p>Ukuran maksimal tiap-tiap dokumen adalah 15mb</p>
|
|
|
<ErrorMessage name="dokumen" component="div" className="form-text text-danger" />
|
|
|
</div>
|
|
|
</FormGroup>
|
|
|
@@ -393,7 +397,7 @@ class App extends Component {
|
|
|
<label>
|
|
|
<Field name="setuju">{({ field }) => <Input type="checkbox" {...field} />}</Field>
|
|
|
<span className="fa fa-check"></span>
|
|
|
- <text>*</text>Klik jika data yang anda laporkan sudah benar
|
|
|
+ <text>Klik jika data yang anda laporkan sudah benar</text>
|
|
|
<ErrorMessage name="setuju" component="div" className="form-text text-danger" />
|
|
|
</label>
|
|
|
</div>
|
|
|
@@ -428,11 +432,10 @@ class App extends Component {
|
|
|
<Button
|
|
|
color="info"
|
|
|
onClick={async () => {
|
|
|
- this.toggleModal();
|
|
|
- this.setState({ error: "", kode: "" });
|
|
|
+ await this.createLaporan(this.state.token);
|
|
|
}}
|
|
|
>
|
|
|
- Kembali
|
|
|
+ Buat Laporan Tanpa Kode Verifikasi
|
|
|
</Button>
|
|
|
<Button
|
|
|
color="primary"
|