Fakultas Ilmu Komputer UI

Commit d21d625c authored by FadhilP's avatar FadhilP
Browse files

[REFACTOR] Add error alert above submit button

parent dc8ce3bf
......@@ -14,7 +14,7 @@ import moment from "moment";
import DateTime from 'react-datetime';
import "react-datetime/css/react-datetime.css";
const FormBatch = ({ onSubmit, initialData = null }) => {
const FormBatch = ({ onSubmit, initialData = null, error }) => {
const { register, handleSubmit, errors } = useForm({
defaultValues: initialData !== null ? {
batch_name: initialData["batch_name"],
......@@ -111,6 +111,15 @@ const FormBatch = ({ onSubmit, initialData = null }) => {
<LabelInput htmlFor="shipping_cost">Ongkos Kirim</LabelInput>
<InputForm type="text" name="shipping_cost" ref={register} />
</RowInput>
<RowInput>
{error && (
<ErrorDiv>
<button className="btn btn-danger">
Error !, Data tidak dapat disimpan
</button>
</ErrorDiv>
)}
</RowInput>
<RowInput>
<InputSubmitForm type="submit" data-testid="submit-batch" />
</RowInput>
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment