Files
discourse-subscriptions/assets/javascripts/discourse/components/payment-options.js
T

25 lines
615 B
JavaScript
Raw Normal View History

import Component from "@ember/component";
2024-11-29 15:42:50 +00:00
import { action } from "@ember/object";
import discourseComputed from "discourse-common/utils/decorators";
2024-11-29 15:42:50 +00:00
export default class PaymentOptions extends Component {
@discourseComputed("plans")
orderedPlans(plans) {
if (plans) {
return plans.sort((a, b) => (a.unit_amount > b.unit_amount ? 1 : -1));
}
2024-11-29 15:42:50 +00:00
}
didInsertElement() {
2024-11-29 15:42:50 +00:00
super.didInsertElement(...arguments);
2020-07-28 15:40:16 -05:00
if (this.plans && this.plans.length === 1) {
this.set("selectedPlan", this.plans[0].id);
}
2024-11-29 15:42:50 +00:00
}
@action
clickPlan(plan) {
this.set("selectedPlan", plan.id);
}
}