Fakultas Ilmu Komputer UI

Commit fb670f8d authored by FadhilP's avatar FadhilP
Browse files

[REFACTOR] Add error alert above submit button

parent d21d625c
......@@ -9,7 +9,7 @@ import {
} from "../../component/html/html";
import { css } from "@emotion/core";
const FormKategori = ({ onSubmit, initialData = null }) => {
const FormKategori = ({ onSubmit, initialData = null, error }) => {
const { register, handleSubmit, errors } = useForm({
defaultValues: initialData !== null ? { name: initialData["name"] } : {},
});
......@@ -53,6 +53,15 @@ const FormKategori = ({ onSubmit, initialData = null }) => {
<LabelInput htmlFor="gambar">Foto kategori </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-category" />
</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