Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix #244 : show proper message while login and signup. #246

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 39 additions & 0 deletions React-frontend/src/pages/admin/SearchUser.js
Original file line number Diff line number Diff line change
@@ -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 (
<div>
<Layout sidebarBool={true}>
<ShowMembers extractors={extractors} managements={managements} isLoading={isLoading} isSearch={true}/>
</Layout>
</div>
)
}
return (
<Layout sidebarBool={false}>
<HomeLogo />
</Layout>
)
}

export default SearchUser
4 changes: 2 additions & 2 deletions React-frontend/src/store/actions/auth.js
Original file line number Diff line number Diff line change
Expand Up @@ -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'))
}
Expand Down Expand Up @@ -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()
Expand Down