2019-01-24 22:34:32 +03:00
|
|
|
import Controller from '@ember/controller';
|
|
|
|
import {alias} from '@ember/object/computed';
|
2019-04-16 18:02:43 +03:00
|
|
|
import {computed} from '@ember/object';
|
2019-02-22 14:31:45 +03:00
|
|
|
import {inject as controller} from '@ember/controller';
|
|
|
|
import {inject as service} from '@ember/service';
|
2019-04-16 18:02:43 +03:00
|
|
|
import {task} from 'ember-concurrency';
|
2019-01-24 22:34:32 +03:00
|
|
|
|
|
|
|
export default Controller.extend({
|
2019-02-22 14:31:45 +03:00
|
|
|
members: controller(),
|
2019-04-16 18:02:43 +03:00
|
|
|
store: service(),
|
|
|
|
|
2019-02-22 14:31:45 +03:00
|
|
|
router: service(),
|
|
|
|
|
|
|
|
member: alias('model'),
|
|
|
|
|
2019-04-16 18:02:43 +03:00
|
|
|
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 || '-'
|
|
|
|
|
|
|
|
};
|
|
|
|
}),
|
|
|
|
|
2019-02-22 14:31:45 +03:00
|
|
|
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');
|
|
|
|
}
|
2019-04-16 18:02:43 +03:00
|
|
|
},
|
|
|
|
|
|
|
|
fetchMember: task(function* (memberId) {
|
|
|
|
yield this.store.findRecord('member', memberId, {
|
|
|
|
reload: true
|
|
|
|
}).then((data) => {
|
|
|
|
this.set('member', data);
|
|
|
|
});
|
|
|
|
})
|
|
|
|
|
2019-01-24 22:34:32 +03:00
|
|
|
});
|