Fakultas Ilmu Komputer UI

Commit 78a12694 authored by FadhilP's avatar FadhilP
Browse files

[REFACTOR] Add error alert above submit button

parent 1d38ebaa
......@@ -11,7 +11,7 @@ import {
} from "../../component/html/html";
import { css } from "@emotion/core";
const FormSubkategori = ({ onSubmit, initialData = null }) => {
const FormSubkategori = ({ onSubmit, initialData = null, error }) => {
const { register, handleSubmit, errors } = useForm({
defaultValues:
initialData !== null
......@@ -93,6 +93,15 @@ const FormSubkategori = ({ onSubmit, initialData = null }) => {
<LabelInput htmlFor="gambar">Foto subkategori </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-subcategory" />
</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