format the select dropdowns for plans

This commit is contained in:
Rimian Perkins 2019-10-24 16:51:58 +11:00
parent 21b27f169a
commit 5f71def8a4
1 changed files with 7 additions and 1 deletions

View File

@ -4,8 +4,14 @@ import Subscription from "discourse/plugins/discourse-patrons/discourse/models/s
export default Discourse.Route.extend({
model() {
const toCurrency = (cents) => parseFloat(cents/100).toFixed(2);
const planSelectText = (plan) => {
return `$${toCurrency(plan.amount)} ${plan.currency.toUpperCase()} / ${plan.interval}`;
};
const group = Group.find();
const plans = Plan.findAll().then(results => results.map(p => ({ id: p.id, name: p.nickname })));
const plans = Plan.findAll().then(results => results.map(p => planSelectText(p)));
const subscription = Subscription.create();
return Ember.RSVP.hash({ group, plans, subscription });