mirror of
https://github.com/elyby/accounts-frontend.git
synced 2024-11-15 04:35:57 +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();
|
form = new FormModel();
|
||||||
|
|
||||||
componentWillMount() {
|
componentWillMount() {
|
||||||
this.setState({
|
this.actualUsername = this.props.username;
|
||||||
actualUsername: this.props.username
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
componentWillUnmount() {
|
componentWillUnmount() {
|
||||||
this.props.updateUsername(this.state.actualUsername);
|
this.props.updateUsername(this.actualUsername);
|
||||||
}
|
}
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
@ -45,7 +43,7 @@ class ChangeUsernamePage extends Component {
|
|||||||
|
|
||||||
onSubmit = () => {
|
onSubmit = () => {
|
||||||
const {form} = this;
|
const {form} = this;
|
||||||
if (this.state.actualUsername === this.props.username) {
|
if (this.actualUsername === this.props.username) {
|
||||||
this.context.goToProfile();
|
this.context.goToProfile();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -54,7 +52,7 @@ class ChangeUsernamePage extends Component {
|
|||||||
form,
|
form,
|
||||||
sendData: () => accounts.changeUsername(form.serialize())
|
sendData: () => accounts.changeUsername(form.serialize())
|
||||||
}).then(() => {
|
}).then(() => {
|
||||||
this.props.updateUsername(form.value('username'));
|
this.actualUsername = form.value('username');
|
||||||
this.context.goToProfile();
|
this.context.goToProfile();
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
@ -9,6 +9,7 @@ class ProfilePage extends Component {
|
|||||||
|
|
||||||
static propTypes = {
|
static propTypes = {
|
||||||
onSubmit: PropTypes.func.isRequired,
|
onSubmit: PropTypes.func.isRequired,
|
||||||
|
fetchUserData: PropTypes.func.isRequired,
|
||||||
goToProfile: PropTypes.func.isRequired,
|
goToProfile: PropTypes.func.isRequired,
|
||||||
children: PropTypes.element
|
children: PropTypes.element
|
||||||
};
|
};
|
||||||
@ -21,7 +22,7 @@ class ProfilePage extends Component {
|
|||||||
getChildContext() {
|
getChildContext() {
|
||||||
return {
|
return {
|
||||||
onSubmit: this.props.onSubmit,
|
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 { connect } from 'react-redux';
|
||||||
import { routeActions } from 'react-router-redux';
|
import { routeActions } from 'react-router-redux';
|
||||||
|
import { fetchUserData } from 'components/user/actions';
|
||||||
import { create as createPopup } from 'components/ui/popup/actions';
|
import { create as createPopup } from 'components/ui/popup/actions';
|
||||||
import PasswordRequestForm from 'components/profile/passwordRequestForm/PasswordRequestForm';
|
import PasswordRequestForm from 'components/profile/passwordRequestForm/PasswordRequestForm';
|
||||||
|
|
||||||
@ -47,6 +49,7 @@ export default connect(null, {
|
|||||||
goToProfile() {
|
goToProfile() {
|
||||||
return routeActions.push('/');
|
return routeActions.push('/');
|
||||||
},
|
},
|
||||||
|
fetchUserData,
|
||||||
onSubmit: ({form, sendData}) => (dispatch) =>
|
onSubmit: ({form, sendData}) => (dispatch) =>
|
||||||
sendData()
|
sendData()
|
||||||
.catch((resp) => {
|
.catch((resp) => {
|
||||||
|
Loading…
Reference in New Issue
Block a user