2019-10-02 06:00:03 +02:00
|
|
|
import Component from '@ember/component';
|
|
|
|
import boundOneWay from 'ghost-admin/utils/bound-one-way';
|
2019-10-03 19:42:33 +02:00
|
|
|
import moment from 'moment';
|
|
|
|
import {computed} from '@ember/object';
|
2019-10-02 06:00:03 +02:00
|
|
|
import {inject as service} from '@ember/service';
|
|
|
|
|
|
|
|
export default Component.extend({
|
|
|
|
feature: service(),
|
|
|
|
config: service(),
|
|
|
|
mediaQueries: service(),
|
|
|
|
|
|
|
|
isViewingSubview: false,
|
2019-10-02 13:35:50 +02:00
|
|
|
|
2019-10-02 06:00:03 +02:00
|
|
|
// Allowed actions
|
|
|
|
setProperty: () => {},
|
|
|
|
showDeleteTagModal: () => {},
|
|
|
|
|
|
|
|
scratchName: boundOneWay('member.name'),
|
|
|
|
scratchEmail: boundOneWay('member.email'),
|
2019-10-10 13:59:35 +02:00
|
|
|
scratchNote: boundOneWay('member.note'),
|
2019-10-04 16:31:56 +02:00
|
|
|
subscriptions: computed('member.stripe', function () {
|
2019-10-03 19:42:33 +02:00
|
|
|
let subscriptions = this.member.get('stripe');
|
|
|
|
if (subscriptions && subscriptions.length > 0) {
|
2019-10-04 16:31:56 +02:00
|
|
|
return subscriptions.map((subscription) => {
|
|
|
|
return {
|
|
|
|
customer: subscription.customer,
|
2019-10-10 10:24:19 +02:00
|
|
|
name: subscription.name || '',
|
2019-10-04 16:31:56 +02:00
|
|
|
email: subscription.email || '',
|
|
|
|
status: subscription.status,
|
2019-10-10 10:24:19 +02:00
|
|
|
startDate: subscription.start_date ? moment(subscription.start_date).format('MMM DD YYYY') : '-',
|
|
|
|
plan: subscription.plan,
|
2019-10-15 16:24:20 +02:00
|
|
|
dollarAmount: parseInt(subscription.plan.amount) ? (subscription.plan.amount / 100) : 0,
|
2019-10-10 10:24:19 +02:00
|
|
|
validUntil: subscription.current_period_end ? moment(subscription.current_period_end).format('MMM DD YYYY') : '-'
|
2019-10-07 05:47:26 +02:00
|
|
|
};
|
2019-10-04 16:31:56 +02:00
|
|
|
}).reverse();
|
2019-10-03 19:42:33 +02:00
|
|
|
}
|
|
|
|
return null;
|
|
|
|
}),
|
2019-10-07 05:47:26 +02:00
|
|
|
hasMultipleSubscriptions: computed('member.stripe', function () {
|
2019-10-04 16:31:56 +02:00
|
|
|
let subscriptions = this.member.get('stripe');
|
|
|
|
if (subscriptions && subscriptions.length > 1) {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}),
|
2019-10-03 19:42:33 +02:00
|
|
|
|
2019-10-02 06:00:03 +02:00
|
|
|
actions: {
|
|
|
|
setProperty(property, value) {
|
|
|
|
this.setProperty(property, value);
|
|
|
|
},
|
|
|
|
|
|
|
|
deleteTag() {
|
|
|
|
this.showDeleteTagModal();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
});
|