Use early return instead of else

[MAILPOET-3848]
This commit is contained in:
Jan Lysý
2021-10-14 08:58:31 +02:00
committed by Veljko V
parent dccfc98792
commit 4f58fa52d7
2 changed files with 66 additions and 64 deletions

View File

@@ -86,7 +86,8 @@ class EventsConditions extends React.Component {
e.preventDefault();
if (!this.isValid()) {
this.validate();
} else {
return;
}
const { history } = this.props;
const {
eventSlug, afterTimeType, afterTimeNumber, event, segment, eventOptionValue,
@@ -131,7 +132,6 @@ class EventsConditions extends React.Component {
}
});
}
}
getEvent(eventSlug) {
return this.emailEvents[eventSlug];

View File

@@ -51,8 +51,9 @@ class NewsletterWelcome extends React.Component {
handleNext(event) {
event.preventDefault();
if (!this.isValid()) {
jQuery('#welcome_scheduling').parsley().validate();
} else {
this.validate();
return;
}
MailPoet.Ajax.post({
api_version: window.mailpoet_api_version,
endpoint: 'newsletters',
@@ -72,10 +73,11 @@ class NewsletterWelcome extends React.Component {
}
});
}
}
isValid = () => jQuery('#welcome_scheduling').parsley().isValid();
validate = () => jQuery('#welcome_scheduling').parsley().validate();
showTemplateSelection(newsletterId) {
this.props.history.push(`/template/${newsletterId}`);
}