1+ "use client" ;
2+
3+ import { signUpSchema } from "@/app/schemas/auth" ;
4+ import { z } from "zod" ;
5+ import {
6+ Card ,
7+ CardContent ,
8+ CardDescription ,
9+ CardHeader ,
10+ CardTitle ,
11+ } from "@/components/ui/card" ;
12+ import { zodResolver } from "@hookform/resolvers/zod" ;
13+ import { Controller , useForm } from "react-hook-form" ;
14+ import { Input } from "@/components/ui/input" ;
15+ import {
16+ Field ,
17+ FieldError ,
18+ FieldGroup ,
19+ FieldLabel ,
20+ } from "@/components/ui/field" ;
21+ import { Button } from "@/components/ui/button" ;
22+
123export default function SignupPage ( ) {
2- return < h1 > Sign Up Page</ h1 >
3- }
24+ const form = useForm < z . infer < typeof signUpSchema > > ( {
25+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
26+ resolver : zodResolver ( signUpSchema as any ) ,
27+ defaultValues : {
28+ name : "" ,
29+ email : "" ,
30+ password : "" ,
31+ } ,
32+ } ) ;
33+
34+ const onSubmit = ( ) => {
35+ console . log ( "yoo" ) ;
36+ } ;
37+
38+ return (
39+ < Card >
40+ < CardHeader >
41+ < CardTitle > Sign Up</ CardTitle >
42+ < CardDescription > Create a new account to get started</ CardDescription >
43+ </ CardHeader >
44+ < CardContent >
45+ < form onSubmit = { form . handleSubmit ( onSubmit ) } >
46+ < FieldGroup >
47+ < Controller
48+ control = { form . control }
49+ name = "name"
50+ render = { ( { field, fieldState } ) => (
51+ < Field >
52+ < FieldLabel > Full Name</ FieldLabel >
53+ < Input
54+ aria-invalid = { fieldState . invalid }
55+ placeholder = "Jhon Doe"
56+ { ...field }
57+ />
58+ { fieldState . error && (
59+ < FieldError > { fieldState . error . message } </ FieldError >
60+ ) }
61+ </ Field >
62+ ) }
63+ />
64+ < Controller
65+ control = { form . control }
66+ name = "email"
67+ render = { ( { field, fieldState } ) => (
68+ < Field >
69+ < FieldLabel > Email</ FieldLabel >
70+ < Input
71+ aria-invalid = { fieldState . invalid }
72+ placeholder = "jhon@doe.com"
73+ type = "email"
74+ { ...field }
75+ />
76+ { fieldState . error && (
77+ < FieldError > { fieldState . error . message } </ FieldError >
78+ ) }
79+ </ Field >
80+ ) }
81+ />
82+ < Controller
83+ control = { form . control }
84+ name = "password"
85+ render = { ( { field, fieldState } ) => (
86+ < Field >
87+ < FieldLabel > Password</ FieldLabel >
88+ < Input
89+ aria-invalid = { fieldState . invalid }
90+ placeholder = "********"
91+ type = "password"
92+ { ...field }
93+ />
94+ { fieldState . error && (
95+ < FieldError > { fieldState . error . message } </ FieldError >
96+ ) }
97+ </ Field >
98+ ) }
99+ />
100+
101+ < Button type = "submit" > Sign up</ Button >
102+ </ FieldGroup >
103+ </ form >
104+ </ CardContent >
105+ </ Card >
106+ ) ;
107+ }
0 commit comments