2019-10-14 18:40:49 -04:00
|
|
|
import { ajax } from "discourse/lib/ajax";
|
|
|
|
|
|
|
|
const AdminProduct = Discourse.Model.extend({
|
2019-10-15 06:50:30 -04:00
|
|
|
active: true,
|
|
|
|
|
2019-10-14 18:40:49 -04:00
|
|
|
destroy() {},
|
|
|
|
|
|
|
|
save() {
|
2019-10-15 06:50:30 -04:00
|
|
|
const data = {
|
|
|
|
name: this.name,
|
|
|
|
groupName: this.groupName,
|
|
|
|
active: this.active
|
|
|
|
};
|
2019-10-14 18:40:49 -04:00
|
|
|
|
|
|
|
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;
|