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