1
0
mirror of synced 2026-09-11 00:19:57 +00:00

product controller

This commit is contained in:
Rimian Perkins
2019-10-25 08:18:16 +11:00
parent 5f71def8a4
commit 6fbcea2cf3
8 changed files with 55 additions and 3 deletions
@@ -0,0 +1,13 @@
import { ajax } from "discourse/lib/ajax";
const Product = Discourse.Model.extend({});
Product.reopenClass({
findAll() {
return ajax("/patrons/products", { method: "get" }).then(result =>
result.map(product => Product.create(product))
);
}
});
export default Product;
@@ -1,6 +1,8 @@
export default function() {
this.route("patrons", function() {
this.route("subscribe");
this.route("subscribe", function() {
this.route("product", { path: ":product_id" })
});
this.route("show", { path: ":pid" });
});
}
@@ -10,10 +10,9 @@ export default Discourse.Route.extend({
return `$${toCurrency(plan.amount)} ${plan.currency.toUpperCase()} / ${plan.interval}`;
};
const group = Group.find();
const plans = Plan.findAll().then(results => results.map(p => planSelectText(p)));
const subscription = Subscription.create();
return Ember.RSVP.hash({ group, plans, subscription });
return Ember.RSVP.hash({ plans, subscription });
}
});