|
@@ -7,13 +7,37 @@ import { Row, Col, FormGroup, Input } from "reactstrap";
|
|
|
import { ToastContainer, toast } from "react-toastify";
|
|
import { ToastContainer, toast } from "react-toastify";
|
|
|
import { Formik, Form, Field, ErrorMessage } from "formik";
|
|
import { Formik, Form, Field, ErrorMessage } from "formik";
|
|
|
import * as Yup from "yup";
|
|
import * as Yup from "yup";
|
|
|
|
|
+import { getOneLaporan } from "@/actions/pelaporan";
|
|
|
|
|
|
|
|
const selectInstanceId = 1;
|
|
const selectInstanceId = 1;
|
|
|
|
|
+const checkIfFilesAreTooBig = (files) => {
|
|
|
|
|
+ let valid = true;
|
|
|
|
|
+ if (files) {
|
|
|
|
|
+ files.map((file) => {
|
|
|
|
|
+ if (file.size > 15 * 1024 * 1024) {
|
|
|
|
|
+ valid = false;
|
|
|
|
|
+ }
|
|
|
|
|
+ });
|
|
|
|
|
+ }
|
|
|
|
|
+ return valid;
|
|
|
|
|
+};
|
|
|
|
|
+
|
|
|
|
|
+const checkIfFilesAreCorrectType = (files) => {
|
|
|
|
|
+ let valid = true;
|
|
|
|
|
+ if (files) {
|
|
|
|
|
+ files.map((file) => {
|
|
|
|
|
+ if (!["image/jpeg", "image/png"].includes(file.type)) {
|
|
|
|
|
+ valid = false;
|
|
|
|
|
+ }
|
|
|
|
|
+ });
|
|
|
|
|
+ }
|
|
|
|
|
+ return valid;
|
|
|
|
|
+};
|
|
|
|
|
|
|
|
const evaluasiSchema = Yup.object().shape({
|
|
const evaluasiSchema = Yup.object().shape({
|
|
|
tanggal: Yup.date().required("Required"),
|
|
tanggal: Yup.date().required("Required"),
|
|
|
judul: Yup.string().min(3).max(150).required("Required"),
|
|
judul: Yup.string().min(3).max(150).required("Required"),
|
|
|
- dokumen: Yup.array().min(1).required("Required"),
|
|
|
|
|
|
|
+ dokumen: Yup.array().min(1).required("Required").test("filesize", "Maksimal ukuran dokumen 15mb", checkIfFilesAreTooBig),
|
|
|
});
|
|
});
|
|
|
|
|
|
|
|
let Dropzone = null;
|
|
let Dropzone = null;
|
|
@@ -110,6 +134,8 @@ export default class InputEvaluasi extends Component {
|
|
|
});
|
|
});
|
|
|
this.setState({ files: [] });
|
|
this.setState({ files: [] });
|
|
|
resetForm();
|
|
resetForm();
|
|
|
|
|
+ const pelaporan = await getOneLaporan(token, query.id);
|
|
|
|
|
+ this.props.changePelaporan(pelaporan);
|
|
|
};
|
|
};
|
|
|
|
|
|
|
|
render() {
|
|
render() {
|