2019-12-02 02:58:14 -05:00
|
|
|
import Product from "discourse/plugins/discourse-subscriptions/discourse/models/product";
|
|
|
|
import Plan from "discourse/plugins/discourse-subscriptions/discourse/models/plan";
|
|
|
|
import Subscription from "discourse/plugins/discourse-subscriptions/discourse/models/subscription";
|
2019-11-04 00:37:21 -05:00
|
|
|
|
|
|
|
export default Discourse.Route.extend({
|
|
|
|
model(params) {
|
2019-11-06 04:59:35 -05:00
|
|
|
const product_id = params["subscription-id"];
|
|
|
|
const product = Product.find(product_id);
|
2019-11-28 04:11:48 -05:00
|
|
|
|
2019-11-06 04:59:35 -05:00
|
|
|
const subscription = Subscription.create();
|
|
|
|
const plans = Plan.findAll({ product_id: product_id }).then(results =>
|
|
|
|
results.map(p => ({ id: p.id, name: p.subscriptionRate }))
|
|
|
|
);
|
2019-11-04 00:37:21 -05:00
|
|
|
|
2019-11-06 04:59:35 -05:00
|
|
|
return Ember.RSVP.hash({ plans, product, subscription });
|
|
|
|
}
|
2019-11-04 00:37:21 -05:00
|
|
|
});
|