From 2d84fae470f8df61f7567c506c22e3cfb62cb684 Mon Sep 17 00:00:00 2001 From: Alex Holliday Date: Fri, 6 Feb 2026 22:53:41 +0000 Subject: [PATCH] form --- client/src/Hooks/useRegisterForm.ts | 17 ++++ client/src/Pages/Auth/Register/index.tsx | 99 ++++++++++++++++++++---- client/src/Validation/register.ts | 43 ++++++++++ 3 files changed, 143 insertions(+), 16 deletions(-) create mode 100644 client/src/Hooks/useRegisterForm.ts create mode 100644 client/src/Validation/register.ts diff --git a/client/src/Hooks/useRegisterForm.ts b/client/src/Hooks/useRegisterForm.ts new file mode 100644 index 000000000..a043d8ff6 --- /dev/null +++ b/client/src/Hooks/useRegisterForm.ts @@ -0,0 +1,17 @@ +import { registerSchema, type RegisterFormData } from "@/Validation/register"; + +export const useRegisterForm = () => { + const defaults: RegisterFormData = { + firstName: "", + lastName: "", + email: "", + password: "", + confirm: "", + role: ["superadmin"], + }; + + return { + schema: registerSchema, + defaults, + }; +}; diff --git a/client/src/Pages/Auth/Register/index.tsx b/client/src/Pages/Auth/Register/index.tsx index e51eff6ec..e2e4fe802 100644 --- a/client/src/Pages/Auth/Register/index.tsx +++ b/client/src/Pages/Auth/Register/index.tsx @@ -1,34 +1,101 @@ import { BaseAuthPage } from "@/Components/v2/design-elements"; import { Button, TextField } from "@/Components/v2/inputs"; - +import { useForm, Controller } from "react-hook-form"; +import { zodResolver } from "@hookform/resolvers/zod/dist/zod.js"; +import { useRegisterForm } from "@/Hooks/useRegisterForm"; +import type { RegisterFormData } from "@/Validation/register"; import { useTranslation } from "react-i18next"; + const RegisterPage = () => { const { t } = useTranslation(); + const { schema, defaults } = useRegisterForm(); + + const { control, handleSubmit } = useForm({ + resolver: zodResolver(schema), + defaultValues: defaults, + }); + + const onSubmit = (data: RegisterFormData) => { + console.log("Registration data:", data); + }; + + const onError = (errors: any) => { + console.log("Validation errors:", errors); + }; + return ( - ( + + )} /> - ( + + )} /> - ( + + )} /> - ( + + )} /> - ( + + )} />