From 709f6dc5c557d09262c2440ddfa1a497eb424960 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcin=20Ja=C5=82ocha?= Date: Wed, 27 Nov 2024 21:40:18 +0100 Subject: [PATCH] Fix search character form --- src/pages/character/index.tsx | 42 ++++++++++++++++++++++------------- 1 file changed, 27 insertions(+), 15 deletions(-) diff --git a/src/pages/character/index.tsx b/src/pages/character/index.tsx index 470524a..5024f30 100644 --- a/src/pages/character/index.tsx +++ b/src/pages/character/index.tsx @@ -1,29 +1,41 @@ import Panel from "src/components/Panel"; import { useRouter } from "next/router"; -import FormWrapper, { FormField } from "src/components/FormWrapper"; -import { searchCharacterSchema } from "src/schemas/SearchCharacter"; -import { FormButton } from "../community/guilds"; +import { SubmitHandler, useForm } from "react-hook-form"; +import { z } from "zod"; +import { zodResolver } from "@hookform/resolvers/zod"; +import { Container, VStack } from "@chakra-ui/react"; +import TextInput from "@component/TextInput"; +import { FormField } from "@component/FormField"; -const fields: FormField[] = [ - { - type: "text", - name: "name", - label: { text: "Character Name" }, - }, -]; - -const buttons: FormButton[] = [{ type: "submit", btnType: "primary", value: "Submit" }]; +const schema = z.object({ + name: z.string(), +}); export default function Character() { + const { + register, + handleSubmit, + formState: { errors }, + } = useForm>({ + resolver: zodResolver(schema), + }); const router = useRouter(); - const onSubmit = async (values: any) => { - router.push(`/character/${values.name}`); + const onSubmit: SubmitHandler> = async ({ name }) => { + router.push(`/character/${name}`); }; return ( - +
+ + + + + + + +
); }