Skip to content

Commit

Permalink
alternative UX implementation of check for email address count > 0
Browse files Browse the repository at this point in the history
comment out line 122 to test
  • Loading branch information
haraldox committed Jan 19, 2018
1 parent 3692bd8 commit 5652096
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 0 deletions.
19 changes: 19 additions & 0 deletions src/components/auth/Invite.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,10 @@ const messages = defineMessages({
id: 'invite.skip.label',
defaultMessage: '!!!I want to do this later',
},
noEmailAddresses: {
id: 'invite.error.noEmails',
defaultMessage: '!!!At least one email address is required',
}
});

@observer
Expand Down Expand Up @@ -64,6 +68,16 @@ export default class Invite extends Component {
e.preventDefault();
this.form.submit({
onSuccess: (form) => {

const atLeastOneEmailAddress = form.$('invite')
.map(invite => {return invite.$('email').value})
.some(email => email.trim() !== '')

if (!atLeastOneEmailAddress) {
form.invalidate('no-email-addresses')
return
}

this.props.onSubmit({ invites: form.values().invite });
},
onError: () => {},
Expand Down Expand Up @@ -97,6 +111,11 @@ export default class Invite extends Component {
</div>
</div>
))}
{form.error === 'no-email-addresses' && (
<p className="franz-form__error invite-form__error">
{intl.formatMessage(messages.noEmailAddresses)}
</p>
)}
<Button
type="submit"
className="auth__button"
Expand Down
1 change: 1 addition & 0 deletions src/i18n/locales/en-US.json
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@
"invite.name.label": "Name",
"invite.email.label": "Email address",
"invite.skip.label": "I want to do this later",
"invite.error.noEmails": "At least one email address is required",
"subscription.submit.label": "I want to support the development of Franz",
"subscription.paymentSessionError": "Could not initialize payment form",
"subscription.includedFeatures": "Paid Franz Premium Supporter Account includes",
Expand Down
4 changes: 4 additions & 0 deletions src/styles/invite.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
.invite-form__error {
text-align: center;
margin-bottom: 20px !important; /* otherwise overridden by rule: p:last-of-type */
}
1 change: 1 addition & 0 deletions src/styles/main.scss
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ $mdi-font-path: '../node_modules/mdi/fonts';
@import './type.scss';
@import './welcome.scss';
@import './auth.scss';
@import './invite.scss';
@import './tooltip.scss';
@import './info-bar.scss';
@import './status-bar-target-url.scss';
Expand Down

0 comments on commit 5652096

Please sign in to comment.