diff --git a/frontend/src/components/AuthorForm.tsx b/frontend/src/components/AuthorForm.tsx deleted file mode 100644 index b2161b9..0000000 --- a/frontend/src/components/AuthorForm.tsx +++ /dev/null @@ -1,63 +0,0 @@ -import React, { useState } from "react"; -import Input from "./Form/Input"; -import { SubmitHandler, useForm } from "react-hook-form"; -import { yupResolver } from "@hookform/resolvers/yup"; -import AuthorSchema from "./Schemas/AuthorSchema"; -import Form, { FormMessage } from "./Form/Form"; -import ManagementService from "services/managementService"; -import { AuthorFormCreate } from "types/author"; - -const managementService = new ManagementService(); - -const AuthorForm: React.FC = () => { - const messageInitialState = { value: "", isError: false }; - const [isLoading, setIsLoading] = useState(false); - const [message, setMessage] = useState(messageInitialState); - const { - register, - handleSubmit, - reset, - - formState: { errors }, - } = useForm({ resolver: yupResolver(AuthorSchema) }); - - const onSubmit: SubmitHandler = async (data: AuthorFormCreate) => { - setIsLoading(true); - const author = await managementService.createAuthor(data); - console.log(author, author === undefined); - setMessage({ - value: author ? "Author created with success" : "It wansn't possible to create the author, try again", - isError: author === undefined, - }); - setIsLoading(false); - // onReset() - }; - - const onReset = () => { - setMessage(messageInitialState); - reset(undefined); - }; - - return ( -
- <> - - - - - - - - -
- ); -}; - -export default AuthorForm;