From 8c5d83e4b5dad80e20460c73e74502e81564ff42 Mon Sep 17 00:00:00 2001 From: Saurabh Salunke Date: Tue, 21 May 2024 17:47:54 +0530 Subject: [PATCH 1/3] temp changes --- config.env | 2 ++ server/.gitignore | 3 ++- server/config/DBconnect.js | 2 +- server/index.js | 16 +++++++++------- 4 files changed, 14 insertions(+), 9 deletions(-) create mode 100644 config.env diff --git a/config.env b/config.env new file mode 100644 index 0000000..9214b52 --- /dev/null +++ b/config.env @@ -0,0 +1,2 @@ + +./package-lock.json \ No newline at end of file diff --git a/server/.gitignore b/server/.gitignore index 0326a4c..ffe0868 100644 --- a/server/.gitignore +++ b/server/.gitignore @@ -1,3 +1,4 @@ config.env /node_modules -package-lock.json \ No newline at end of file +package-lock.json +config.env \ No newline at end of file diff --git a/server/config/DBconnect.js b/server/config/DBconnect.js index bd4b6d6..cbc68f3 100644 --- a/server/config/DBconnect.js +++ b/server/config/DBconnect.js @@ -5,7 +5,7 @@ const connectDB = async () => { await mongoose.connect(process.env.DATABASE_URL); console.log("Connected To MongoDB"); } catch (err) { - console.log("DB Disconnected"); + console.log(err) process.exit(1); } }; diff --git a/server/index.js b/server/index.js index d1c7f9e..2c025f4 100644 --- a/server/index.js +++ b/server/index.js @@ -9,7 +9,7 @@ import { KidsRouter } from './routes/kids-route.js'; const app=express(); -dotenv.config({path:'./config.env'}); +dotenv.config({path:'./config.env'}) connectDB(); @@ -17,18 +17,20 @@ app.use(express.json()); app.use(morgan('dev')) -app.use(cors({ - origin:"https://shopy-mohitparmar1s-projects.vercel.app/", - methods:['GET','POST'], - credentials:true, - })) +app.use( + cors({ + // origin: "https://shopy-mohitparmar1s-projects.vercel.app/", + origin: "*", + methods: ["GET", "POST"], + credentials: true, + }) +); app.use('/api/v1/mens',MensRouter); app.use('/api/v1/womens',WomensRouter); app.use('/api/v1/kids',KidsRouter); const port=process.env.PORT||7000; - app.listen(port,()=>{ console.log(`Server is running on port ${port}`); }) \ No newline at end of file From 80c3d049e4df4c7b8dad5e7624394f5e181a1c26 Mon Sep 17 00:00:00 2001 From: Saurabh Salunke Date: Tue, 21 May 2024 19:32:50 +0530 Subject: [PATCH 2/3] Fixes: #83 Login and signup Form Validation fixed --- src/Pages/Login.jsx | 71 +++++++++++++++++++++++++++++++------- src/Pages/Signup.jsx | 82 +++++++++++++++++++++++++++++++++++++++++--- 2 files changed, 136 insertions(+), 17 deletions(-) diff --git a/src/Pages/Login.jsx b/src/Pages/Login.jsx index 5bac6bd..590ba95 100644 --- a/src/Pages/Login.jsx +++ b/src/Pages/Login.jsx @@ -1,47 +1,92 @@ -import React, { useState } from "react"; +import React, { useEffect, useState } from "react"; import { Link, useNavigate } from "react-router-dom"; import google from '../assets/google.png' const Login = () => { const [active, setActive] = useState(true); - + const [email, setEmail] = useState(""); + const [password, setPassword] = useState(""); + const [isEmailValid, setIsEmailValid] = useState(false); + const [isPasswordValid, setIsPasswordValid] = useState(false); + const [isEmailFocused, setIsEmailFocused] = useState(false); + const [isPasswordFocused, setIsPasswordFocused] = useState(false); const navigate = useNavigate(); - const handleClicked = () => { - navigate("/signup"); - }; + const handleLogin = async (e) => { + e.preventDefault(); + console.log(email," ",password); + } return (

Login

- + + {isEmailFocused && !isEmailValid && ( +
+ * Email is not valid +
+ )} { + setEmail(e.target.value); + setIsEmailValid( + e.target.value.trim().length > 0 && + e.target.value.trim().includes("@") && + e.target.value.trim().includes(".") + ); + }} + onFocus={() => { + setIsEmailFocused(true); + setIsPasswordFocused(false); + }} /> + {isPasswordFocused && !isPasswordValid && ( +
+ * Password is not valid +
+ )} { + setPassword(e.target.value); + setIsPasswordValid( + e.target.value.trim().length > 0 && + e.target.value.trim().length >= 8 + ); + }} + onFocus={() => { + setIsEmailFocused(false); + setIsPasswordFocused(true); + }} /> - -

+

{"Don't have an account?"} navigate("/signup")} > Sign Up

-
); diff --git a/src/Pages/Signup.jsx b/src/Pages/Signup.jsx index 5883805..8d501bb 100644 --- a/src/Pages/Signup.jsx +++ b/src/Pages/Signup.jsx @@ -1,7 +1,20 @@ import { useNavigate } from "react-router-dom"; - +import { useState } from "react"; const Signup = () => { const navigate = useNavigate(); + const [email, setEmail] = useState(""); + const [password, setPassword] = useState(""); + const [confirmPassword, setConfirmPassword] = useState(""); + const [isEmailValid, setIsEmailValid] = useState(false); + const [isPasswordValid, setIsPasswordValid] = useState(false); + const [isEmailFocused, setIsEmailFocused] = useState(false); + const [isPasswordFocused, setIsPasswordFocused] = useState(false); + const [isConfirmPasswordValid,setIsConfirmPasswordValid] = useState(false) + const [isConfirmPasswordFocused,setIsConfirmPasswordFocused]=useState(false) + const handleSignUp = async (e) => { + e.preventDefault(); + console.log(email, " ", password," ",confirmPassword); + }; const handleClicked = () => { navigate("/login"); }; @@ -9,31 +22,92 @@ const Signup = () => {

Sign up

- + + {isEmailFocused && !isEmailValid && ( +
+ * Email is not valid +
+ )} { + setEmail(e.target.value); + setIsEmailValid( + e.target.value.trim().length > 0 && + e.target.value.trim().includes("@") && + e.target.value.trim().includes(".") + ); + }} + onFocus={() => { + setIsEmailFocused(true); + setIsPasswordFocused(false); + setIsConfirmPasswordFocused(false); + }} /> + {isPasswordFocused && !isPasswordValid && ( +
+ * Password is not valid +
+ )} { + setPassword(e.target.value); + setIsPasswordValid( + e.target.value.trim().length > 0 && + e.target.value.trim().length >= 8 + ); + }} + onFocus={() => { + setIsEmailFocused(false); + setIsPasswordFocused(true); + setIsConfirmPasswordFocused(false); + }} /> + {isConfirmPasswordFocused && !isConfirmPasswordValid && ( +
+ * Password doesn't match +
+ )} { + setConfirmPassword(e.target.value); + setIsConfirmPasswordValid(e.target.value === password); + }} + onFocus={() => { + setIsEmailFocused(false); + setIsPasswordFocused(false); + setIsConfirmPasswordFocused(true); + }} /> - -

+

{"Already have an account?"} Date: Tue, 21 May 2024 20:32:13 +0530 Subject: [PATCH 3/3] Fixes: #83 Login and signup Form Validation fixed --- src/Pages/Login.jsx | 66 +++++++++++++++++------ src/Pages/Signup.jsx | 123 ++++++++++++++++++++++++++++++++----------- 2 files changed, 141 insertions(+), 48 deletions(-) diff --git a/src/Pages/Login.jsx b/src/Pages/Login.jsx index 590ba95..3f579bf 100644 --- a/src/Pages/Login.jsx +++ b/src/Pages/Login.jsx @@ -1,6 +1,8 @@ import React, { useEffect, useState } from "react"; import { Link, useNavigate } from "react-router-dom"; import google from '../assets/google.png' +import { IoEyeOutline, IoEyeOffOutline } from "react-icons/io5"; + const Login = () => { const [active, setActive] = useState(true); const [email, setEmail] = useState(""); @@ -9,6 +11,7 @@ const Login = () => { const [isPasswordValid, setIsPasswordValid] = useState(false); const [isEmailFocused, setIsEmailFocused] = useState(false); const [isPasswordFocused, setIsPasswordFocused] = useState(false); + const [isPasswordVisible, setIsPasswordVisible] = useState(false); const navigate = useNavigate(); const handleLogin = async (e) => { e.preventDefault(); @@ -48,23 +51,52 @@ const Login = () => { * Password is not valid

)} - { - setPassword(e.target.value); - setIsPasswordValid( - e.target.value.trim().length > 0 && - e.target.value.trim().length >= 8 - ); +
{ - setIsEmailFocused(false); - setIsPasswordFocused(true); - }} - /> + > + { + setPassword(e.target.value); + setIsPasswordValid( + e.target.value.trim().length > 0 && + e.target.value.trim().length >= 8 + ); + }} + onFocus={() => { + setIsEmailFocused(false); + setIsPasswordFocused(true); + }} + /> +
setIsPasswordVisible(!isPasswordVisible)} + > + {!isPasswordVisible ? ( + + ) : ( + + )} +
+
-

+

{"Don't have an account?"} { const navigate = useNavigate(); const [email, setEmail] = useState(""); @@ -11,6 +12,8 @@ const Signup = () => { const [isPasswordFocused, setIsPasswordFocused] = useState(false); const [isConfirmPasswordValid,setIsConfirmPasswordValid] = useState(false) const [isConfirmPasswordFocused,setIsConfirmPasswordFocused]=useState(false) + const [isPasswordVisible, setIsPasswordVisible] = useState(false); + const [isConfirmPasswordVisible, setConfirmIsPasswordVisible] = useState(false); const handleSignUp = async (e) => { e.preventDefault(); console.log(email, " ", password," ",confirmPassword); @@ -53,45 +56,103 @@ const Signup = () => { * Password is not valid )} - { - setPassword(e.target.value); - setIsPasswordValid( - e.target.value.trim().length > 0 && - e.target.value.trim().length >= 8 - ); +

{ - setIsEmailFocused(false); - setIsPasswordFocused(true); - setIsConfirmPasswordFocused(false); - }} - /> + > + { + setPassword(e.target.value); + setIsPasswordValid( + e.target.value.trim().length > 0 && + e.target.value.trim().length >= 8 + ); + }} + onFocus={() => { + setIsEmailFocused(false); + setIsPasswordFocused(true); + setIsConfirmPasswordFocused(false); + }} + /> +
setIsPasswordVisible(!isPasswordVisible)} + > + {!isPasswordVisible ? ( + + ) : ( + + )} +
+
{isConfirmPasswordFocused && !isConfirmPasswordValid && (
* Password doesn't match
)} - { - setConfirmPassword(e.target.value); - setIsConfirmPasswordValid(e.target.value === password); +
{ - setIsEmailFocused(false); - setIsPasswordFocused(false); - setIsConfirmPasswordFocused(true); - }} - /> + > + { + setConfirmPassword(e.target.value); + setIsConfirmPasswordValid(e.target.value === password); + }} + onFocus={() => { + setIsEmailFocused(false); + setIsPasswordFocused(false); + setIsConfirmPasswordFocused(true); + }} + /> +
+ setConfirmIsPasswordVisible(!isConfirmPasswordVisible) + } + > + {!isConfirmPasswordVisible ? ( + + ) : ( + + )} +
+