2020-05-28 10:32:57 -05:00
|
|
|
import Component from "@ember/component";
|
2021-02-16 12:07:53 -06:00
|
|
|
import discourseComputed from "discourse-common/utils/decorators";
|
2019-12-13 10:41:14 +11:00
|
|
|
|
2020-05-28 10:32:57 -05:00
|
|
|
export default Component.extend({
|
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));
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
|
2020-08-03 10:31:21 -05:00
|
|
|
didInsertElement() {
|
2020-07-28 11:08:21 -05:00
|
|
|
this._super(...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);
|
|
|
|
|
}
|
|
|
|
|
},
|
2019-12-06 14:33:38 +11:00
|
|
|
actions: {
|
|
|
|
|
clickPlan(plan) {
|
2020-07-22 11:06:34 -05:00
|
|
|
this.set("selectedPlan", plan.id);
|
2020-09-16 09:53:50 -05:00
|
|
|
},
|
|
|
|
|
},
|
2019-12-06 14:33:38 +11:00
|
|
|
});
|