From bc174ee358f61f23149f84508ddb210d98cc458d Mon Sep 17 00:00:00 2001 From: tudinhtu98 Date: Mon, 13 Feb 2023 11:47:29 +0700 Subject: [PATCH] Refactor: No need export action on subscribe-show --- .../discourse/components/subscribe-google-pay.js | 10 +++++----- .../discourse/controllers/subscribe-show.js | 9 --------- .../javascripts/discourse/templates/subscribe/show.hbs | 6 +++--- 3 files changed, 8 insertions(+), 17 deletions(-) diff --git a/assets/javascripts/discourse/components/subscribe-google-pay.js b/assets/javascripts/discourse/components/subscribe-google-pay.js index 2d4740d..805cd37 100644 --- a/assets/javascripts/discourse/components/subscribe-google-pay.js +++ b/assets/javascripts/discourse/components/subscribe-google-pay.js @@ -79,28 +79,28 @@ export default Component.extend({ if (authenticationResult && !authenticationResult.error) { return Transaction.finalize(transactionId, planId).then( () => { - this.advanceSuccessfulTransaction(plan); + this._advanceSuccessfulTransaction(plan); e.complete("success"); console.log(`Success: ${authenticationResult.paymentIntent.id}`); } ); } else if (authenticationResult.error) { - console.log("Payment fail"); + console.log("Payment fail", authenticationResult.error); e.complete("fail"); } } ); } else { - this.advanceSuccessfulTransaction(plan); + this._advanceSuccessfulTransaction(plan); e.complete("success"); console.log(`Success`); } }) .catch((result) => { e.complete("fail"); - console.log("Payment fail"); + console.log("Catch Payment fail"); this.dialog.alert( - result.jqXHR.responseJSON?.errors[0] || result.errorThrown + result.jqXHR?.responseJSON?.errors[0] || result.errorThrown ); }); diff --git a/assets/javascripts/discourse/controllers/subscribe-show.js b/assets/javascripts/discourse/controllers/subscribe-show.js index 7f07cb8..e6ca002 100644 --- a/assets/javascripts/discourse/controllers/subscribe-show.js +++ b/assets/javascripts/discourse/controllers/subscribe-show.js @@ -83,15 +83,6 @@ export default Controller.extend({ }, actions: { - alert(path) { - this.alert(path) - }, - handleAuthentication(plan, transaction) { - this.handleAuthentication(plan, transaction) - }, - advanceSuccessfulTransaction(plan) { - this._advanceSuccessfulTransaction(plan) - }, stripePaymentHandler() { this.set("loading", true); const plan = this.get("model.plans") diff --git a/assets/javascripts/discourse/templates/subscribe/show.hbs b/assets/javascripts/discourse/templates/subscribe/show.hbs index 595aabc..7c252af 100644 --- a/assets/javascripts/discourse/templates/subscribe/show.hbs +++ b/assets/javascripts/discourse/templates/subscribe/show.hbs @@ -46,13 +46,13 @@ }} {{subscribe-google-pay - alert=alert stripe=stripe plans=model.plans selectedPlan=selectedPlan promoCode=promoCode - advanceSuccessfulTransaction=(action "advanceSuccessfulTransaction") - handleAuthentication=(action "handleAuthentication") + alert=alert + _advanceSuccessfulTransaction=_advanceSuccessfulTransaction + handleAuthentication=handleAuthentication }} {{/if}}