diff options
author | 2018-01-30 12:41:42 +0100 | |
---|---|---|
committer | 2018-01-30 12:41:42 +0100 | |
commit | 25446bbdf8d0020b1adfe34e4f45c1a1eec6528e (patch) | |
tree | ce1716855f3501da31ec2994e6d9ddb3d7e3fa09 /src/components/auth/Invite.js | |
parent | Merge branch 'develop' into feature/invite-button (diff) | |
download | ferdium-app-25446bbdf8d0020b1adfe34e4f45c1a1eec6528e.tar.gz ferdium-app-25446bbdf8d0020b1adfe34e4f45c1a1eec6528e.tar.zst ferdium-app-25446bbdf8d0020b1adfe34e4f45c1a1eec6528e.zip |
Merge branch 'fix-invite-screen' into feature/invite-button
fix linitng errors
Diffstat (limited to 'src/components/auth/Invite.js')
-rw-r--r-- | src/components/auth/Invite.js | 39 |
1 files changed, 10 insertions, 29 deletions
diff --git a/src/components/auth/Invite.js b/src/components/auth/Invite.js index 1fe594d73..fa83837ac 100644 --- a/src/components/auth/Invite.js +++ b/src/components/auth/Invite.js | |||
@@ -30,16 +30,17 @@ const messages = defineMessages({ | |||
30 | id: 'invite.skip.label', | 30 | id: 'invite.skip.label', |
31 | defaultMessage: '!!!I want to do this later', | 31 | defaultMessage: '!!!I want to do this later', |
32 | }, | 32 | }, |
33 | noEmailAddresses: { | ||
34 | id: 'invite.error.noEmails', | ||
35 | defaultMessage: '!!!At least one email address is required', | ||
36 | } | ||
37 | }); | 33 | }); |
38 | 34 | ||
39 | @observer | 35 | @observer |
40 | export default class Invite extends Component { | 36 | export default class Invite extends Component { |
41 | static propTypes = { | 37 | static propTypes = { |
42 | onSubmit: PropTypes.func.isRequired, | 38 | onSubmit: PropTypes.func.isRequired, |
39 | from: PropTypes.string, | ||
40 | }; | ||
41 | |||
42 | static defaultProps = { | ||
43 | from: '/', | ||
43 | }; | 44 | }; |
44 | 45 | ||
45 | static contextTypes = { | 46 | static contextTypes = { |
@@ -58,8 +59,8 @@ export default class Invite extends Component { | |||
58 | label: this.context.intl.formatMessage(messages.emailLabel), | 59 | label: this.context.intl.formatMessage(messages.emailLabel), |
59 | placeholder: this.context.intl.formatMessage(messages.emailLabel), | 60 | placeholder: this.context.intl.formatMessage(messages.emailLabel), |
60 | validators: [email], | 61 | validators: [email], |
61 | } | 62 | }, |
62 | } | 63 | }, |
63 | })], | 64 | })], |
64 | }, | 65 | }, |
65 | }, this.context.intl); | 66 | }, this.context.intl); |
@@ -68,21 +69,6 @@ export default class Invite extends Component { | |||
68 | e.preventDefault(); | 69 | e.preventDefault(); |
69 | this.form.submit({ | 70 | this.form.submit({ |
70 | onSuccess: (form) => { | 71 | onSuccess: (form) => { |
71 | |||
72 | this.props.onSubmit({ | ||
73 | invites: form.values().invite, | ||
74 | from: this.props.from | ||
75 | }); | ||
76 | |||
77 | const atLeastOneEmailAddress = form.$('invite') | ||
78 | .map(invite => {return invite.$('email').value}) | ||
79 | .some(email => email.trim() !== '') | ||
80 | |||
81 | if (!atLeastOneEmailAddress) { | ||
82 | form.invalidate('no-email-addresses') | ||
83 | return | ||
84 | } | ||
85 | |||
86 | this.props.onSubmit({ invites: form.values().invite }); | 72 | this.props.onSubmit({ invites: form.values().invite }); |
87 | }, | 73 | }, |
88 | onError: () => {}, | 74 | onError: () => {}, |
@@ -95,8 +81,8 @@ export default class Invite extends Component { | |||
95 | const { from } = this.props; | 81 | const { from } = this.props; |
96 | 82 | ||
97 | const atLeastOneEmailAddress = form.$('invite') | 83 | const atLeastOneEmailAddress = form.$('invite') |
98 | .map(invite => {return invite.$('email').value}) | 84 | .map(invite => invite.$('email').value) |
99 | .some(email => email.trim() !== '') | 85 | .some(emailValue => emailValue.trim() !== ''); |
100 | 86 | ||
101 | return ( | 87 | return ( |
102 | <div className="auth__container auth__container--signup"> | 88 | <div className="auth__container auth__container--signup"> |
@@ -117,11 +103,6 @@ export default class Invite extends Component { | |||
117 | </div> | 103 | </div> |
118 | </div> | 104 | </div> |
119 | ))} | 105 | ))} |
120 | {form.error === 'no-email-addresses' && ( | ||
121 | <p className="franz-form__error invite-form__error"> | ||
122 | {intl.formatMessage(messages.noEmailAddresses)} | ||
123 | </p> | ||
124 | )} | ||
125 | <Button | 106 | <Button |
126 | type="submit" | 107 | type="submit" |
127 | className="auth__button" | 108 | className="auth__button" |
@@ -129,7 +110,7 @@ export default class Invite extends Component { | |||
129 | label={intl.formatMessage(messages.submitButtonLabel)} | 110 | label={intl.formatMessage(messages.submitButtonLabel)} |
130 | /> | 111 | /> |
131 | <Link | 112 | <Link |
132 | to={ !!from ? from : '/'} | 113 | to={from || '/'} |
133 | className="franz-form__button franz-form__button--secondary auth__button auth__button--skip" | 114 | className="franz-form__button franz-form__button--secondary auth__button auth__button--skip" |
134 | > | 115 | > |
135 | {intl.formatMessage(messages.skipButtonLabel)} | 116 | {intl.formatMessage(messages.skipButtonLabel)} |