2021-10-04 14:01:12 +03:00
|
|
|
import Controller from '@ember/controller';
|
|
|
|
import {action} from '@ember/object';
|
2021-10-04 16:00:41 +03:00
|
|
|
import {inject as service} from '@ember/service';
|
|
|
|
import {task} from 'ember-concurrency-decorators';
|
|
|
|
import {tracked} from '@glimmer/tracking';
|
2021-10-04 14:01:12 +03:00
|
|
|
|
|
|
|
export default class MembersController extends Controller {
|
2021-10-04 16:00:41 +03:00
|
|
|
@service config;
|
|
|
|
@service settings;
|
|
|
|
@service store;
|
|
|
|
@tracked cadences = [];
|
|
|
|
@tracked products = [];
|
|
|
|
@tracked selectedDiscountType = 'percentage';
|
|
|
|
|
|
|
|
constructor() {
|
|
|
|
super(...arguments);
|
|
|
|
this.setup();
|
|
|
|
}
|
|
|
|
|
|
|
|
@task({drop: true})
|
|
|
|
*fetchProducts() {
|
|
|
|
this.products = yield this.store.query('product', {include: 'monthly_price,yearly_price,benefits'});
|
|
|
|
const cadences = [];
|
|
|
|
this.products.forEach((product) => {
|
|
|
|
cadences.push({
|
|
|
|
label: `${product.name} - Monthly`,
|
|
|
|
name: product.monthlyPrice.id
|
|
|
|
});
|
|
|
|
cadences.push({
|
|
|
|
label: `${product.name} - Yearly`,
|
|
|
|
name: product.yearlyPrice.id
|
|
|
|
});
|
|
|
|
});
|
|
|
|
this.cadences = cadences;
|
|
|
|
}
|
|
|
|
|
|
|
|
@action
|
|
|
|
setup() {
|
|
|
|
this.fetchProducts.perform();
|
|
|
|
}
|
|
|
|
|
|
|
|
@action
|
|
|
|
setDiscountType(discountType) {
|
|
|
|
this.selectedDiscountType = discountType;
|
|
|
|
}
|
|
|
|
|
2021-10-04 14:01:12 +03:00
|
|
|
@action
|
2021-10-04 16:00:41 +03:00
|
|
|
updateVisibility(tab) {
|
|
|
|
this.tab = tab;
|
|
|
|
}
|
2021-10-04 14:01:12 +03:00
|
|
|
}
|