-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
SignUp page now exists and works, mostly
- Loading branch information
1 parent
81a0fec
commit bda0e50
Showing
3 changed files
with
298 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,151 @@ | ||
"use client" | ||
|
||
import { Button } from '@/app/ui/button'; | ||
|
||
|
||
import { SignUp } from '../lib/actions'; | ||
|
||
import { useForm } from "react-hook-form"; | ||
import { zodResolver } from "@hookform/resolvers/zod"; | ||
import { z } from 'zod'; | ||
|
||
export default function SignupPage() { | ||
|
||
const SignUpSchema = z.object({ | ||
email: z.string().email(), | ||
|
||
first_name: z.string(), | ||
last_name: z.string(), | ||
|
||
password: z.string(), | ||
confirm_password: z.string() | ||
|
||
}).refine((data) => data.password === data.confirm_password, { | ||
message: "Passwords don't match", | ||
path: ["confirm_password"], // path of error | ||
}); | ||
|
||
type SignUp = z.infer<typeof SignUpSchema>; | ||
|
||
|
||
|
||
const {register,handleSubmit,reset, formState: { errors },} = useForm<SignUp>({resolver: zodResolver(SignUpSchema)}); | ||
|
||
const onSubmit = (data: SignUp) => { | ||
console.log("SENDING SIGNUP"); | ||
console.log(data); | ||
const resp = SignUp(data.first_name, data.last_name, data.email, data.password, data.confirm_password); | ||
console.log(resp); | ||
} | ||
|
||
|
||
return ( | ||
<main className="flex items-center justify-center md:h-screen"> | ||
<form onSubmit={handleSubmit(onSubmit)} > | ||
<div className="w-full"> | ||
<div> | ||
<label | ||
className="mb-3 mt-5 block text-xs font-medium text-gray-900" | ||
htmlFor="email" | ||
> | ||
</label> | ||
<div className="relative"> | ||
<input | ||
{...register("email")} | ||
className="peer block w-full rounded-md border border-gray-200 py-[9px] pl-10 text-sm outline-2 placeholder:text-gray-500" | ||
id="email" | ||
type="email" | ||
name="email" | ||
placeholder="Enter your email address" | ||
required | ||
/> | ||
{errors.email && (<p className="text-xs italic text-red-500 mt-2">{errors.email?.message}</p>)} | ||
</div> | ||
</div> | ||
|
||
<div className="mt-4"> | ||
<label | ||
className="mb-3 mt-5 block text-xs font-medium text-gray-900" | ||
htmlFor="first_name" | ||
> | ||
First | ||
</label> | ||
<div className="relative"> | ||
<input | ||
{...register("first_name")} | ||
className="peer block w-full rounded-md border border-gray-200 py-[9px] pl-10 text-sm outline-2 placeholder:text-gray-500" | ||
id="first_name" | ||
name="first_name" | ||
placeholder="First" | ||
required | ||
/> | ||
{errors.first_name && (<p className="text-xs italic text-red-500 mt-2">{errors.first_name?.message}</p>)} | ||
</div> | ||
</div> | ||
|
||
<div className="mt-4"> | ||
<label | ||
className="mb-3 mt-5 block text-xs font-medium text-gray-900" | ||
htmlFor="first" | ||
> | ||
Last | ||
</label> | ||
<div className="relative"> | ||
<input | ||
{...register("last_name")} | ||
className="peer block w-full rounded-md border border-gray-200 py-[9px] pl-10 text-sm outline-2 placeholder:text-gray-500" | ||
id="last_name" | ||
name="last_name" | ||
placeholder="Last" | ||
required | ||
/> | ||
{errors.last_name && (<p className="text-xs italic text-red-500 mt-2">{errors.last_name?.message}</p>)} | ||
</div> | ||
</div> | ||
|
||
<div className="mt-4"> | ||
<label | ||
className="mb-3 mt-5 block text-xs font-medium text-gray-900" | ||
htmlFor="password" | ||
> | ||
Password | ||
</label> | ||
<div className="relative"> | ||
<input | ||
{...register("password")} | ||
className="peer block w-full rounded-md border border-gray-200 py-[9px] pl-10 text-sm outline-2 placeholder:text-gray-500" | ||
id="password" | ||
name="password" | ||
placeholder="Enter password" | ||
required | ||
/> | ||
{errors.password && (<p className="text-xs italic text-red-500 mt-2">{errors.password?.message}</p>)} | ||
</div> | ||
</div> | ||
<div className="mt-4"> | ||
<label | ||
className="mb-3 mt-5 block text-xs font-medium text-gray-900" | ||
htmlFor="confirm_password" | ||
> | ||
Confim Password | ||
</label> | ||
<div className="relative"> | ||
<input | ||
{...register("confirm_password")} | ||
className="peer block w-full rounded-md border border-gray-200 py-[9px] pl-10 text-sm outline-2 placeholder:text-gray-500" | ||
id="confirm_password" | ||
name="confirm_password" | ||
placeholder="Enter password again" | ||
required | ||
/> | ||
{errors.confirm_password && (<p className="text-xs italic text-red-500 mt-2">{errors.confirm_password?.message}</p>)} | ||
</div> | ||
</div> | ||
|
||
</div> | ||
<Button type = "submit">Sign Up</Button> | ||
</form> | ||
</main> | ||
); | ||
} |