From b7b72fa011b745b232fea3e48ec2097c31b78dce Mon Sep 17 00:00:00 2001 From: safwan20 Date: Thu, 11 Nov 2021 14:51:04 +0530 Subject: [PATCH] show proper message while login and signup --- React-frontend/src/pages/admin/SearchUser.js | 39 ++++++++++++++++++++ React-frontend/src/store/actions/auth.js | 4 +- 2 files changed, 41 insertions(+), 2 deletions(-) create mode 100644 React-frontend/src/pages/admin/SearchUser.js diff --git a/React-frontend/src/pages/admin/SearchUser.js b/React-frontend/src/pages/admin/SearchUser.js new file mode 100644 index 00000000..df427dc7 --- /dev/null +++ b/React-frontend/src/pages/admin/SearchUser.js @@ -0,0 +1,39 @@ +/* +* Component to display all the members of an admin. +*/ + +import React, { useEffect, useState } from 'react' +import Layout from '../../components/core/Layout' +import ShowMembers from '../../components/Admin/ShowMembers'; +import HomeLogo from '../../components/core/HomeLogo'; +import { useSelector, useDispatch } from 'react-redux'; +import { fetchMembers } from '../../store/actions/admin'; +import { set } from 'date-fns'; + +const SearchUser = () => { + // auth reducer + const auth = useSelector(state => state.auth) + const dispatch = useDispatch() + const {extractors, managements, isLoading} = useSelector(state => state.admin) + + useEffect(() => { + dispatch(fetchMembers()) + }, [dispatch]) + + if(auth && auth.isAuthenticated){ + return ( +
+ + + +
+ ) + } + return ( + + + + ) +} + +export default SearchUser diff --git a/React-frontend/src/store/actions/auth.js b/React-frontend/src/store/actions/auth.js index aced0916..ceb979ab 100644 --- a/React-frontend/src/store/actions/auth.js +++ b/React-frontend/src/store/actions/auth.js @@ -130,7 +130,7 @@ export const login = (email, password, role, remember, callback) => async dispat type: LOGIN_SUCCESSFULL, payload: {data: {auth_token: res.data.access_token}} }) - callback(false) + if (callback) callback(false) dispatch(loadUser()) dispatch(setAlert(res.data.message, 'success')) } @@ -177,7 +177,7 @@ export const signUp = (username, email, password, role, history, callback) => (d .then((res) => { if(res && (res.status === 200 || res.status === 201)){ dispatch({type: SIGNUP_SUCCESSFULL}) - callback(false) + if (callback) callback(false) history.push('/') dispatch(setAlert(res.data.message, 'success')) window.location.reload()