0
Fork 0
mirror of https://github.com/TryGhost/Ghost.git synced 2025-02-24 23:48:13 -05:00

Added price to offers products

This commit is contained in:
Peter Zimon 2021-10-06 17:11:35 +02:00
parent 31e4b77525
commit 7d61e7fda1

View file

@ -1,5 +1,7 @@
import Controller, {inject as controller} from '@ember/controller'; import Controller, {inject as controller} from '@ember/controller';
import {action} from '@ember/object'; import {action} from '@ember/object';
import {getSymbol} from 'ghost-admin/utils/currency';
import {ghPriceAmount} from '../helpers/gh-price-amount';
import {inject as service} from '@ember/service'; import {inject as service} from '@ember/service';
import {task} from 'ember-concurrency-decorators'; import {task} from 'ember-concurrency-decorators';
import {tracked} from '@glimmer/tracking'; import {tracked} from '@glimmer/tracking';
@ -67,14 +69,31 @@ export default class OffersController extends Controller {
name: '' name: ''
}]; }];
this.products.forEach((product) => { this.products.forEach((product) => {
cadences.push({ let monthlyCurrency = getSymbol(product.monthlyPrice.currency);
label: `${product.name} - Monthly`, if (monthlyCurrency.length === 1) {
name: `${product.id}-month` cadences.push({
}); label: `${product.name} - Monthly (${monthlyCurrency}${ghPriceAmount(product.monthlyPrice.amount)})`,
cadences.push({ name: `${product.id}-month`
label: `${product.name} - Yearly`, });
name: `${product.id}-year` } else {
}); cadences.push({
label: `${product.name} - Monthly (${ghPriceAmount(product.monthlyPrice.amount)} ${monthlyCurrency})`,
name: `${product.id}-month`
});
}
let yearlyCurrency = getSymbol(product.yearlyPrice.currency);
if (yearlyCurrency.length === 1) {
cadences.push({
label: `${product.name} - Yearly (${yearlyCurrency}${ghPriceAmount(product.yearlyPrice.amount)})`,
name: `${product.id}-year`
});
} else {
cadences.push({
label: `${product.name} - Yearly (${ghPriceAmount(product.yearlyPrice.amount)} ${yearlyCurrency})`,
name: `${product.id}-year`
});
}
}); });
this.cadences = cadences; this.cadences = cadences;
} }