mirror of
https://github.com/discourse/discourse-subscriptions.git
synced 2025-03-03 08:09:26 +00:00
33 lines
672 B
JavaScript
33 lines
672 B
JavaScript
import { ajax } from "discourse/lib/ajax";
|
|
|
|
const AdminPlan = Discourse.Model.extend({
|
|
name: "",
|
|
interval: "month",
|
|
amount: 0,
|
|
intervals: ["day", "week", "month", "year"],
|
|
|
|
destroy() {
|
|
return ajax(`/patrons/admin/plans/${this.id}`, { method: "delete" });
|
|
},
|
|
|
|
save() {
|
|
const data = {
|
|
interval: this.interval,
|
|
amount: this.amount,
|
|
name: this.name
|
|
};
|
|
|
|
return ajax("/patrons/admin/plans", { method: "post", data });
|
|
}
|
|
});
|
|
|
|
AdminPlan.reopenClass({
|
|
findAll() {
|
|
return ajax("/patrons/admin/plans", { method: "get" }).then(result =>
|
|
result.map(plan => AdminPlan.create(plan))
|
|
);
|
|
}
|
|
});
|
|
|
|
export default AdminPlan;
|