2020-10-29 11:31:12 -04:00
|
|
|
import I18n from "I18n";
|
2019-12-12 19:54:32 -05:00
|
|
|
import Route from "@ember/routing/route";
|
2019-12-02 02:58:14 -05:00
|
|
|
import AdminSubscription from "discourse/plugins/discourse-subscriptions/discourse/models/admin-subscription";
|
2022-01-06 06:32:09 -05:00
|
|
|
import { action } from "@ember/object";
|
2022-03-06 18:30:01 -05:00
|
|
|
import bootbox from "bootbox";
|
2019-09-23 03:53:05 -04:00
|
|
|
|
2019-12-12 19:54:32 -05:00
|
|
|
export default Route.extend({
|
2019-09-26 19:42:32 -04:00
|
|
|
model() {
|
2019-10-13 21:36:46 -04:00
|
|
|
return AdminSubscription.find();
|
2019-11-13 18:51:04 -05:00
|
|
|
},
|
|
|
|
|
2022-01-06 06:32:09 -05:00
|
|
|
@action
|
|
|
|
cancelSubscription(model) {
|
|
|
|
const subscription = model.subscription;
|
|
|
|
const refund = model.refund;
|
|
|
|
subscription.set("loading", true);
|
|
|
|
subscription
|
|
|
|
.destroy(refund)
|
|
|
|
.then((result) => {
|
|
|
|
subscription.set("status", result.status);
|
|
|
|
this.send("closeModal");
|
|
|
|
bootbox.alert(I18n.t("discourse_subscriptions.admin.canceled"));
|
|
|
|
})
|
|
|
|
.catch((data) => bootbox.alert(data.jqXHR.responseJSON.errors.join("\n")))
|
|
|
|
.finally(() => {
|
|
|
|
subscription.set("loading", false);
|
|
|
|
this.refresh();
|
|
|
|
});
|
2020-09-16 10:53:50 -04:00
|
|
|
},
|
2019-09-23 03:53:05 -04:00
|
|
|
});
|