mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-11-25 09:03:12 +03:00
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:
parent
27b7bcebac
commit
b015ac4d42
@ -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;
|
||||
}
|
||||
}
|
||||
|
@ -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>
|
||||
|
Loading…
Reference in New Issue
Block a user