Ghost/ghost/admin/app/controllers/member.js
Rishabh Garg c72e7b6040 Updated member management data (#1150)
no issue

- Updated hard-coded data in member management to use real values from API
2019-04-16 20:32:43 +05:30

47 lines
1.4 KiB
JavaScript

import Controller from '@ember/controller';
import {alias} from '@ember/object/computed';
import {computed} from '@ember/object';
import {inject as controller} from '@ember/controller';
import {inject as service} from '@ember/service';
import {task} from 'ember-concurrency';
export default Controller.extend({
members: controller(),
store: service(),
router: service(),
member: alias('model'),
subscription: computed('member.subscriptions', function () {
let subscriptions = this.member.get('subscriptions') || [];
let subscription = subscriptions[0] || {};
return {
amount: subscription.amount ? (subscription.amount / 100) : '-',
status: subscription.status || '-',
plan: subscription.plan || '-'
};
}),
actions: {
finaliseDeletion() {
// decrememnt the total member count manually so there's no flash
// when transitioning back to the members list
if (this.members.meta) {
this.members.decrementProperty('meta.pagination.total');
}
this.router.transitionTo('members');
}
},
fetchMember: task(function* (memberId) {
yield this.store.findRecord('member', memberId, {
reload: true
}).then((data) => {
this.set('member', data);
});
})
});