From bf6b8a7c8a80c20d2677eea299e0a779c6a9a4b1 Mon Sep 17 00:00:00 2001 From: Dhaval rathod Date: Fri, 10 May 2024 09:38:32 +0530 Subject: [PATCH] fix-Login page Error showing --- client/.env.sample | 2 +- client/src/components/Login/Login.jsx | 53 ++++++++++----------------- server/.env.sample | 6 +-- 3 files changed, 23 insertions(+), 38 deletions(-) diff --git a/client/.env.sample b/client/.env.sample index abdaae8..3afd2c3 100644 --- a/client/.env.sample +++ b/client/.env.sample @@ -1 +1 @@ -VITE_BASE_URL = \ No newline at end of file +VITE_BASE_URL = diff --git a/client/src/components/Login/Login.jsx b/client/src/components/Login/Login.jsx index ea78582..e58ae91 100644 --- a/client/src/components/Login/Login.jsx +++ b/client/src/components/Login/Login.jsx @@ -30,6 +30,17 @@ const Login = () => { }; const loginUser = async (data) => { + const tostStyle= { + position: "top-center", + autoClose: 5000, + hideProgressBar: false, + closeOnClick: false, + pauseOnHover: false, + draggable: false, + progress: undefined, + theme: "light", + transition: Bounce, + }; setLoading(true); try { const token = localStorage.getItem("token"); @@ -49,43 +60,17 @@ const Login = () => { navigate("/"); } else if (res.data.message === "user not found") { setloginError("User not found"); - toast.warning("User not found!", { - position: "top-center", - autoClose: 5000, - hideProgressBar: false, - closeOnClick: false, - pauseOnHover: false, - draggable: false, - progress: undefined, - theme: "light", - transition: Bounce, - }); + toast.warning("User not found!",tostStyle); } else if (res.data.message === "Invalid Credentials") { setloginError("Invalid Credentials"); - toast.error("Invalid credentials!", { - position: "top-center", - autoClose: 5000, - hideProgressBar: false, - closeOnClick: false, - pauseOnHover: false, - draggable: false, - progress: undefined, - theme: "light", - transition: Bounce, - }); - } else { + toast.error("Invalid credentials!",tostStyle); + } else if (res.data.message === "Unauthorized") { + setloginError("Invalid Credentials"); + toast.error("Invalid credentials!",tostStyle); + } + else { setloginError("Something went wrong!"); - toast.error("An error occurred!", { - position: "top-center", - autoClose: 5000, - hideProgressBar: false, - closeOnClick: false, - pauseOnHover: false, - draggable: false, - progress: undefined, - theme: "light", - transition: Bounce, - }); + toast.error("An error occurred!",tostStyle); } }); setLoading(false); diff --git a/server/.env.sample b/server/.env.sample index 8ad82b9..6629122 100644 --- a/server/.env.sample +++ b/server/.env.sample @@ -1,4 +1,4 @@ PORT = -MONGODB_URI = "" -SECRET = "" -ORIGIN = "" \ No newline at end of file +MONGODB_URI = +SECRET = +ORIGIN = \ No newline at end of file