From ffb94accf691bd9002a6f60ec9d4f6f424ef6c72 Mon Sep 17 00:00:00 2001 From: andrzej Date: Wed, 11 Sep 2024 13:06:43 +0200 Subject: [PATCH] build login form --- src/app/login/page.tsx | 68 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 68 insertions(+) create mode 100644 src/app/login/page.tsx diff --git a/src/app/login/page.tsx b/src/app/login/page.tsx new file mode 100644 index 0000000..53277e5 --- /dev/null +++ b/src/app/login/page.tsx @@ -0,0 +1,68 @@ +"use client" +import { useForm } from "react-hook-form"; +import { z } from "zod"; +import { zodResolver } from "@hookform/resolvers/zod"; +import { toast } from "@/components/ui/use-toast"; +import { Form, FormControl, FormField, FormItem, FormLabel, FormMessage } from "@/components/ui/form"; +import { Input } from "@/components/ui/input"; +import { Button } from "@/components/ui/button"; + +const formSchema = z.object({ + email: z.string().email(), + password: z.string().min(6) +}) + +export default function LoginForm() { + const form = useForm>({ + resolver: zodResolver(formSchema), + }) + function onSubmit(values: z.infer) { + toast({ + title: "You submitted:", + description: JSON.stringify(values) + }) + } + + function onErrors(errors) { + toast({ + title: "WHOOPS", + description: JSON.stringify(errors) + }) + } + + return ( +
+ + ( + + Email Address + + + + + + )} + > + ( + + Password + + + + + + )} + > + +
+ + + ) +} +