mirror of
https://github.com/TryGhost/Ghost.git
synced 2025-04-01 02:41:39 -05:00
Added update plan setup for paid members
refs https://github.com/TryGhost/members.js/issues/20 - Adds update plan action for paid members to allow switching plans
This commit is contained in:
parent
3f738b1088
commit
748f56ee47
2 changed files with 13 additions and 2 deletions
ghost/portal/src/components
|
@ -171,6 +171,11 @@ export default class ParentContainer extends React.Component {
|
|||
await this.GhostApi.member.checkoutPlan({
|
||||
plan
|
||||
});
|
||||
} else if (action === 'updatePlan') {
|
||||
const {plan, subscriptionId} = data;
|
||||
await this.GhostApi.member.updateSubscription({
|
||||
plan, subscriptionId
|
||||
});
|
||||
} else if (action === 'editBilling') {
|
||||
await this.GhostApi.member.editBilling();
|
||||
}
|
||||
|
|
|
@ -34,9 +34,15 @@ export default class AccountPlanPage extends React.Component {
|
|||
|
||||
onPlanCheckout(e) {
|
||||
e.preventDefault();
|
||||
const {onAction} = this.context;
|
||||
const {onAction, member} = this.context;
|
||||
const plan = this.state.plan;
|
||||
onAction('checkoutPlan', {plan});
|
||||
if (member.paid) {
|
||||
const {subscriptions} = member;
|
||||
const subscriptionId = subscriptions[0].id;
|
||||
onAction('updatePlan', {plan, subscriptionId});
|
||||
} else {
|
||||
onAction('checkoutPlan', {plan});
|
||||
}
|
||||
}
|
||||
|
||||
onPlanSelect(e, name) {
|
||||
|
|
Loading…
Add table
Reference in a new issue