From 6f87f11e4a308b4b7a9e7ce36dbb5e5caa799b56 Mon Sep 17 00:00:00 2001 From: Rimian Perkins Date: Thu, 12 Sep 2019 18:16:47 +1000 Subject: [PATCH] currency format helper --- README.md | 2 ++ .../discourse/helpers/format-curency.js.es6 | 16 ++++++++++++++++ .../templates/components/donation-form.hbs | 4 ++-- .../templates/components/stripe-card.hbs | 2 +- config/locales/client.en.yml | 6 +++--- 5 files changed, 24 insertions(+), 6 deletions(-) create mode 100644 assets/javascripts/discourse/helpers/format-curency.js.es6 diff --git a/README.md b/README.md index 443caa9..6791940 100644 --- a/README.md +++ b/README.md @@ -44,5 +44,7 @@ Many thanks to Chris Beach and Angus McLeod who helped on the previous version o * Format the currency * Check against other themes * Add billing info to confirm dialog +* Confirm dialog heading * Validate the model properly. Not in the stripe component * Show the transaction on the thank you page. +* Work out where to put the helper tests. Name collision! diff --git a/assets/javascripts/discourse/helpers/format-curency.js.es6 b/assets/javascripts/discourse/helpers/format-curency.js.es6 new file mode 100644 index 0000000..ba077b5 --- /dev/null +++ b/assets/javascripts/discourse/helpers/format-curency.js.es6 @@ -0,0 +1,16 @@ +export default Ember.Helper.helper(function(params) { + let currencySign; + + switch (Discourse.SiteSettings.discourse_patrons_currency) { + case 'EUR': + currencySign = "€"; + break; + case 'GBP': + currencySign = "£"; + break; + default: + currencySign = "$"; + } + + return [currencySign, params[0]].join(''); +}); diff --git a/assets/javascripts/discourse/templates/components/donation-form.hbs b/assets/javascripts/discourse/templates/components/donation-form.hbs index a34e185..594270b 100644 --- a/assets/javascripts/discourse/templates/components/donation-form.hbs +++ b/assets/javascripts/discourse/templates/components/donation-form.hbs @@ -5,7 +5,7 @@ - + @@ -17,7 +17,7 @@ diff --git a/assets/javascripts/discourse/templates/components/stripe-card.hbs b/assets/javascripts/discourse/templates/components/stripe-card.hbs index 724a245..48ff7c4 100644 --- a/assets/javascripts/discourse/templates/components/stripe-card.hbs +++ b/assets/javascripts/discourse/templates/components/stripe-card.hbs @@ -3,7 +3,7 @@
{{#d-button action="submitStripeCard" class="btn btn-primary btn-payment btn-discourse-patrons"}} - {{i18n 'discourse_patrons.buttons.make_payment'}}{{amount}} + {{i18n 'discourse_patrons.buttons.make_payment'}} {{format-curency amount}} {{/d-button}} {{#if cardError}} diff --git a/config/locales/client.en.yml b/config/locales/client.en.yml index 4ca0c14..11192b0 100644 --- a/config/locales/client.en.yml +++ b/config/locales/client.en.yml @@ -27,9 +27,9 @@ en: email: Email phone: Phone Number confirmation: - amount: Amount $ + amount: Amount last4: Card number buttons: - make_payment: Make payment $ - confirm_payment: Confirm payment $ + make_payment: Make payment + confirm_payment: Confirm payment success: Go back
{{i18n 'discourse_patrons.confirmation.amount'}}{{amount}}{{format-curency amount}}
{{i18n 'discourse_patrons.confirmation.last4'}}