mirror of
https://github.com/elyby/accounts-frontend.git
synced 2024-12-27 15:30:37 +05:30
#65: Return to profile, if username was not changed.
This commit is contained in:
parent
c1723d09d7
commit
c2c6604ca5
@ -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())
|
||||
|
@ -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) => {
|
||||
|
Loading…
Reference in New Issue
Block a user