2016-05-02 16:13:18 +03:00
|
|
|
import React, { Component, PropTypes } from 'react';
|
|
|
|
|
|
|
|
import { FormattedMessage as Message } from 'react-intl';
|
|
|
|
import Helmet from 'react-helmet';
|
|
|
|
|
|
|
|
import { Input, Button, Form, FormModel } from 'components/ui/form';
|
2016-05-26 17:51:17 +03:00
|
|
|
import { BackButton } from 'components/profile/ProfileForm';
|
2016-05-02 16:13:18 +03:00
|
|
|
import styles from 'components/profile/profileForm.scss';
|
2016-05-02 20:32:03 +03:00
|
|
|
|
2016-05-22 10:53:40 +03:00
|
|
|
import messages from './ChangeUsername.intl.json';
|
2016-05-02 16:13:18 +03:00
|
|
|
|
|
|
|
export default class ChangeUsername extends Component {
|
|
|
|
static displayName = 'ChangeUsername';
|
|
|
|
|
|
|
|
static propTypes = {
|
|
|
|
username: PropTypes.string.isRequired,
|
|
|
|
form: PropTypes.instanceOf(FormModel),
|
|
|
|
onChange: PropTypes.func.isRequired,
|
|
|
|
onSubmit: PropTypes.func.isRequired
|
|
|
|
};
|
|
|
|
|
|
|
|
static get defaultProps() {
|
|
|
|
return {
|
|
|
|
form: new FormModel()
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
render() {
|
|
|
|
const {form, username} = this.props;
|
|
|
|
|
|
|
|
return (
|
|
|
|
<Form onSubmit={this.onFormSubmit}
|
|
|
|
form={form}
|
|
|
|
>
|
|
|
|
<div className={styles.contentWithBackButton}>
|
2016-05-26 17:51:17 +03:00
|
|
|
<BackButton />
|
2016-05-02 16:13:18 +03:00
|
|
|
|
|
|
|
<div className={styles.form}>
|
|
|
|
<div className={styles.formBody}>
|
|
|
|
<Message {...messages.changeUsernameTitle}>
|
|
|
|
{(pageTitle) => (
|
|
|
|
<h3 className={styles.title}>
|
|
|
|
<Helmet title={pageTitle} />
|
|
|
|
{pageTitle}
|
|
|
|
</h3>
|
|
|
|
)}
|
|
|
|
</Message>
|
|
|
|
|
|
|
|
<div className={styles.formRow}>
|
|
|
|
<p className={styles.description}>
|
|
|
|
<Message {...messages.changeUsernameDescription} />
|
|
|
|
</p>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<div className={styles.formRow}>
|
|
|
|
<Input {...form.bindField('username')}
|
|
|
|
value={username}
|
|
|
|
onChange={this.onUsernameChange}
|
|
|
|
required
|
|
|
|
skin="light"
|
|
|
|
/>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<div className={styles.formRow}>
|
|
|
|
<p className={styles.description}>
|
|
|
|
<Message {...messages.changeUsernameWarning} />
|
|
|
|
</p>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
|
2016-05-27 23:04:17 +03:00
|
|
|
<Button color="green" block label={messages.changeUsernameButton} type="submit" />
|
2016-05-02 16:13:18 +03:00
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</Form>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
onUsernameChange = (event) => {
|
|
|
|
this.props.onChange(event.target.value);
|
|
|
|
};
|
|
|
|
|
|
|
|
onFormSubmit = () => {
|
|
|
|
this.props.onSubmit(this.props.form);
|
|
|
|
};
|
|
|
|
}
|