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";
|
2025-02-06 16:57:53 +00:00
|
|
|
import discourseComputed from "discourse/lib/decorators";
|
2025-06-05 12:40:13 +02:00
|
|
|
import { i18n } from "discourse-i18n";
|
|
|
|
|
import PaymentPlan from "./payment-plan";
|
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);
|
|
|
|
|
}
|
2025-06-05 12:40:13 +02:00
|
|
|
|
|
|
|
|
<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
|
|
|
}
|