2022-01-17 21:53:43 +03:00
|
|
|
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';
|
2022-02-01 12:34:03 +03:00
|
|
|
|
2022-01-17 21:53:43 +03:00
|
|
|
export default class extends Component {
|
|
|
|
@service membersUtils;
|
|
|
|
@service ghostPaths;
|
|
|
|
@service ajax;
|
|
|
|
@service store;
|
|
|
|
@service config;
|
|
|
|
|
|
|
|
@tracked showProductModal = false;
|
|
|
|
|
|
|
|
get product() {
|
|
|
|
return this.args.product;
|
|
|
|
}
|
|
|
|
|
2022-02-02 14:04:51 +03:00
|
|
|
get showArchiveOption() {
|
|
|
|
return this.product.type === 'paid' && !!this.product.monthlyPrice;
|
|
|
|
}
|
|
|
|
|
2022-01-19 10:34:08 +03:00
|
|
|
get productCurrency() {
|
|
|
|
if (this.isFreeProduct) {
|
|
|
|
const firstPaidProduct = this.args.products.find((product) => {
|
|
|
|
return product.type === 'paid';
|
|
|
|
});
|
|
|
|
return firstPaidProduct?.monthlyPrice?.currency || 'usd';
|
|
|
|
} else {
|
|
|
|
return this.product?.monthlyPrice?.currency;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-01-17 21:53:43 +03:00
|
|
|
get isPaidProduct() {
|
|
|
|
return this.product.type === 'paid';
|
|
|
|
}
|
|
|
|
|
|
|
|
get hasCurrencySymbol() {
|
|
|
|
const currencySymbol = getSymbol(this.product?.monthlyPrice?.currency);
|
|
|
|
return currencySymbol?.length !== 3;
|
|
|
|
}
|
|
|
|
|
|
|
|
get isFreeProduct() {
|
|
|
|
return this.product.type === 'free';
|
|
|
|
}
|
|
|
|
|
|
|
|
@action
|
|
|
|
async openEditProduct(product) {
|
|
|
|
this.args.openEditProduct(product);
|
|
|
|
}
|
|
|
|
}
|