From 4bbbea29ed00485faecbde3281be2235fc9a8966 Mon Sep 17 00:00:00 2001 From: Rishabh Date: Fri, 8 Oct 2021 16:03:16 +0530 Subject: [PATCH] Refined fixed discount type amount UI refs https://github.com/TryGhost/Team/issues/1084 refs https://github.com/TryGhost/Team/issues/1085 - uses price helper to show Stripe amount instead of manual calculation --- ghost/admin/app/controllers/offer.js | 9 +-------- ghost/admin/app/templates/offer.hbs | 6 ++++-- ghost/admin/app/templates/offers.hbs | 4 ++-- 3 files changed, 7 insertions(+), 12 deletions(-) diff --git a/ghost/admin/app/controllers/offer.js b/ghost/admin/app/controllers/offer.js index 1c2e631542..493d8d190a 100644 --- a/ghost/admin/app/controllers/offer.js +++ b/ghost/admin/app/controllers/offer.js @@ -69,13 +69,6 @@ export default class OffersController extends Controller { }; } - get discountVal() { - if (this.offer?.type === 'fixed' && typeof this.offer?.amount === 'number') { - return (this.offer?.amount / 100); - } - return this.offer?.amount; - } - get cadence() { if (this.offer.tier && this.offer.cadence) { return `${this.offer.tier.id}-${this.offer.cadence}`; @@ -114,7 +107,7 @@ export default class OffersController extends Controller { }); this.cadences = cadences; if (this.offer && !this.offer.tier) { - this.updateCadence(this.cadences[0].name); + this.updateCadence(this.cadences[0]?.name); } } diff --git a/ghost/admin/app/templates/offer.hbs b/ghost/admin/app/templates/offer.hbs index f4ddf727d6..67ac2e8c5f 100644 --- a/ghost/admin/app/templates/offer.hbs +++ b/ghost/admin/app/templates/offer.hbs @@ -29,6 +29,7 @@ @id="name" @value={{this.offer.name}} @input={{this.setOfferName}} + data-test-input="offer-name" @class="gh-input" />

Will be shown to members on the Stripe Checkout page

@@ -62,10 +63,11 @@ @type="number" @placeholder="" @disabled={{this.isDiscountSectionDisabled}} - @value={{readonly this.discountVal}} + @value={{readonly (gh-price-amount this.offer.amount)}} @input={{this.setDiscountAmount}} @id="amount" - @class="gh-input" /> + @class="gh-input" + /> diff --git a/ghost/admin/app/templates/offers.hbs b/ghost/admin/app/templates/offers.hbs index 2993c00e16..183b8e0f7e 100644 --- a/ghost/admin/app/templates/offers.hbs +++ b/ghost/admin/app/templates/offers.hbs @@ -18,8 +18,8 @@ {{#each this.offers as |offer|}} - - + +

{{offer.name}}