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

31 lines
592 B
Plaintext
Raw Normal View History

2019-10-09 22:52:55 -04:00
import { ajax } from "discourse/lib/ajax";
const AdminPlan = Discourse.Model.extend({
2019-10-14 18:40:49 -04:00
name: "",
interval: "month",
amount: 0,
intervals: ["day", "week", "month", "year"],
destroy() {},
save() {
const data = {
interval: this.interval,
amount: this.amount,
name: this.name
};
return ajax("/patrons/admin/plans", { method: "post", data });
}
2019-10-09 22:52:55 -04:00
});
AdminPlan.reopenClass({
find() {
return ajax("/patrons/admin/plans", { method: "get" }).then(result =>
2019-10-13 21:36:46 -04:00
result.map(plan => AdminPlan.create(plan))
2019-10-09 22:52:55 -04:00
);
}
});
export default AdminPlan;