From 8b99ec1ab8899959df935c63467d7ebb82dcd525 Mon Sep 17 00:00:00 2001 From: victorAnumudu Date: Wed, 24 May 2023 22:29:04 +0100 Subject: [PATCH 1/3] login type bug fixed --- src/components/AuthPages/Login/index.jsx | 47 +++++++++++++----------- 1 file changed, 26 insertions(+), 21 deletions(-) diff --git a/src/components/AuthPages/Login/index.jsx b/src/components/AuthPages/Login/index.jsx index ffa0d35..81213a5 100644 --- a/src/components/AuthPages/Login/index.jsx +++ b/src/components/AuthPages/Login/index.jsx @@ -1,4 +1,4 @@ -import React, { useState } from "react"; +import React, { useEffect, useState } from "react"; import { Link, useNavigate } from "react-router-dom"; import linkedInLogo from "../../../assets/images/Linkedin.png"; import appleLogo from "../../../assets/images/apple-black.svg"; @@ -17,7 +17,7 @@ import { updateUserDetails } from "../../../store/UserDetails"; export default function Login() { const dispatch = useDispatch(); - let [loginCom, setLoginCom] = useState({ user: true, family: false }); + let [loginType, setLoginType] = useState({ full: true, family: false }); const [checked, setValue] = useState(false); const [loginLoading, setLoginLoading] = useState(false); @@ -32,11 +32,11 @@ export default function Login() { }; //FUNCTION TO DETERMINE/CHANGE LOGIN COMPONENT - const handleLoginCom = ({ target: { name } }) => { - if (name == "user") { - setLoginCom({ [name]: true, family: false }); - } else { - setLoginCom({ [name]: false, family: true }); + const handleLoginType = ({ target: { name } }) => { + if (name == "full") { + setLoginType({ [name]: true, family: false }); + } else if(name='family') { + setLoginType({ [name]: false, family: true }); } }; @@ -57,7 +57,7 @@ export default function Login() { const doLogin = ({ target: { name } }) => { setMsgError(""); setLoginLoading(true); - let postData = {}; // Post Data for API + let postData; // Post Data for API if (!email || !password) { setLoginLoading(false); setMsgError("Please fill all the fields"); @@ -67,14 +67,15 @@ export default function Login() { return; } - if (name == "userlogin") { // Post Data Info for normal Login + if (name == "loginfull") { // Post Data Info for normal Login postData = { username: email, password: password, sessionid: "STARTING", + login_mode: 1100, action: 11025, }; - } else if (name == "familylogin") { // Post Data Info for family Login + } else if (name == "loginfamily") { // Post Data Info for family Login postData = { username: email, pin: password, @@ -83,7 +84,6 @@ export default function Login() { action: 11025, }; } - userApi.logInUser(postData).then((res) => { if (res.status != 200 || res.data.internal_return < 0) { // setMsgError("Wrong, email/password"); @@ -112,6 +112,11 @@ export default function Login() { }); }; + useEffect(()=>{ + setMail('') + setPassword('') + },[loginType.full, loginType.family]) + return ( <> @@ -145,20 +150,20 @@ export default function Login() { {/* switch login component */}
@@ -168,7 +173,7 @@ export default function Login() { {/* for login component */} { - loginCom.user ? ( + loginType.full ? ( //user login compoenent
@@ -219,7 +224,7 @@ export default function Login() {
) : ( - Continue + <>Continue )}
@@ -302,7 +307,7 @@ export default function Login() {
) : ( - Continue + <>Continue )}
From fec464430064881e1f71ba1bcd478232018e50fd Mon Sep 17 00:00:00 2001 From: victorAnumudu Date: Wed, 24 May 2023 22:34:47 +0100 Subject: [PATCH 2/3] login type bug fixed --- src/components/AuthPages/Login/index.jsx | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/components/AuthPages/Login/index.jsx b/src/components/AuthPages/Login/index.jsx index 81213a5..5cc6bf5 100644 --- a/src/components/AuthPages/Login/index.jsx +++ b/src/components/AuthPages/Login/index.jsx @@ -83,6 +83,13 @@ export default function Login() { login_mode: 1105, action: 11025, }; + }else{ + setLoginLoading(false); + setMsgError("Invalid Login Type. Consider refreshing the page"); + setTimeout(() => { + setMsgError(""); + }, Number(process.env.REACT_APP_LOGIN_ERROR_TIMEOUT)); + return; } userApi.logInUser(postData).then((res) => { if (res.status != 200 || res.data.internal_return < 0) { From 65b58a6e6f050d3d1c1f75c2899f2b32e915a4a1 Mon Sep 17 00:00:00 2001 From: victorAnumudu Date: Wed, 24 May 2023 22:39:12 +0100 Subject: [PATCH 3/3] set login error to false once continue btn is clicked --- src/components/AuthPages/Login/index.jsx | 1 + 1 file changed, 1 insertion(+) diff --git a/src/components/AuthPages/Login/index.jsx b/src/components/AuthPages/Login/index.jsx index 5cc6bf5..dd37fb5 100644 --- a/src/components/AuthPages/Login/index.jsx +++ b/src/components/AuthPages/Login/index.jsx @@ -56,6 +56,7 @@ export default function Login() { // FUNCTION TO HANDLE USER LOGIN const doLogin = ({ target: { name } }) => { setMsgError(""); + setLoginError(false) setLoginLoading(true); let postData; // Post Data for API if (!email || !password) {