'use client' import * as z from 'zod' import { zodResolver } from '@hookform/resolvers/zod' import { useForm } from 'react-hook-form' import { Form, FormControl, FormField, FormItem, FormLabel, FormMessage } from '@/components/ui/form' import { RegisterSchema } from '@/schemas' import { Input } from '@/components/ui/input' import { CardWrapper } from '@/components/auth/card-wrapper' import { Button } from '@/components/ui/button' import { useTransition } from 'react' import { register } from '@/actions/register' import toast from 'react-hot-toast' export default function Page() { const [isPending, startTransition] = useTransition() const form = useForm>({ resolver: zodResolver(RegisterSchema), defaultValues: { email: '', password: '', name: '' } }) const onSubmit = (values: z.infer) => { startTransition(() => { register(values).then((data) => { if (data?.error) { toast.error(data.error) } if (data?.success) { toast.success(data.success) form.reset({ email: '', password: '', name: '' }) } }) }) } return (
( Name )} /> ( Email )} /> ( Password )} />
) }