diff --git a/README.md b/README.md index 8bedf51..6c991b5 100644 --- a/README.md +++ b/README.md @@ -116,6 +116,8 @@ Below is a list of all the amazing contributors who have helped make this projec

## +<<<<<<< HEAD +======= # Project Contributers: ### Thank you everyone for your contributions! 🙏 We hope to see you contribute even more in the future. 🚀👨‍💻👩‍💻 @@ -129,6 +131,7 @@ Below is a list of all the amazing contributors who have helped make this projec --- +>>>>>>> e9d5817b131855e47dd0b52d0c40e8546a339662 *Connect with me on GitHub: [yashksaini-coder](https://github.com/yashksaini-coder)* diff --git a/components/AuthComponent/SigninForm.tsx b/components/AuthComponent/SigninForm.tsx index c62c9bd..7d9a4b4 100644 --- a/components/AuthComponent/SigninForm.tsx +++ b/components/AuthComponent/SigninForm.tsx @@ -1,10 +1,12 @@ -"use client" +"use client"; -import React from "react" -import { useRouter } from "next/navigation" -import { zodResolver } from "@hookform/resolvers/zod" -import { useForm } from "react-hook-form" -import * as z from "zod" +import React, { useState } from "react"; +import { useRouter } from "next/navigation"; +import { zodResolver } from "@hookform/resolvers/zod"; +import { useForm } from "react-hook-form"; +import * as z from "zod"; +import { Eye, EyeOff } from "lucide-react"; +import { Button } from "@/components/ui/button"; import { Form, FormControl, @@ -12,9 +14,9 @@ import { FormItem, FormLabel, FormMessage, -} from "@/components/ui/form" -import { Input } from "@/components/ui/input" -import { Alert, AlertDescription } from "@/components/ui/alert" +} from "@/components/ui/form"; +import { Input } from "@/components/ui/input"; +import { Alert, AlertDescription } from "@/components/ui/alert"; import { Card, CardContent, @@ -22,17 +24,18 @@ import { CardFooter, CardHeader, CardTitle, -} from "@/components/ui/card" -import { useAuthStore } from "@/store/AuthStore/useAuthStore" -import LoadingButton from "../Buttons/LoadingButton" -import AuthBottom from "./AuthBottom" -import { signinSchema } from "@/validations/validation" +} from "@/components/ui/card"; +import { useAuthStore } from "@/store/AuthStore/useAuthStore"; +import LoadingButton from "../Buttons/LoadingButton"; +import AuthBottom from "./AuthBottom"; +import { signinSchema } from "@/validations/validation"; -type SigninFormValues = z.infer +type SigninFormValues = z.infer; export default function SigninForm() { - const { isSigningIn, signin, signinError } = useAuthStore() - const router = useRouter() + const { isSigningIn, signin, signinError } = useAuthStore(); + const router = useRouter(); + const [showPassword, setShowPassword] = useState(false); const form = useForm({ resolver: zodResolver(signinSchema), @@ -40,11 +43,11 @@ export default function SigninForm() { email: "", password: "", }, - }) + }); const onSubmit = (data: SigninFormValues) => { - signin(data, router) - } + signin(data, router); + }; return (
@@ -78,7 +81,26 @@ export default function SigninForm() { Password - +
+ + +
@@ -107,5 +129,5 @@ export default function SigninForm() {
- ) -} \ No newline at end of file + ); +} diff --git a/components/AuthComponent/SignupForm.tsx b/components/AuthComponent/SignupForm.tsx index 8b93fe1..66cb706 100644 --- a/components/AuthComponent/SignupForm.tsx +++ b/components/AuthComponent/SignupForm.tsx @@ -1,10 +1,12 @@ "use client"; -import React from "react"; +import React, { useState } from "react"; import { useRouter } from "next/navigation"; import { zodResolver } from "@hookform/resolvers/zod"; import { useForm } from "react-hook-form"; import * as z from "zod"; +import { Eye, EyeOff } from "lucide-react"; +import { Button } from "@/components/ui/button"; import { Form, FormControl, @@ -39,6 +41,7 @@ type SignupFormValues = z.infer; export default function SignupForm() { const { isSigningUp, signup, signupError } = useAuthStore(); const router = useRouter(); + const [showPassword, setShowPassword] = useState(false); const form = useForm({ resolver: zodResolver(signupSchema), @@ -47,7 +50,7 @@ export default function SignupForm() { email: "", password: "", leetcodeUsername: "", - gender: "", + gender: undefined, // Changed from "" to undefined }, }); @@ -102,7 +105,26 @@ export default function SignupForm() { Password - +
+ + +
diff --git a/package-lock.json b/package-lock.json index 72801a3..fbcc356 100644 --- a/package-lock.json +++ b/package-lock.json @@ -243,6 +243,7 @@ "version": "3.10.0", "resolved": "https://registry.npmjs.org/@hookform/resolvers/-/resolvers-3.10.0.tgz", "integrity": "sha512-79Dv+3mDF7i+2ajj7SkypSKHhl1cbln1OGavqrsF7p6mbUv11xpqpacPsGDCTRvCSjEEIez2ef1NveSVL3b0Ag==", + "license": "MIT", "peerDependencies": { "react-hook-form": "^7.0.0" } @@ -5779,6 +5780,7 @@ "version": "7.54.2", "resolved": "https://registry.npmjs.org/react-hook-form/-/react-hook-form-7.54.2.tgz", "integrity": "sha512-eHpAUgUjWbZocoQYUHposymRb4ZP6d0uwUnooL2uOybA9/3tPUvoAKqEWK1WaSiTxxOfTpffNZP7QwlnM3/gEg==", + "license": "MIT", "engines": { "node": ">=18.0.0" }, @@ -7217,6 +7219,7 @@ "version": "3.24.1", "resolved": "https://registry.npmjs.org/zod/-/zod-3.24.1.tgz", "integrity": "sha512-muH7gBL9sI1nciMZV67X5fTKKBLtwpZ5VBp1vsOQzj1MhrBZ4wlVCm3gedKZWLp0Oyel8sIGfeiz54Su+OVT+A==", + "license": "MIT", "funding": { "url": "https://github.com/sponsors/colinhacks" } diff --git a/validations/validation.ts b/validations/validation.ts index 167cbb3..6f7aa1e 100644 --- a/validations/validation.ts +++ b/validations/validation.ts @@ -1,33 +1,19 @@ -import z from 'zod'; +import * as z from "zod"; export const signupSchema = z.object({ - email: z - .string() - .email({ message: "Please provide a valid email address." }), - password: z - .string() - .min(6, { message: "Password must be at least 6 characters." }) - .max(20, { message: "Your password cannot exceed 20 characters" }) - .regex( - /^(?=.*[a-z])(?=.*[A-Z])(?=.*[@$!%*?&#^])[A-Za-z@$!%*?&#^]{6,}$/, - { - message: "Password must include at least one uppercase letter, one lowercase letter, and one special character", - } - ), - fullName: z - .string() - .nonempty({ message: "Full name is required." }), - leetcodeUsername: z - .string() - .nonempty({ message: "Leetcode username is required to connect your profile" }), - gender: z - .string() - .nonempty({ message: "Please select your gender " }), + fullName: z.string().min(2, "Full name must be at least 2 characters"), + email: z.string().email("Invalid email address"), + password: z + .string() + .min(6, "Password must be at least 6 characters") + .max(100, "Password must be less than 100 characters"), + leetcodeUsername: z.string().min(1, "LeetCode username is required"), + gender: z.enum(["male", "female", "other"], { + required_error: "Please select a gender", + }), }); export const signinSchema = z.object({ - email: z.string().email({ message: "Please provide a valid email address." }), - password: z.string().nonempty({ message: "Password is required." }), + email: z.string().email("Invalid email address"), + password: z.string().min(1, "Password is required"), }); - -