mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-11-28 14:03:48 +03:00
86b55b0f81
refs https://github.com/TryGhost/Team/issues/1037 Adds new free tier card with option to add custom description and benefits for free tier, behind the tiers beta flag. Also: - updates formatting of tier prices - changes "Free" section to "Default" - updates price formatting of membership tiers in admin - updates currency code handling for product card - updates default paid product handling Co-authored-by: Djordje Vlaisavljevic <dzvlais@gmail.com> Co-authored-by: Peter Zimon <peter.zimon@gmail.com>
80 lines
2.1 KiB
JavaScript
80 lines
2.1 KiB
JavaScript
import Controller from '@ember/controller';
|
|
import {action} from '@ember/object';
|
|
import {inject as service} from '@ember/service';
|
|
import {task} from 'ember-concurrency-decorators';
|
|
import {tracked} from '@glimmer/tracking';
|
|
|
|
const TYPES = [{
|
|
name: 'Active',
|
|
value: 'active'
|
|
},{
|
|
name: 'Archived',
|
|
value: 'archived'
|
|
}];
|
|
|
|
export default class MembersController extends Controller {
|
|
@service modals;
|
|
@service router;
|
|
|
|
@tracked offers = [];
|
|
@tracked products = [];
|
|
@tracked type = 'active';
|
|
|
|
queryParams = [
|
|
'type'
|
|
];
|
|
|
|
constructor() {
|
|
super(...arguments);
|
|
this.availableTypes = TYPES;
|
|
}
|
|
|
|
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;
|
|
});
|
|
}
|
|
|
|
get offersExist() {
|
|
return this.offers.length > 0;
|
|
}
|
|
|
|
get selectedType() {
|
|
return this.type ? TYPES.find((d) => {
|
|
return this.type === d.value;
|
|
}) : TYPES[0];
|
|
}
|
|
|
|
@action
|
|
onTypeChange(type) {
|
|
this.type = type.value;
|
|
}
|
|
|
|
@action
|
|
openLinkDialog(offer) {
|
|
this.advancedModal = this.modals.open('modals/offers/link', {
|
|
offer: offer
|
|
}, {
|
|
className: 'fullscreen-modal-action fullscreen-modal-wide'
|
|
});
|
|
}
|
|
|
|
@task({restartable: true})
|
|
*fetchOffersTask() {
|
|
this.products = yield this.store.query('product', {
|
|
filter: 'type:paid', include: 'monthly_price,yearly_price'
|
|
});
|
|
this.offers = yield this.store.query('offer', {limit: 'all'});
|
|
return this.offers;
|
|
}
|
|
}
|