the subscribe product page
This commit is contained in:
@@ -20,8 +20,8 @@ const Plan = Discourse.Model.extend({
|
||||
});
|
||||
|
||||
Plan.reopenClass({
|
||||
findAll() {
|
||||
return ajax("/patrons/plans", { method: "get" }).then(result =>
|
||||
findAll(data) {
|
||||
return ajax("/patrons/plans", { method: "get", data }).then(result =>
|
||||
result.map(plan => Plan.create(plan))
|
||||
);
|
||||
}
|
||||
|
||||
@@ -7,6 +7,12 @@ Product.reopenClass({
|
||||
return ajax("/patrons/products", { method: "get" }).then(result =>
|
||||
result.map(product => Product.create(product))
|
||||
);
|
||||
},
|
||||
|
||||
find(id) {
|
||||
return ajax(`/patrons/products/${id}`, { method: "get" }).then(
|
||||
product => Product.create(product)
|
||||
);
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
@@ -15,22 +15,13 @@ const Subscription = Discourse.Model.extend({
|
||||
};
|
||||
|
||||
return ajax("/patrons/subscriptions", { method: "post", data });
|
||||
},
|
||||
|
||||
destroy() {
|
||||
return ajax(`/patrons/subscriptions/${this.id}`, { method: "delete" }).then(
|
||||
result => Subscription.create(result)
|
||||
);
|
||||
}
|
||||
});
|
||||
|
||||
Subscription.reopenClass({
|
||||
findAll() {
|
||||
return ajax("/patrons/subscriptions", { method: "get" }).then(result =>
|
||||
result.map(subscription => {
|
||||
subscription.plan = Plan.create(subscription.plan);
|
||||
return Subscription.create(subscription);
|
||||
})
|
||||
result.map(subscription => Subscription.create(subscription))
|
||||
);
|
||||
}
|
||||
});
|
||||
|
||||
@@ -6,6 +6,12 @@ const UserSubscription = Discourse.Model.extend({
|
||||
@computed("status")
|
||||
canceled(status) {
|
||||
return status === "canceled";
|
||||
},
|
||||
|
||||
destroy() {
|
||||
return ajax(`/patrons/user/subscriptions/${this.id}`, { method: "delete" }).then(
|
||||
result => UserSubscription.create(result)
|
||||
);
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user