Ghost/ghost/admin/app/controllers/offers.js
Rishabh 31e4b77525 Added initial wiring for offer screens
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
2021-10-06 20:01:25 +05:30

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'});
}
}