discourse-subscriptions/assets/javascripts/discourse/models/admin-product.js.es6

28 lines
541 B
JavaScript

import { ajax } from "discourse/lib/ajax";
const AdminProduct = Discourse.Model.extend({
active: true,
destroy() {},
save() {
const data = {
name: this.name,
groupName: this.groupName,
active: this.active
};
return ajax("/patrons/admin/products", { method: "post", data });
}
});
AdminProduct.reopenClass({
find() {
return ajax("/patrons/admin/products", { method: "get" }).then(result =>
result.map(product => AdminProduct.create(product))
);
}
});
export default AdminProduct;