Skip to content

Commit

Permalink
Merge pull request #630 from meetfranz/fix-invite-screen
Browse files Browse the repository at this point in the history
Fix invite screen
  • Loading branch information
adlk committed Jan 30, 2018
2 parents 7618f51 + 682a54e commit 81c4e99
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 13 deletions.
25 changes: 15 additions & 10 deletions src/components/auth/Invite.js
Expand Up @@ -45,16 +45,16 @@ export default class Invite extends Component {
form = new Form({
fields: {
invite: [...Array(3).fill({
name: {
label: this.context.intl.formatMessage(messages.nameLabel),
// value: '',
placeholder: this.context.intl.formatMessage(messages.nameLabel),
},
email: {
label: this.context.intl.formatMessage(messages.emailLabel),
// value: '',
validators: [email],
placeholder: this.context.intl.formatMessage(messages.emailLabel),
fields: {
name: {
label: this.context.intl.formatMessage(messages.nameLabel),
placeholder: this.context.intl.formatMessage(messages.nameLabel),
},
email: {
label: this.context.intl.formatMessage(messages.emailLabel),
placeholder: this.context.intl.formatMessage(messages.emailLabel),
validators: [email],
},
},
})],
},
Expand All @@ -74,6 +74,10 @@ export default class Invite extends Component {
const { form } = this;
const { intl } = this.context;

const atLeastOneEmailAddress = form.$('invite')
.map(invite => invite.$('email').value)
.some(emailValue => emailValue.trim() !== '');

return (
<div className="auth__container auth__container--signup">
<form className="franz-form auth__form" onSubmit={e => this.submit(e)}>
Expand All @@ -96,6 +100,7 @@ export default class Invite extends Component {
<Button
type="submit"
className="auth__button"
disabled={!atLeastOneEmailAddress}
label={intl.formatMessage(messages.submitButtonLabel)}
/>
<Link
Expand Down
2 changes: 1 addition & 1 deletion src/helpers/validation-helpers.js
Expand Up @@ -13,7 +13,7 @@ export function email({ field }) {
isValid = true;
}

return [isValid, `${field.label} is not a valid email address`];
return [isValid, `${field.label} not valid`];
}

export function url({ field }) {
Expand Down
5 changes: 3 additions & 2 deletions src/lib/Form.js
Expand Up @@ -21,8 +21,9 @@ export default class DefaultForm extends Form {

options() {
return {
validateOnInit: false,
// validateOnBlur: true,
validateOnInit: false, // default: true
// validateOnBlur: true, // default: true
// validateOnChange: true // default: false
// // validationDebounceWait: {
// // trailing: true,
// // },
Expand Down

0 comments on commit 81c4e99

Please sign in to comment.