2022-05-11 20:11:54 +03:00
|
|
|
import Component from '@glimmer/component';
|
|
|
|
import {action} from '@ember/object';
|
|
|
|
import {getSymbol} from 'ghost-admin/utils/currency';
|
2022-11-03 14:14:36 +03:00
|
|
|
import {inject} from 'ghost-admin/decorators/inject';
|
2022-05-11 20:11:54 +03:00
|
|
|
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;
|
2022-11-03 14:14:36 +03:00
|
|
|
|
|
|
|
@inject config;
|
2022-05-11 20:11:54 +03:00
|
|
|
|
|
|
|
@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';
|
|
|
|
});
|
2022-05-16 21:51:49 +03:00
|
|
|
return firstPaidTier?.currency || 'usd';
|
2022-05-11 20:11:54 +03:00
|
|
|
} else {
|
2022-05-16 21:51:49 +03:00
|
|
|
return this.tier?.currency;
|
2022-05-11 20:11:54 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
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';
|
|
|
|
}
|
|
|
|
|
2022-08-16 15:15:31 +03:00
|
|
|
get isFreeTrialEnabled() {
|
|
|
|
return this.tier.trialDays > 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
get tierTrialDays() {
|
|
|
|
return this.tier.trialDays;
|
|
|
|
}
|
|
|
|
|
2022-05-11 20:11:54 +03:00
|
|
|
@action
|
|
|
|
async openEditTier(tier) {
|
|
|
|
this.args.openEditTier(tier);
|
|
|
|
}
|
|
|
|
}
|