Files

43 lines
1.0 KiB
Plaintext
Raw Permalink 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/lib/decorators";
import { i18n } from "discourse-i18n";
import PaymentPlan from "./payment-plan";
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);
}
<template>
<p>
{{i18n "discourse_subscriptions.plans.select"}}
</p>
<div class="subscribe-buttons">
{{#each this.orderedPlans as |plan|}}
<PaymentPlan
@plan={{plan}}
@selectedPlan={{this.selectedPlan}}
@clickPlan={{this.clickPlan}}
/>
{{/each}}
</div>
</template>
2024-11-29 15:42:50 +00:00
}