|
@@ -2,36 +2,48 @@ import React from 'react';
|
|
|
import { connect } from 'react-redux';
|
|
|
import { bindActionCreators } from 'redux'
|
|
|
import ChangeLoginForm from './ChangeLoginForm/index';
|
|
|
-import {changeLoginRequest} from '../../../actions/user/changelogin'
|
|
|
-
|
|
|
+import ChangeEmailForm from './ChangeEmailForm/index';
|
|
|
+import ChangePasswordForm from './changePassword/index'
|
|
|
+import {changeLoginRequest} from '../../../actions/user/changelogin';
|
|
|
+import {changeEmailRequest} from '../../../actions/user/changeEmail';
|
|
|
+import {changePasswordRequest } from '../../../actions/user/changePassword'
|
|
|
|
|
|
|
|
|
class ProfilePage extends React.Component {
|
|
|
+
|
|
|
state={
|
|
|
- clicked:false
|
|
|
+ clicked:false,
|
|
|
+ klick: false,
|
|
|
+ click: false
|
|
|
}
|
|
|
|
|
|
handleClick = () => {
|
|
|
this.setState((prevState) => ({ clicked: !prevState.clicked }));
|
|
|
}
|
|
|
+ handleClicks = () => {
|
|
|
+ this.setState((prevState) => ({ klick: !prevState.klick }));
|
|
|
+ }
|
|
|
+ handleClicked = () => {
|
|
|
+ this.setState((prevState) => ({ click: !prevState.click }));
|
|
|
+ }
|
|
|
|
|
|
render() {
|
|
|
- const { signIn:{data, token}, changeLoginRequest, changeLogin} = this.props;
|
|
|
- console.log(changeLogin)
|
|
|
- const {clicked} =this.state;
|
|
|
- const {handleClick} = this;
|
|
|
+ const { signIn:{data, token}, changeLoginRequest, chageLoginReducer, changeEmailRequest, changeEmailReducer, changePasswordRequest} = this.props;
|
|
|
+ console.log(changeEmailReducer)
|
|
|
+ const {clicked, klick, click} =this.state;
|
|
|
+ const {handleClick, handleClicks, handleClicked} = this;
|
|
|
|
|
|
return (
|
|
|
<div className="page page--bottom-only profile-page">
|
|
|
<div className="border bg-autumn-foliage m-5 rounded d-flex">
|
|
|
<div>
|
|
|
- <h5 className="p-2 font-po-bold flex-fill bd-highlight align-self-end">{data.name}</h5>
|
|
|
- <div className="d-flex" >
|
|
|
+ {/* <h5 className="p-2 font-po-bold flex-fill bd-highlight align-self-end">{data.name}</h5> */}
|
|
|
+ {/* <div className="d-flex" >
|
|
|
<p className="p-2 flex-fill font-po-bold bd-highlight align-self-end">Email</p><p className="p-2 flex-fill font-po-bold bd-highlight align-self-end">{data.email}</p>
|
|
|
- </div>
|
|
|
- <div className="d-flex" >
|
|
|
+ </div> */}
|
|
|
+ {/* <div className="d-flex" >
|
|
|
<p className="p-2 flex-fill font-po-bold bd-highlight align-self-end">Role</p><p className="p-2 flex-fill font-po-bold bd-highlight align-self-end">{data.role}</p>
|
|
|
- </div>
|
|
|
+ </div> */}
|
|
|
|
|
|
<div>
|
|
|
<img className="m-4 " src=" https://cdn.iconscout.com/icon/free/png-256/avatar-373-456325.png" ></img>
|
|
@@ -42,7 +54,14 @@ class ProfilePage extends React.Component {
|
|
|
?
|
|
|
<div className ="d-flex mb-3" >
|
|
|
<h3 className = " p-2 flex-fill bd-highlight">Name</h3>
|
|
|
- <h5 className="p-2 font-po-bold flex-fill bd-highlight align-self-end">{data.name}</h5>
|
|
|
+ <h5 className="p-2 font-po-bold flex-fill bd-highlight align-self-end">{
|
|
|
+ chageLoginReducer.data == null
|
|
|
+ ?
|
|
|
+ data.name
|
|
|
+ :
|
|
|
+ chageLoginReducer.data
|
|
|
+
|
|
|
+ }</h5>
|
|
|
<button type="button" onClick ={handleClick} className=" flex-fill bg-shadow btn btn-outline-primary col-3">Change</button>
|
|
|
</div>
|
|
|
:
|
|
@@ -52,15 +71,41 @@ class ProfilePage extends React.Component {
|
|
|
<ChangeLoginForm data ={data} token={token} actions ={{changeLoginRequest}} handlers={{ handleClick}}> </ChangeLoginForm>
|
|
|
</div>
|
|
|
}
|
|
|
+ {!klick
|
|
|
+ ?
|
|
|
+ <div className ="d-flex mb-3" >
|
|
|
+ <h3 className = "p-2 flex-fill bd-highlight">Email</h3>
|
|
|
+ <h5 className="p-2 flex-fill font-po-bold bd-highlight align-self-end">
|
|
|
+ {
|
|
|
+ changeEmailReducer.data ===null
|
|
|
+ ?
|
|
|
+ data.email
|
|
|
+ :
|
|
|
+ changeEmailReducer.data
|
|
|
+ }
|
|
|
+ </h5>
|
|
|
+ <button type="button" name ="name" onClick ={handleClicks} className=" flex-fill bg-shadow btn btn-outline-primary col-3">Change</button>
|
|
|
+ </div>
|
|
|
+ :
|
|
|
<div className ="d-flex mb-3" >
|
|
|
<h3 className = "p-2 flex-fill bd-highlight">Email</h3>
|
|
|
<h5 className="p-2 flex-fill font-po-bold bd-highlight align-self-end">{data.email}</h5>
|
|
|
- <button type="button" className=" flex-fill bg-shadow btn btn-outline-primary col-3">Change</button>
|
|
|
+ <ChangeEmailForm data ={data} token={token} actions ={{changeEmailRequest}} handlers={{ handleClicks}}></ChangeEmailForm>
|
|
|
</div>
|
|
|
+ }
|
|
|
+ {
|
|
|
+ !click
|
|
|
+ ?
|
|
|
<div className ="d-flex mb-3" >
|
|
|
<h3 className = "p-2 flex-fill bd-highlight">Password</h3>
|
|
|
- <button type="button" className=" flex-fill bg-shadow btn btn-outline-primary col-3">Change</button>
|
|
|
+ <button type="button" onClick ={handleClicked} className=" flex-fill bg-shadow btn btn-outline-primary col-3">Change</button>
|
|
|
</div>
|
|
|
+ :
|
|
|
+ <div className ="d-flex mb-3" >
|
|
|
+ <h3 className = "p-2 flex-fill bd-highlight">Password</h3>
|
|
|
+ <ChangePasswordForm data ={data} token={token} actions ={{changePasswordRequest}} handlers={{ handleClicked}}></ChangePasswordForm>
|
|
|
+ </div>
|
|
|
+ }
|
|
|
|
|
|
</div>
|
|
|
</div>
|
|
@@ -94,9 +139,10 @@ class ProfilePage extends React.Component {
|
|
|
const
|
|
|
mapStateToProps = state => ({
|
|
|
signIn: state.signIn,
|
|
|
- changeLogin: state.changeLogin
|
|
|
+ chageLoginReducer: state.chageLoginReducer,
|
|
|
+ changeEmailReducer:state.changeEmailReducer
|
|
|
});
|
|
|
|
|
|
-const mapDispatchToProps = dispatch => bindActionCreators({changeLoginRequest}, dispatch);
|
|
|
+const mapDispatchToProps = dispatch => bindActionCreators({changeLoginRequest, changeEmailRequest, changePasswordRequest}, dispatch);
|
|
|
|
|
|
export default connect(mapStateToProps, mapDispatchToProps)(ProfilePage);
|