31e4b77525
refs https://github.com/TryGhost/Team/issues/1084 refs https://github.com/TryGhost/Team/issues/1085 - adds model/validator/config and router for offers - updates template for offer list and detail with dynamic values - updated route handling for offer list and creation - wires offer data from API to list and detail pages
33 lines
851 B
JavaScript
33 lines
851 B
JavaScript
import Controller from '@ember/controller';
|
|
import {task} from 'ember-concurrency-decorators';
|
|
import {tracked} from '@glimmer/tracking';
|
|
|
|
export default class MembersController extends Controller {
|
|
@tracked offers = [];
|
|
|
|
constructor() {
|
|
super(...arguments);
|
|
}
|
|
|
|
get offersExist() {
|
|
return this.offers.length > 0;
|
|
}
|
|
|
|
get offersList() {
|
|
const offersList = this.offers.map((offer) => {
|
|
return {
|
|
offerModel: offer,
|
|
...offer.toJSON(),
|
|
duration: offer.duration || 'Once',
|
|
cadenceInterval: offer.cadence === 'year' ? 'Yearly' : 'Monthly'
|
|
};
|
|
});
|
|
return offersList;
|
|
}
|
|
|
|
@task({restartable: true})
|
|
*fetchOffersTask() {
|
|
this.offers = yield this.store.query('offer', {limit: 'all'});
|
|
}
|
|
}
|