1
0
Fork 0
mirror of https://github.com/TryGhost/Ghost-Admin.git synced 2023-12-14 02:33:04 +01:00
Ghost-Admin/app/components/gh-member-settings-form.js

58 lines
1.9 KiB
JavaScript
Raw Normal View History

2019-10-02 06:00:03 +02:00
import Component from '@ember/component';
import boundOneWay from 'ghost-admin/utils/bound-one-way';
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 06:00:03 +02:00
// Allowed actions
setProperty: () => {},
showDeleteTagModal: () => {},
scratchName: boundOneWay('member.name'),
scratchEmail: boundOneWay('member.email'),
scratchNote: boundOneWay('member.note'),
subscriptions: computed('member.stripe', function () {
let subscriptions = this.member.get('stripe');
if (subscriptions && subscriptions.length > 0) {
return subscriptions.map((subscription) => {
return {
customer: subscription.customer,
name: subscription.name || '',
email: subscription.email || '',
status: subscription.status,
startDate: subscription.start_date ? moment(subscription.start_date).format('MMM DD YYYY') : '-',
plan: subscription.plan,
dollarAmount: parseInt(subscription.plan.amount) ? (subscription.plan.amount / 100) : 0,
validUntil: subscription.current_period_end ? moment(subscription.current_period_end).format('MMM DD YYYY') : '-'
2019-10-07 05:47:26 +02:00
};
}).reverse();
}
return null;
}),
2019-10-07 05:47:26 +02:00
hasMultipleSubscriptions: computed('member.stripe', function () {
let subscriptions = this.member.get('stripe');
if (subscriptions && subscriptions.length > 1) {
return true;
}
return false;
}),
2019-10-02 06:00:03 +02:00
actions: {
setProperty(property, value) {
this.setProperty(property, value);
},
deleteTag() {
this.showDeleteTagModal();
}
}
});