Fix: Cannot read property 'showError' of undefined

[MAILPOET-1352]
This commit is contained in:
Pavel Dohnal
2018-04-24 12:33:11 +01:00
parent ed8c75dd06
commit f64cf728fe

View File

@@ -87,9 +87,13 @@ const NewsletterSend = React.createClass({
body: JSON.stringify(response.data.body), body: JSON.stringify(response.data.body),
categories: '["recent"]', categories: '["recent"]',
}, },
}).then(done).fail(this.showError); }).then(done).fail((err) => {
this.showError(err);
});
}) })
.catch(err => this.showError({ errors: [err] })); .catch((err) => {
this.showError({ errors: [err] });
});
}, },
handleSend: function handleSend(e) { handleSend: function handleSend(e) {
e.preventDefault(); e.preventDefault();
@@ -236,7 +240,9 @@ const NewsletterSend = React.createClass({
} }
}); });
}) })
.fail(this.showError) .fail((err) => {
this.showError(err);
})
.always(() => { .always(() => {
this.setState({ loading: false }); this.setState({ loading: false });
}); });
@@ -252,7 +258,9 @@ const NewsletterSend = React.createClass({
); );
}).done(() => { }).done(() => {
this.context.router.push(`/${this.state.item.type || ''}`); this.context.router.push(`/${this.state.item.type || ''}`);
}).fail(this.showError); }).fail((err) => {
this.showError(err);
});
}, },
handleRedirectToDesign: function handleRedirectToDesign(e) { handleRedirectToDesign: function handleRedirectToDesign(e) {
e.preventDefault(); e.preventDefault();
@@ -264,7 +272,9 @@ const NewsletterSend = React.createClass({
); );
}).done(() => { }).done(() => {
window.location = redirectTo; window.location = redirectTo;
}).fail(this.showError); }).fail((err) => {
this.showError(err);
});
}, },
saveNewsletter: function saveNewsletter() { saveNewsletter: function saveNewsletter() {
const data = this.state.item; const data = this.state.item;