plans and products

This commit is contained in:
Rimian Perkins
2019-10-17 12:07:06 +11:00
parent 01b78b31df
commit e2b915b905
13 changed files with 107 additions and 40 deletions
@@ -14,9 +14,15 @@ const AdminPlan = Discourse.Model.extend({
const data = {
interval: this.interval,
amount: this.amount,
name: this.name
name: this.name,
product: {
id: this.product.id,
// name: this.product.name
}
};
console.log(12, data);
return ajax("/patrons/admin/plans", { method: "post", data });
}
});
@@ -2,6 +2,7 @@ import { ajax } from "discourse/lib/ajax";
const AdminProduct = Discourse.Model.extend({
isNew: false,
metadata: {},
destroy() {
return ajax(`/patrons/admin/products/${this.id}`, { method: "delete" });
@@ -3,7 +3,7 @@ import { ajax } from "discourse/lib/ajax";
const Plan = Discourse.Model.extend({});
Plan.reopenClass({
find() {
findAll() {
return ajax("/patrons/plans", { method: "get" }).then(result =>
result.plans.map(plan => Plan.create(plan))
);