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
This commit is contained in:
Rishabh 2021-10-08 16:03:16 +05:30
parent fa89f42e70
commit 4bbbea29ed
3 changed files with 7 additions and 12 deletions

View File

@ -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);
}
}

View File

@ -29,6 +29,7 @@
@id="name"
@value={{this.offer.name}}
@input={{this.setOfferName}}
data-test-input="offer-name"
@class="gh-input" />
<GhErrorMessage @errors={{this.errors}} @property="name" />
<p>Will be shown to members on the Stripe Checkout page</p>
@ -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"
/>
<GhErrorMessage @errors={{this.errors}} @property="amount" />
</div>
</GhFormGroup>

View File

@ -18,8 +18,8 @@
<th class="gh-list-header gh-list-cellwidth-10"></th>
</tr>
{{#each this.offers as |offer|}}
<tr class="gh-list-row">
<LinkTo @route="offer" @model={{offer}} class="gh-list-data">
<tr class="gh-list-row" data-test-list="offers-list-item">
<LinkTo @route="offer" @model={{offer}} class="gh-list-data" data-test-list="offer-name">
<h3>{{offer.name}}</h3>
</LinkTo>
<LinkTo @route="offer" @model={{offer}} class="gh-list-data">