2021-10-04 14:01:12 +03:00
|
|
|
import Controller from '@ember/controller';
|
2021-10-08 06:58:17 +03:00
|
|
|
import {action} from '@ember/object';
|
|
|
|
import {inject as service} from '@ember/service';
|
2021-10-06 17:29:15 +03:00
|
|
|
import {task} from 'ember-concurrency-decorators';
|
2021-10-04 14:55:17 +03:00
|
|
|
import {tracked} from '@glimmer/tracking';
|
2021-10-04 14:01:12 +03:00
|
|
|
|
2021-10-13 18:53:21 +03:00
|
|
|
const TYPES = [{
|
|
|
|
name: 'Active',
|
|
|
|
value: 'active'
|
|
|
|
},{
|
|
|
|
name: 'Archived',
|
|
|
|
value: 'archived'
|
|
|
|
}];
|
|
|
|
|
2021-10-04 14:55:17 +03:00
|
|
|
export default class MembersController extends Controller {
|
2021-10-08 06:58:17 +03:00
|
|
|
@service modals;
|
2021-10-13 18:53:21 +03:00
|
|
|
@service router;
|
|
|
|
|
|
|
|
@tracked offers = [];
|
|
|
|
@tracked type = 'active';
|
|
|
|
|
|
|
|
queryParams = [
|
|
|
|
'type'
|
|
|
|
];
|
2021-10-06 17:29:15 +03:00
|
|
|
|
|
|
|
constructor() {
|
|
|
|
super(...arguments);
|
2021-10-13 18:53:21 +03:00
|
|
|
this.availableTypes = TYPES;
|
|
|
|
}
|
|
|
|
|
|
|
|
get filteredOffers() {
|
|
|
|
return this.offers.filter((offer) => {
|
|
|
|
return offer.status === this.type;
|
|
|
|
});
|
2021-10-06 17:29:15 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
get offersExist() {
|
|
|
|
return this.offers.length > 0;
|
|
|
|
}
|
|
|
|
|
2021-10-13 18:53:21 +03:00
|
|
|
get selectedType() {
|
|
|
|
return this.type ? TYPES.find((d) => {
|
|
|
|
return this.type === d.value;
|
|
|
|
}) : TYPES[0];
|
|
|
|
}
|
|
|
|
|
|
|
|
@action
|
|
|
|
onTypeChange(type) {
|
|
|
|
this.type = type.value;
|
|
|
|
}
|
|
|
|
|
2021-10-08 06:58:17 +03:00
|
|
|
@action
|
|
|
|
openLinkDialog(offer) {
|
|
|
|
this.advancedModal = this.modals.open('modals/offers/link', {
|
|
|
|
offer: offer
|
|
|
|
}, {
|
|
|
|
className: 'fullscreen-modal-action fullscreen-modal-wide'
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2021-10-06 17:29:15 +03:00
|
|
|
@task({restartable: true})
|
|
|
|
*fetchOffersTask() {
|
|
|
|
this.offers = yield this.store.query('offer', {limit: 'all'});
|
|
|
|
}
|
|
|
|
}
|