2020-05-28 10:32:57 -05:00
|
|
|
import Controller from "@ember/controller";
|
2019-10-08 15:55:38 +11:00
|
|
|
import { popupAjaxError } from "discourse/lib/ajax-error";
|
|
|
|
|
|
2020-05-28 10:32:57 -05:00
|
|
|
export default Controller.extend({
|
2019-09-24 15:20:07 +10:00
|
|
|
actions: {
|
|
|
|
|
createPlan() {
|
2019-10-25 14:00:59 +11:00
|
|
|
if (this.get("model.plan.product_id") === undefined) {
|
2019-10-17 20:34:26 +11:00
|
|
|
const productID = this.get("model.products.firstObject.id");
|
|
|
|
|
this.set("model.plan.product_id", productID);
|
2019-10-17 12:07:06 +11:00
|
|
|
}
|
|
|
|
|
|
2019-10-16 14:15:01 +11:00
|
|
|
this.get("model.plan")
|
2019-09-24 20:44:51 +10:00
|
|
|
.save()
|
|
|
|
|
.then(() => {
|
2019-12-02 18:58:14 +11:00
|
|
|
this.transitionToRoute("adminPlugins.discourse-subscriptions.plans");
|
2019-10-08 15:55:38 +11:00
|
|
|
})
|
|
|
|
|
.catch(popupAjaxError);
|
2020-09-16 09:53:50 -05:00
|
|
|
},
|
|
|
|
|
},
|
2019-09-24 15:20:07 +10:00
|
|
|
});
|