Fakultas Ilmu Komputer UI

Commit fd4c1d56 authored by FadhilP's avatar FadhilP
Browse files

[REFACTOR] Add error alert above submit button

parent fb670f8d
......@@ -12,7 +12,7 @@ import {
} from "../../component/html/html";
import { css } from "@emotion/core";
const FormProduk = ({ onSubmit, initialData = null }) => {
const FormProduk = ({ onSubmit, initialData = null, error }) => {
const { register, handleSubmit, errors, watch } = useForm({
defaultValues:
initialData !== null
......@@ -194,6 +194,15 @@ const FormProduk = ({ onSubmit, initialData = null }) => {
<LabelInput htmlFor="gambar">Foto Produk </LabelInput>
<InputForm type="file" name="image" 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-produk" />
</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