Ghost/ghost/admin/app/components/gh-tier-card.js
Peter Zimon 1b6b905dcd Added free trial indicator to tier card in Admin
refs. https://github.com/TryGhost/Team/issues/1806

- free trial indicator - which helps users identify tiers easier - was missing on tier cards in Settings / Membership in the Admin
2022-08-16 14:15:31 +02:00

61 lines
1.4 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';
}
get isFreeTrialEnabled() {
return this.tier.trialDays > 0;
}
get tierTrialDays() {
return this.tier.trialDays;
}
@action
async openEditTier(tier) {
this.args.openEditTier(tier);
}
}