-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
30 changed files
with
600 additions
and
114 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,2 @@ | ||
NEXT_PUBLIC_ENV=development | ||
NEXT_NODE_SERVER_URL=http://localhost:3000 | ||
NEXT_PUBLIC_SERVER_URL=http://localhost:8000 |
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,5 @@ | ||
import Image from 'next/image' | ||
|
||
const LoadingBall = () => <Image src={'/assets/icons/loader.svg'} alt='loading....' width={30} height={30} className='h-5 w-5' /> | ||
|
||
export default LoadingBall |
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
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 |
---|---|---|
|
@@ -7,12 +7,19 @@ import { z } from "zod"; | |
import { Form } from "@/components/ui/form"; | ||
import CustomFormField from "@/components/utils/CustomFormField"; | ||
import SubmitButton from "@/components/utils/SubmitButton"; | ||
import { signupFormValidation } from "@/lib/userValidation"; | ||
import { signupFormValidation } from "@/lib/validators/userValidation"; | ||
import { useSignUpMutation } from "@/lib/features/api/authApi"; | ||
import { FormFieldType } from "@/types/fromTypes"; | ||
import Link from "next/link"; | ||
import { useRouter } from "next/navigation"; | ||
import { useToast } from "../ui/use-toast"; | ||
import { Button } from "../ui/button"; | ||
|
||
const RegistrationForm = () => { | ||
const [isLoading, setIsLoading] = useState<boolean>(false); | ||
const [error, setError] = useState<string>(""); | ||
const router = useRouter(); | ||
const { toast } = useToast(); | ||
|
||
const form = useForm<z.infer<typeof signupFormValidation>>({ | ||
resolver: zodResolver(signupFormValidation), | ||
defaultValues: { | ||
|
@@ -24,12 +31,30 @@ const RegistrationForm = () => { | |
}, | ||
}); | ||
|
||
const onSubmit = async (values: z.infer<typeof signupFormValidation>) => { | ||
setIsLoading(true); | ||
setTimeout(() => { | ||
console.log("done"); | ||
}, 2000); | ||
setIsLoading(false); | ||
const [signUp, { isLoading: isPosting, data: response, error: signUpError }] = useSignUpMutation(); | ||
|
||
const onSubmit = async (formData: z.infer<typeof signupFormValidation>) => { | ||
try { | ||
await signUp(formData).unwrap(); | ||
toast({ | ||
title: "Registration Successful", | ||
description: "You have successfully registered. Please sign in.", | ||
variant: "default", | ||
}); | ||
router.push("/signin"); | ||
} catch (error: any) { | ||
setError(error?.data?.message || "An error occurred during registration"); | ||
toast({ | ||
title: "Registration Failed", | ||
description: error?.data?.message || "Please try again later.", | ||
variant: "destructive", | ||
action: ( | ||
<Button variant={"link"}> | ||
<Link href="/signin">Sign In</Link> | ||
</Button> | ||
), | ||
}); | ||
} | ||
}; | ||
|
||
return ( | ||
|
@@ -38,15 +63,15 @@ const RegistrationForm = () => { | |
<section className="mb-12 space-y-4"> | ||
<h1 className="header">Hi There👋</h1> | ||
<p className="text-dark-700"> | ||
Already have an account{" "} | ||
<Link href={"/patient/signin"} className="text-blue-400"> | ||
Already have an account?{" "} | ||
<Link href="/patient/signin" className="text-blue-400"> | ||
Sign In | ||
</Link> | ||
</p> | ||
</section> | ||
<section className="mb-12 space-y-4"> | ||
<div className="mb-9 space-y-1"> | ||
<h2 className="sub-header">Personal information </h2> | ||
<h2 className="sub-header">Personal Information</h2> | ||
</div> | ||
</section> | ||
|
||
|
@@ -59,22 +84,21 @@ const RegistrationForm = () => { | |
iconSrc="/assets/icons/user.svg" | ||
/> | ||
|
||
{/* EMAIL & PHONE */} | ||
<div className="flex flex-col gap-6 xl:flex-row"> | ||
<CustomFormField | ||
fieldType={FormFieldType.INPUT} | ||
control={form.control} | ||
name="email" | ||
label="Email address *" | ||
label="Email Address *" | ||
placeholder="[email protected]" | ||
iconSrc={"/assets/icons/email.svg"} | ||
iconSrc="/assets/icons/email.svg" | ||
/> | ||
|
||
<CustomFormField | ||
fieldType={FormFieldType.PHONE_INPUT} | ||
control={form.control} | ||
name="phone" | ||
label="Phone Number *" | ||
label="Phone Number *" | ||
placeholder="(555) 123-4567" | ||
/> | ||
</div> | ||
|
@@ -83,7 +107,7 @@ const RegistrationForm = () => { | |
control={form.control} | ||
fieldType={FormFieldType.PASSWORD} | ||
name="password" | ||
label="Password *" | ||
label="Password *" | ||
placeholder="Enter your password" | ||
/> | ||
<CustomFormField | ||
|
@@ -93,7 +117,10 @@ const RegistrationForm = () => { | |
label="Confirm Password" | ||
placeholder="Re-enter your password" | ||
/> | ||
<SubmitButton isLoading={isLoading}>Sign In</SubmitButton> | ||
|
||
{error && <p className="text-red-500 text-sm mt-2">{error}</p>} | ||
|
||
<SubmitButton isLoading={isPosting}>Sign Up</SubmitButton> | ||
</form> | ||
</Form> | ||
); | ||
|
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
Oops, something went wrong.
3d440b4
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Successfully deployed to the following URLs:
avm-care – ./
avm-care-sinans-projects-8d312afe.vercel.app
avm-care.vercel.app
avm-care-git-main-sinans-projects-8d312afe.vercel.app