Permalink
Browse files

feat(App) Feature Invite Friends in Settings

- MOVE form creation to `componentWillMount()`
- focus input field on `componentDidMount()`
  • Loading branch information...
haraldox committed Feb 8, 2018
1 parent 2a25f02 commit ab33c44bbb4ffad2cdfcad76d3cd26f1444e27cd
Showing with 31 additions and 25 deletions.
  1. +31 −25 src/components/auth/Invite.js
@@ -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();

0 comments on commit ab33c44

Please sign in to comment.