0
0
Fork 1
Spiegel von https://github.com/paviliondev/discourse-custom-wizard.git synchronisiert 2024-11-22 17:30:29 +01:00
discourse-custom-wizard/assets/javascripts/discourse/components/wizard-pro-subscription.js.es6

54 Zeilen
1,4 KiB
Text

import Component from "@ember/component";
import CustomWizardPro from "../models/custom-wizard-pro";
import { notEmpty } from "@ember/object/computed";
import discourseComputed from "discourse-common/utils/decorators";
2021-09-07 14:15:04 +02:00
import I18n from "I18n";
export default Component.extend({
2021-09-07 14:13:01 +02:00
classNameBindings: [
":custom-wizard-pro-subscription",
"subscription.active:active:inactive",
],
subscribed: notEmpty("subscription"),
2021-09-07 14:13:01 +02:00
@discourseComputed("subscription.type")
title(type) {
2021-09-07 14:13:01 +02:00
return type
? I18n.t(`admin.wizard.pro.subscription.title.${type}`)
: I18n.t("admin.wizard.pro.not_subscribed");
},
2021-09-07 14:13:01 +02:00
@discourseComputed("subscription.active")
stateClass(active) {
2021-09-07 14:13:01 +02:00
return active ? "active" : "inactive";
},
2021-09-07 14:13:01 +02:00
@discourseComputed("stateClass")
stateLabel(stateClass) {
return I18n.t(`admin.wizard.pro.subscription.status.${stateClass}`);
},
actions: {
update() {
2021-09-07 14:13:01 +02:00
this.set("updating", true);
CustomWizardPro.update_subscription()
.then((result) => {
if (result.success) {
this.setProperties({
updateIcon: "check",
subscription: result.subscription,
});
} else {
this.set("updateIcon", "times");
}
})
.finally(() => {
this.set("updating", false);
setTimeout(() => {
this.set("updateIcon", null);
}, 7000);
});
},
},
});