|
@@ -3,8 +3,11 @@ import { connect } from 'react-redux';
|
|
|
import { bindActionCreators } from 'redux'
|
|
|
import { getUserRequest } from '../../../actions/admin/user/getUser';
|
|
|
import { changeUserRequest } from '../../../actions/admin/user/changeUser';
|
|
|
+import {deleteUsersRequest} from '../../../actions/admin/user/deleteUser'
|
|
|
import ChangeUser from './changeUsers';
|
|
|
-import DeleteUserForm from './DeleteUserForm/index'
|
|
|
+import GetUser from './GetUsers';
|
|
|
+import PropagateLoader from 'react-spinners/PropagateLoader';
|
|
|
+
|
|
|
|
|
|
|
|
|
|
|
@@ -19,34 +22,41 @@ class DeleteUser extends React.Component {
|
|
|
|
|
|
}
|
|
|
handelClick = ({ el }) => {
|
|
|
+ console.log(el)
|
|
|
this.setState({ initialValues: el });
|
|
|
this.setState((prevState) => ({ flag: !prevState.flag }))
|
|
|
}
|
|
|
|
|
|
render() {
|
|
|
const { handelClick } = this
|
|
|
- const { users: { user }, changeUserRequest } = this.props;
|
|
|
+ const { users: { user }, changeUserRequest, changeUser: { data, isFetching }, deleteUsers, deleteUsersRequest } = this.props;
|
|
|
const { initialValues, flag } = this.state;
|
|
|
- console.log(initialValues, console.log(user))
|
|
|
+ console.log(initialValues)
|
|
|
+ console.log(user)
|
|
|
|
|
|
|
|
|
return (
|
|
|
<div className=" profile-page d-flex flex-row font-ci padding ">
|
|
|
- <div className='w-50 p-3 bg-rgba border rounded' >
|
|
|
+ <div className='w-25 p-3 bg-rgba border rounded' >
|
|
|
+ <h4 class="text-center text-white font-ci font-ci-bold">USERS</h4>
|
|
|
<div class="list-group">
|
|
|
-
|
|
|
- {user && user.map(el =>
|
|
|
- <button type="button" class=" list-group-item-action mb-4 borber bg-rgba1 border-0 text-white font-ci font-ci-bold " id={el._id} onClick={handelClick.bind(null, { el })}>{el.email}</button>
|
|
|
- )}
|
|
|
+ {
|
|
|
+ user !== null
|
|
|
+ ?
|
|
|
+ <GetUser data={data} deleteUsers={deleteUsers} initialValues={initialValues} user={user} isFetching ={isFetching } handlers={{handelClick}}></GetUser>
|
|
|
+ :
|
|
|
+ <PropagateLoader />
|
|
|
+ }
|
|
|
</div>
|
|
|
</div>
|
|
|
- <div className='w-50 p-3 bg-rgba ml-3 border rounded' >
|
|
|
- <DeleteUserForm></DeleteUserForm>
|
|
|
+ <div className='w-75 p-3 bg-rgba ml-3 border rounded' >
|
|
|
+
|
|
|
{
|
|
|
flag
|
|
|
?
|
|
|
- <ChangeUser initialValues={initialValues} action={{ changeUserRequest }} ></ChangeUser>
|
|
|
- : null
|
|
|
+ <ChangeUser initialValues={initialValues} action={{ changeUserRequest,deleteUsersRequest }} ></ChangeUser>
|
|
|
+ :
|
|
|
+ null
|
|
|
}
|
|
|
</div>
|
|
|
</div>
|
|
@@ -58,8 +68,10 @@ class DeleteUser extends React.Component {
|
|
|
const
|
|
|
mapStateToProps = state => ({
|
|
|
users: state.users,
|
|
|
+ changeUser: state.changeUser,
|
|
|
+ deleteUsers:state.deleteUsers
|
|
|
});
|
|
|
|
|
|
-const mapDispatchToProps = dispatch => bindActionCreators({ getUserRequest, changeUserRequest }, dispatch);
|
|
|
+const mapDispatchToProps = dispatch => bindActionCreators({ getUserRequest, changeUserRequest, deleteUsersRequest }, dispatch);
|
|
|
|
|
|
export default connect(mapStateToProps, mapDispatchToProps)(DeleteUser);
|