diff --git a/assets/javascripts/discourse/routes/donate.js.es6 b/assets/javascripts/discourse/routes/donate.js.es6 index 04d7994..4a52b8c 100644 --- a/assets/javascripts/discourse/routes/donate.js.es6 +++ b/assets/javascripts/discourse/routes/donate.js.es6 @@ -1,8 +1,16 @@ import DiscourseRoute from "discourse/routes/discourse"; +import DiscourseURL from 'discourse/lib/url'; import { popupAjaxError } from 'discourse/lib/ajax-error'; import { ajax } from 'discourse/lib/ajax'; export default DiscourseRoute.extend({ + redirect() { + if (!Discourse.SiteSettings.discourse_donations_enabled) { + DiscourseURL.routeTo('/'); + return; + } + }, + setupController(controller) { let charges = []; let subscriptions = []; @@ -10,7 +18,7 @@ export default DiscourseRoute.extend({ controller.set('loadingDonations', true); - ajax('/donate/charges').then((result) => { + ajax('/donate/charges').then((result) => { if (result) { charges = result.charges; subscriptions = result.subscriptions; @@ -24,6 +32,6 @@ export default DiscourseRoute.extend({ }); }).catch(popupAjaxError).finally(() => { controller.set('loadingDonations', false); - }) + }); } });