This commit is contained in:
Rimian Perkins 2019-10-31 13:31:24 +11:00
parent b0a4665bf4
commit bec2d57920
5 changed files with 14 additions and 15 deletions

View File

@ -16,7 +16,7 @@ const Plan = Discourse.Model.extend({
@computed("amountDollars", "currency", "interval")
subscriptionRate(amountDollars, currency, interval) {
return `$${amountDollars} ${currency.toUpperCase()} / ${interval}`;
},
}
});
Plan.reopenClass({

View File

@ -10,7 +10,7 @@ const Subscription = Discourse.Model.extend({
@computed("status")
canceled(status) {
return status === 'canceled';
return status === "canceled";
},
save() {
@ -23,10 +23,10 @@ const Subscription = Discourse.Model.extend({
},
destroy() {
return ajax(`/patrons/subscriptions/${this.id}`, { method: "delete" }).then(result =>
Subscription.create(result)
return ajax(`/patrons/subscriptions/${this.id}`, { method: "delete" }).then(
result => Subscription.create(result)
);
},
}
});
Subscription.reopenClass({

View File

@ -16,14 +16,16 @@ export default Discourse.Route.extend({
actions: {
cancelSubscription(subscription) {
bootbox.confirm(
I18n.t("discourse_patrons.user.subscriptions.operations.destroy.confirm"),
I18n.t(
"discourse_patrons.user.subscriptions.operations.destroy.confirm"
),
I18n.t("no_value"),
I18n.t("yes_value"),
confirmed => {
if (confirmed) {
subscription
.destroy()
.then(result => subscription.set('status', result.status))
.then(result => subscription.set("status", result.status))
.catch(data =>
bootbox.alert(data.jqXHR.responseJSON.errors.join("\n"))
);

View File

@ -22,7 +22,8 @@ textarea[readonly] {
table.discourse-patrons-user-table {
width: 100%;
th, td {
th,
td {
padding: 10px;
}
}

View File

@ -5,8 +5,8 @@ QUnit.module("discourse-patrons:model:plan");
QUnit.test("subscriptionRate", assert => {
const plan = Plan.create({
amount: "2399",
currency: 'aud',
interval: 'month'
currency: "aud",
interval: "month"
});
assert.equal(
@ -29,9 +29,5 @@ QUnit.test("amountDollars", assert => {
QUnit.test("amount", assert => {
const plan = Plan.create({ amountDollars: "22.12" });
assert.equal(
plan.get("amount"),
2212,
"it returns the cents amount"
);
assert.equal(plan.get("amount"), 2212, "it returns the cents amount");
});