Skip to content

Commit

Permalink
feat(App) Feature Invite Friends in Settings
Browse files Browse the repository at this point in the history
- MOVE form creation to `componentWillMount()`
- focus input field on `componentDidMount()`
  • Loading branch information
haraldox committed Feb 8, 2018
1 parent 2a25f02 commit ab33c44
Showing 1 changed file with 31 additions and 25 deletions.
56 changes: 31 additions & 25 deletions src/components/auth/Invite.js
Expand Up @@ -64,32 +64,38 @@ export default class Invite extends Component {


state = { showSuccessInfo: false }; state = { showSuccessInfo: false };


handlers = { componentWillMount() {
onChange: () => { const handlers = {
this.setState({ showSuccessInfo: false }); onChange: () => {
}, this.setState({ showSuccessInfo: false });
}; },

};
form = new Form({
fields: { this.form = new Form({
invite: [...Array(3).fill({ fields: {
fields: { invite: [...Array(3).fill({
name: { fields: {
label: this.context.intl.formatMessage(messages.nameLabel), name: {
placeholder: this.context.intl.formatMessage(messages.nameLabel), label: this.context.intl.formatMessage(messages.nameLabel),
handlers: this.handlers, placeholder: this.context.intl.formatMessage(messages.nameLabel),
// related: ['invite.0.email'], // path accepted but does not work handlers,
}, // related: ['invite.0.email'], // path accepted but does not work
email: { },
label: this.context.intl.formatMessage(messages.emailLabel), email: {
placeholder: this.context.intl.formatMessage(messages.emailLabel), label: this.context.intl.formatMessage(messages.emailLabel),
handlers: this.handlers, placeholder: this.context.intl.formatMessage(messages.emailLabel),
validators: [email], handlers,
validators: [email],
},
}, },
}, })],
})], },
}, }, this.context.intl);
}, this.context.intl); }

componentDidMount() {
document.querySelector('input:first-child').focus();
}


submit(e) { submit(e) {
e.preventDefault(); e.preventDefault();
Expand Down

0 comments on commit ab33c44

Please sign in to comment.