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 };

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

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

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

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

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

0 comments on commit ab33c44

Please sign in to comment.