mirror of
https://github.com/elyby/accounts-frontend.git
synced 2024-11-27 01:02:14 +05:30
#100: fetch fresh user data after profile update
This commit is contained in:
parent
f68f28a291
commit
6d44e43f5d
@ -20,13 +20,11 @@ class ChangeUsernamePage extends Component {
|
||||
form = new FormModel();
|
||||
|
||||
componentWillMount() {
|
||||
this.setState({
|
||||
actualUsername: this.props.username
|
||||
});
|
||||
this.actualUsername = this.props.username;
|
||||
}
|
||||
|
||||
componentWillUnmount() {
|
||||
this.props.updateUsername(this.state.actualUsername);
|
||||
this.props.updateUsername(this.actualUsername);
|
||||
}
|
||||
|
||||
render() {
|
||||
@ -45,7 +43,7 @@ class ChangeUsernamePage extends Component {
|
||||
|
||||
onSubmit = () => {
|
||||
const {form} = this;
|
||||
if (this.state.actualUsername === this.props.username) {
|
||||
if (this.actualUsername === this.props.username) {
|
||||
this.context.goToProfile();
|
||||
return;
|
||||
}
|
||||
@ -54,7 +52,7 @@ class ChangeUsernamePage extends Component {
|
||||
form,
|
||||
sendData: () => accounts.changeUsername(form.serialize())
|
||||
}).then(() => {
|
||||
this.props.updateUsername(form.value('username'));
|
||||
this.actualUsername = form.value('username');
|
||||
this.context.goToProfile();
|
||||
});
|
||||
};
|
||||
|
@ -9,6 +9,7 @@ class ProfilePage extends Component {
|
||||
|
||||
static propTypes = {
|
||||
onSubmit: PropTypes.func.isRequired,
|
||||
fetchUserData: PropTypes.func.isRequired,
|
||||
goToProfile: PropTypes.func.isRequired,
|
||||
children: PropTypes.element
|
||||
};
|
||||
@ -21,7 +22,7 @@ class ProfilePage extends Component {
|
||||
getChildContext() {
|
||||
return {
|
||||
onSubmit: this.props.onSubmit,
|
||||
goToProfile: this.props.goToProfile
|
||||
goToProfile: () => this.props.fetchUserData().then(this.props.goToProfile)
|
||||
};
|
||||
}
|
||||
|
||||
@ -40,6 +41,7 @@ class ProfilePage extends Component {
|
||||
|
||||
import { connect } from 'react-redux';
|
||||
import { routeActions } from 'react-router-redux';
|
||||
import { fetchUserData } from 'components/user/actions';
|
||||
import { create as createPopup } from 'components/ui/popup/actions';
|
||||
import PasswordRequestForm from 'components/profile/passwordRequestForm/PasswordRequestForm';
|
||||
|
||||
@ -47,6 +49,7 @@ export default connect(null, {
|
||||
goToProfile() {
|
||||
return routeActions.push('/');
|
||||
},
|
||||
fetchUserData,
|
||||
onSubmit: ({form, sendData}) => (dispatch) =>
|
||||
sendData()
|
||||
.catch((resp) => {
|
||||
|
Loading…
Reference in New Issue
Block a user