Ghost/ghost/admin/app/components/gh-tier-card.js
Hannah Wolfe affe6743e5 Renamed products to tiers (#2372)
refs: https://github.com/TryGhost/Team/issues/1145

- this should allow us to remove the /products endpoint in v5

It avoids:

- `kg-product-card`, that really is meant to say product
- `product-cadence` on offers

Co-authored-by: Rishabh <zrishabhgarg@gmail.com>
2022-05-11 22:41:54 +05:30

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?.monthlyPrice?.currency || 'usd';
} else {
return this.tier?.monthlyPrice?.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);
}
}