mirror of
https://github.com/discourse/discourse-subscriptions.git
synced 2025-03-06 09:39:51 +00:00
FEATURE: Show renewal date on uncanceled subscriptions
This commit is contained in:
parent
a868e6b838
commit
4457713901
@ -2,6 +2,7 @@ import EmberObject from "@ember/object";
|
|||||||
import discourseComputed from "discourse-common/utils/decorators";
|
import discourseComputed from "discourse-common/utils/decorators";
|
||||||
import { ajax } from "discourse/lib/ajax";
|
import { ajax } from "discourse/lib/ajax";
|
||||||
import Plan from "discourse/plugins/discourse-subscriptions/discourse/models/plan";
|
import Plan from "discourse/plugins/discourse-subscriptions/discourse/models/plan";
|
||||||
|
import I18n from "I18n";
|
||||||
|
|
||||||
const UserSubscription = EmberObject.extend({
|
const UserSubscription = EmberObject.extend({
|
||||||
@discourseComputed("status")
|
@discourseComputed("status")
|
||||||
@ -9,22 +10,31 @@ const UserSubscription = EmberObject.extend({
|
|||||||
return status === "canceled";
|
return status === "canceled";
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@discourseComputed("current_period_end", "canceled_at")
|
||||||
|
endDate(current_period_end, canceled_at) {
|
||||||
|
if (!canceled_at) {
|
||||||
|
return moment.unix(current_period_end).format("LL");
|
||||||
|
} else {
|
||||||
|
return I18n.t("discourse_subscriptions.user.subscriptions.cancelled");
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
destroy() {
|
destroy() {
|
||||||
return ajax(`/s/user/subscriptions/${this.id}`, {
|
return ajax(`/s/user/subscriptions/${this.id}`, {
|
||||||
method: "delete"
|
method: "delete",
|
||||||
}).then(result => UserSubscription.create(result));
|
}).then((result) => UserSubscription.create(result));
|
||||||
}
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
UserSubscription.reopenClass({
|
UserSubscription.reopenClass({
|
||||||
findAll() {
|
findAll() {
|
||||||
return ajax("/s/user/subscriptions", { method: "get" }).then(result =>
|
return ajax("/s/user/subscriptions", { method: "get" }).then((result) =>
|
||||||
result.map(subscription => {
|
result.map((subscription) => {
|
||||||
subscription.plan = Plan.create(subscription.plan);
|
subscription.plan = Plan.create(subscription.plan);
|
||||||
return UserSubscription.create(subscription);
|
return UserSubscription.create(subscription);
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
}
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
export default UserSubscription;
|
export default UserSubscription;
|
||||||
|
@ -5,6 +5,7 @@
|
|||||||
<th>{{i18n 'discourse_subscriptions.user.plans.product'}}</th>
|
<th>{{i18n 'discourse_subscriptions.user.plans.product'}}</th>
|
||||||
<th>{{i18n 'discourse_subscriptions.user.plans.rate'}}</th>
|
<th>{{i18n 'discourse_subscriptions.user.plans.rate'}}</th>
|
||||||
<th>{{i18n 'discourse_subscriptions.user.subscriptions.status'}}</th>
|
<th>{{i18n 'discourse_subscriptions.user.subscriptions.status'}}</th>
|
||||||
|
<th>Renews</th>
|
||||||
<th>{{i18n 'discourse_subscriptions.user.subscriptions.created_at'}}</th>
|
<th>{{i18n 'discourse_subscriptions.user.subscriptions.created_at'}}</th>
|
||||||
<th></th>
|
<th></th>
|
||||||
</thead>
|
</thead>
|
||||||
@ -14,6 +15,7 @@
|
|||||||
<td>{{subscription.product.name}}</td>
|
<td>{{subscription.product.name}}</td>
|
||||||
<td>{{subscription.plan.subscriptionRate}}</td>
|
<td>{{subscription.plan.subscriptionRate}}</td>
|
||||||
<td>{{subscription.status}}</td>
|
<td>{{subscription.status}}</td>
|
||||||
|
<td>{{subscription.endDate}}</td>
|
||||||
<td>{{format-unix-date subscription.created}}</td>
|
<td>{{format-unix-date subscription.created}}</td>
|
||||||
<td class="td-right">
|
<td class="td-right">
|
||||||
{{#if subscription.loading}}
|
{{#if subscription.loading}}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user