Added price list to offer list screen

refs https://github.com/TryGhost/Team/issues/1162

- adds original and updated price for an offer in offer list table
This commit is contained in:
Rishabh 2021-10-20 17:19:16 +05:30
parent 27b7bcebac
commit b015ac4d42
2 changed files with 13 additions and 1 deletions

View File

@ -17,6 +17,7 @@ export default class MembersController extends Controller {
@service router;
@tracked offers = [];
@tracked products = [];
@tracked type = 'active';
queryParams = [
@ -31,6 +32,15 @@ export default class MembersController extends Controller {
get filteredOffers() {
return this.offers.filter((offer) => {
return offer.status === this.type;
}).map((offer) => {
const product = this.products.find((p) => {
return p.id === offer.tier.id;
});
const price = offer.cadence === 'month' ? product.monthlyPrice : product.yearlyPrice;
offer.finalCurrency = offer.currency || price.currency;
offer.originalPrice = price.amount;
offer.updatedPrice = offer.type === 'fixed' ? (price.amount - offer.amount) : (price.amount - ((price.amount * offer.amount) / 100));
return offer;
});
}
@ -60,6 +70,8 @@ export default class MembersController extends Controller {
@task({restartable: true})
*fetchOffersTask() {
this.products = yield this.store.query('product', {include: 'monthly_price,yearly_price'});
this.offers = yield this.store.query('offer', {limit: 'all'});
return this.offers;
}
}

View File

@ -64,7 +64,7 @@
</span>
</LinkTo>
<LinkTo @route="offer" @model={{offer}} class="gh-list-data">
<span class="midgrey strike mr2">$32</span> <span>$25.6</span>
<span class="midgrey strike mr2">{{currency-symbol offer.finalCurrency}}{{gh-price-amount offer.originalPrice}}</span> <span>{{currency-symbol offer.finalCurrency}}{{gh-price-amount offer.updatedPrice}}</span>
</LinkTo>
<LinkTo @route="offer" @model={{offer}} class="gh-list-data">
<span class="midgrey">{{offer.redemptionCount}}</span>