0
0
Fork 1
Spiegel von https://github.com/paviliondev/discourse-custom-wizard.git synchronisiert 2024-09-19 23:31:11 +02:00
discourse-custom-wizard/assets/javascripts/discourse/components/wizard-subscription-badge.js

63 Zeilen
1,6 KiB
JavaScript

import { inject as service } from "@ember/service";
import { action, computed } from "@ember/object";
2023-10-09 14:39:10 +02:00
import { ajax } from "discourse/lib/ajax";
import { popupAjaxError } from "discourse/lib/ajax-error";
2023-09-24 12:58:20 +02:00
import Component from "@glimmer/component";
2023-10-09 14:39:10 +02:00
import { tracked } from "@glimmer/tracking";
import DiscourseURL from "discourse/lib/url";
import I18n from "I18n";
export default class WizardSubscriptionBadge extends Component {
@service subscription;
2023-10-09 14:39:10 +02:00
@tracked updating = false;
@tracked updateIcon = null;
basePath = "/admin/plugins/subscription-client";
@computed("subscription.subscriptionType")
get i18nKey() {
2023-09-24 12:58:20 +02:00
return `admin.wizard.subscription.type.${
this.subscription.subscriptionType
? this.subscription.subscriptionType
: "none"
}`;
}
@computed("i18nKey")
get title() {
2023-09-24 14:01:46 +02:00
return `${this.i18nKey}.title`;
2023-09-24 12:58:20 +02:00
}
@computed("i18nKey")
get label() {
return I18n.t(`${this.i18nKey}.label`);
2023-09-24 12:58:20 +02:00
}
@action
click() {
DiscourseURL.routeTo(this.subscription.subscriptionLink);
2023-09-24 12:58:20 +02:00
}
2023-10-09 14:39:10 +02:00
@action
update() {
2023-10-09 15:02:07 +02:00
this.subscription.retrieveSubscriptionStatus();
// this.updating = true;
// return ajax(`${this.basePath}/subscriptions`, {
// type: "POST",
// })
// .then(() => {
// if (this.subscription.subscribed) {
// this.updateIcon = "check";
// } else {
// this.updateIcon = "times";
// }
// })
// .catch(popupAjaxError)
// .finally(() => {
// this.updating = false;
// setTimeout(() => {
// this.updateIcon = null;
// }, 7000);
// });
2023-10-09 14:39:10 +02:00
}
2023-09-24 12:58:20 +02:00
}