2020-05-28 10:32:57 -05:00
|
|
|
import Component from "@ember/component";
|
2024-11-29 15:42:50 +00:00
|
|
|
import { action } from "@ember/object";
|
2021-02-16 12:07:53 -06:00
|
|
|
import discourseComputed from "discourse-common/utils/decorators";
|
2019-12-13 10:41:14 +11:00
|
|
|
|
2024-11-29 15:42:50 +00:00
|
|
|
export default class PaymentOptions extends Component {
|
2021-02-16 12:07:53 -06:00
|
|
|
@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
|
|
|
}
|
2021-02-16 12:07:53 -06:00
|
|
|
|
2020-08-03 10:31:21 -05: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) {
|
2020-07-28 11:08:21 -05:00
|
|
|
this.set("selectedPlan", this.plans[0].id);
|
|
|
|
|
}
|
2024-11-29 15:42:50 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@action
|
|
|
|
|
clickPlan(plan) {
|
|
|
|
|
this.set("selectedPlan", plan.id);
|
|
|
|
|
}
|
|
|
|
|
}
|