#65: Return to profile, if username was not changed.

This commit is contained in:
SleepWalker 2016-05-14 10:54:26 +03:00
parent c1723d09d7
commit c2c6604ca5
2 changed files with 12 additions and 3 deletions

View File

@ -13,7 +13,8 @@ class ChangeUsernamePage extends Component {
};
static contextTypes = {
onSubmit: PropTypes.func.isRequired
onSubmit: PropTypes.func.isRequired,
goToProfile: PropTypes.func.isRequired
};
form = new FormModel();
@ -44,6 +45,11 @@ class ChangeUsernamePage extends Component {
onSubmit = () => {
const {form} = this;
if (this.state.actualUsername === this.props.username) {
this.context.goToProfile();
return;
}
this.context.onSubmit({
form,
sendData: () => accounts.changeUsername(form.serialize())

View File

@ -10,12 +10,14 @@ class ProfilePage extends Component {
};
static childContextTypes = {
onSubmit: PropTypes.func
onSubmit: PropTypes.func,
goToProfile: PropTypes.func
};
getChildContext() {
return {
onSubmit: this.props.onSubmit
onSubmit: this.props.onSubmit,
goToProfile: this.props.goToProfile
};
}
@ -38,6 +40,7 @@ function goToProfile() {
}
export default connect(null, {
goToProfile,
onSubmit: ({form, sendData}) => (dispatch) =>
sendData()
.catch((resp) => {