From 37e7645fa1eb0b83bc68f6e14069344a1f931c13 Mon Sep 17 00:00:00 2001 From: "Ayobami Alaran A." Date: Mon, 30 Oct 2023 18:56:03 +0000 Subject: [PATCH 1/3] feat: make auth password hidden and visible on show --- client/src/pages/Auth/SignIn.tsx | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/client/src/pages/Auth/SignIn.tsx b/client/src/pages/Auth/SignIn.tsx index 989afce..b0eeebc 100644 --- a/client/src/pages/Auth/SignIn.tsx +++ b/client/src/pages/Auth/SignIn.tsx @@ -3,6 +3,7 @@ import { useSnackbar } from 'notistack'; import { useNavigate } from 'react-router-dom'; import { useDispatch } from 'react-redux'; import { talentAuth, employerAuth } from '../../actions/auth'; +import { BiShow } from 'react-icons/bi' // eslint-disable-next-line @typescript-eslint/no-unused-vars import axios, { AxiosError } from 'axios'; @@ -28,6 +29,7 @@ const SignIn = ({ handleIsMemberClick }: SignInProps) => { const navigate = useNavigate(); const [loading, setLoading] = useState(false); const dispatch = useDispatch(); + const [hidePassword, setShowPassword] = useState(true); const handleSignIn = async () => { const credentials: SignInCredential = { email, @@ -92,14 +94,17 @@ const SignIn = ({ handleIsMemberClick }: SignInProps) => { className='border-1 text-2xl border-black-500 rounded-lg bg-gray-600 h-50 px-4 my-3 py-4 w-full justify-center' placeholder='Email' onChange={(e) => setEmail(e.target.value)} + /> + setPassword(e.target.value)} /> +

setShowPassword(!hidePassword)} /> Show Password

- - - setEmail(e.target.value)} - /> - setName(e.target.value)} - /> - setPassword(e.target.value)} - /> - setConfirmPassword(e.target.value)} - /> - -

- Already a Member?{' '} - - Sign in. - -

- + return ( +
+
+

Sign up as

+
+ +
- ); + setEmail(e.target.value)} + /> + setName(e.target.value)} + /> + setPassword(e.target.value)} + /> + setConfirmPassword(e.target.value)} + /> +

+ setShowPassword(!hidePassword)} + />{' '} + Show Password +

+ +

+ Already a Member?{' '} + + Sign in. + +

+
+
+ ); }; export default Signup; From 05620341d5ea08c31690793814c801a3dae04d03 Mon Sep 17 00:00:00 2001 From: Ayobami Date: Mon, 30 Oct 2023 22:10:10 +0100 Subject: [PATCH 3/3] bug: fix signup doesn't redirect after signup Made auth form switch to signin after signup successful --- client/src/pages/Auth/Auth.tsx | 45 +++++++++++++++----------------- client/src/pages/Auth/Signup.tsx | 6 +++-- client/src/reducers/users.ts | 7 ++++- 3 files changed, 31 insertions(+), 27 deletions(-) diff --git a/client/src/pages/Auth/Auth.tsx b/client/src/pages/Auth/Auth.tsx index 4374503..be85cf1 100644 --- a/client/src/pages/Auth/Auth.tsx +++ b/client/src/pages/Auth/Auth.tsx @@ -4,34 +4,31 @@ import SignUp from './Signup'; import Navbar from '../../components/Navbar/Navbar2'; const Auth: React.FC = () => { - const [isSignup, setIsSignup] = useState(false); + const [isSignup, setIsSignup] = useState(false); - const handleIsMemberClick = () => { - setIsSignup(!isSignup); - }; + const handleIsMemberClick = () => { + setIsSignup(!isSignup); + }; - return ( - <> -
- {/*
+ return ( + <> +
+ {/*
*/} - -
- -
- {isSignup ? ( - - ) : ( - - )} -
-
Footer
- - ); + +
+ +
+ {isSignup ? ( + + ) : ( + + )} +
+
Footer
+ + ); }; export default Auth; diff --git a/client/src/pages/Auth/Signup.tsx b/client/src/pages/Auth/Signup.tsx index fcb8eb9..41e69b5 100644 --- a/client/src/pages/Auth/Signup.tsx +++ b/client/src/pages/Auth/Signup.tsx @@ -43,7 +43,7 @@ const Signup = ({ handleIsMemberClick }: SignUpProps) => { // send request to talent signin endpoint if (isTalent) { setLoading(true); - dispatch( + await dispatch( talentSignupAuth( 'talents/signup', userData, @@ -52,11 +52,12 @@ const Signup = ({ handleIsMemberClick }: SignUpProps) => { setLoading, ), ); + handleIsMemberClick(); // else to employer endpoint } else { setLoading(true); - dispatch( + await dispatch( employerSignupAuth( 'employers/signup', userData, @@ -65,6 +66,7 @@ const Signup = ({ handleIsMemberClick }: SignUpProps) => { setLoading, ), ); + handleIsMemberClick(); } } catch (error) { const axiosError = error as AxiosError; diff --git a/client/src/reducers/users.ts b/client/src/reducers/users.ts index 6f847b6..1c78e42 100644 --- a/client/src/reducers/users.ts +++ b/client/src/reducers/users.ts @@ -1,4 +1,6 @@ -export const userReducer = (state = {}, action) => { +export const userReducer = (state = { + signupSuccessful: false, +}, action) => { switch (action.type) { case 'TALENT_AUTH': localStorage.setItem( @@ -12,6 +14,9 @@ export const userReducer = (state = {}, action) => { JSON.stringify({ ...action?.data }), ); return { ...state, user: action?.data?.data }; + + case 'SIGN_SUCCESS': + return { ...state, signupSuccessful: true } case 'LOGOUT': localStorage.clear(); return { ...state, user: null };