2016-05-02 23:02:03 +05:30
|
|
|
import React, { Component, PropTypes } from 'react';
|
|
|
|
|
|
|
|
import { FormModel } from 'components/ui/form';
|
|
|
|
import ChangeEmail from 'components/profile/changeEmail/ChangeEmail';
|
|
|
|
|
|
|
|
class ProfileChangeEmailPage extends Component {
|
|
|
|
static displayName = 'ProfileChangeEmailPage';
|
|
|
|
|
|
|
|
static propTypes = {
|
2016-05-20 10:44:14 +05:30
|
|
|
email: PropTypes.string.isRequired,
|
|
|
|
params: PropTypes.shape({
|
|
|
|
step: PropTypes.oneOf(['step1', 'step2', 'step3']),
|
|
|
|
code: PropTypes.string
|
|
|
|
})
|
|
|
|
};
|
|
|
|
|
|
|
|
static contextTypes = {
|
|
|
|
router: PropTypes.shape({
|
|
|
|
push: PropTypes.func
|
|
|
|
}).isRequired
|
2016-05-02 23:02:03 +05:30
|
|
|
};
|
|
|
|
|
|
|
|
form = new FormModel();
|
|
|
|
|
2016-05-20 10:44:14 +05:30
|
|
|
componentWillMount() {
|
|
|
|
const step = this.props.params.step;
|
|
|
|
|
|
|
|
if (step && !/^step\d$/.test(step)) {
|
|
|
|
// wrong param value
|
|
|
|
// TODO: probably we should decide with something better here
|
|
|
|
this.context.router.push('/');
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-05-02 23:02:03 +05:30
|
|
|
render() {
|
2016-05-20 10:44:14 +05:30
|
|
|
const {params: {step, code}} = this.props;
|
|
|
|
|
2016-05-02 23:02:03 +05:30
|
|
|
return (
|
|
|
|
<ChangeEmail form={this.form}
|
|
|
|
onSubmit={this.onSubmit}
|
|
|
|
email={this.props.email}
|
2016-05-20 10:44:14 +05:30
|
|
|
step={step ? step.slice(-1) * 1 - 1 : step}
|
|
|
|
onChangeStep={this.onChangeStep}
|
|
|
|
code={code}
|
2016-05-02 23:02:03 +05:30
|
|
|
/>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2016-05-20 10:44:14 +05:30
|
|
|
onChangeStep = (step) => {
|
|
|
|
this.context.router.push(`/profile/change-email/step${++step}`);
|
|
|
|
};
|
|
|
|
|
2016-05-02 23:02:03 +05:30
|
|
|
onSubmit = () => {
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
import { connect } from 'react-redux';
|
|
|
|
|
|
|
|
export default connect((state) => ({
|
|
|
|
email: state.user.email
|
|
|
|
}), {
|
|
|
|
})(ProfileChangeEmailPage);
|