mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-12-22 10:21:36 +03:00
8b5b3aa734
refs https://github.com/TryGhost/Team/issues/1575 - Update usage of Tier to read monthly & yearly price & currency from top level - Updated usage of Tier to read benefit name from benefits[n], not from benefits[n].name Co-authored-by: Fabien "egg" O'Carroll <fabien@allou.is>
53 lines
1.3 KiB
JavaScript
53 lines
1.3 KiB
JavaScript
import Component from '@glimmer/component';
|
|
import {action} from '@ember/object';
|
|
import {getSymbol} from 'ghost-admin/utils/currency';
|
|
import {inject as service} from '@ember/service';
|
|
import {tracked} from '@glimmer/tracking';
|
|
|
|
export default class extends Component {
|
|
@service membersUtils;
|
|
@service ghostPaths;
|
|
@service ajax;
|
|
@service store;
|
|
@service config;
|
|
|
|
@tracked showTierModal = false;
|
|
|
|
get tier() {
|
|
return this.args.tier;
|
|
}
|
|
|
|
get showArchiveOption() {
|
|
return this.tier.type === 'paid' && !!this.tier.monthlyPrice;
|
|
}
|
|
|
|
get tierCurrency() {
|
|
if (this.isFreeTier) {
|
|
const firstPaidTier = this.args.tiers.find((tier) => {
|
|
return tier.type === 'paid';
|
|
});
|
|
return firstPaidTier?.currency || 'usd';
|
|
} else {
|
|
return this.tier?.currency;
|
|
}
|
|
}
|
|
|
|
get isPaidTier() {
|
|
return this.tier.type === 'paid';
|
|
}
|
|
|
|
get hasCurrencySymbol() {
|
|
const currencySymbol = getSymbol(this.tier?.monthlyPrice?.currency);
|
|
return currencySymbol?.length !== 3;
|
|
}
|
|
|
|
get isFreeTier() {
|
|
return this.tier.type === 'free';
|
|
}
|
|
|
|
@action
|
|
async openEditTier(tier) {
|
|
this.args.openEditTier(tier);
|
|
}
|
|
}
|