mirror of
https://github.com/TryGhost/Ghost.git
synced 2025-04-01 02:41:39 -05:00
Fixed account plan page for logged out state
no issue - Account plan page did not handle redirect to signup when no member is logged in
This commit is contained in:
parent
96c72aa3c9
commit
465793a518
2 changed files with 13 additions and 4 deletions
|
@ -30,7 +30,7 @@ function getConfirmationPageTitle({confirmationType}) {
|
|||
}
|
||||
|
||||
const Header = ({member, lastPage, brandColor, onBack, showConfirmation, confirmationType}) => {
|
||||
let title = member.paid ? 'Change plan' : 'Choose a plan';
|
||||
let title = isPaidMember({member}) ? 'Change plan' : 'Choose a plan';
|
||||
if (showConfirmation) {
|
||||
title = getConfirmationPageTitle({confirmationType});
|
||||
}
|
||||
|
@ -251,6 +251,15 @@ export default class AccountPlanPage extends React.Component {
|
|||
this.state = this.getInitialState();
|
||||
}
|
||||
|
||||
componentDidMount() {
|
||||
const {member} = this.context;
|
||||
if (!member) {
|
||||
this.context.onAction('switchPage', {
|
||||
page: 'signup'
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
componentWillUnmount() {
|
||||
clearTimeout(this.timeoutId);
|
||||
}
|
||||
|
@ -296,7 +305,7 @@ export default class AccountPlanPage extends React.Component {
|
|||
onPlanCheckout(e, name) {
|
||||
const {onAction, member} = this.context;
|
||||
const {confirmationPlan, selectedPlan} = this.state;
|
||||
if (member.paid) {
|
||||
if (isPaidMember({member})) {
|
||||
const {subscriptions} = member;
|
||||
const subscriptionId = subscriptions[0].id;
|
||||
onAction('updateSubscription', {plan: confirmationPlan.name, subscriptionId, cancelAtPeriodEnd: false});
|
||||
|
|
|
@ -26,7 +26,7 @@ export function isCookiesDisabled() {
|
|||
}
|
||||
|
||||
export function getMemberSubscription({member = {}}) {
|
||||
if (member.paid) {
|
||||
if (isPaidMember({member})) {
|
||||
const [subscription] = member.subscriptions || [];
|
||||
return subscription;
|
||||
}
|
||||
|
@ -64,7 +64,7 @@ export function getMemberActivePlan({member}) {
|
|||
}
|
||||
|
||||
export function getSubscriptionFromId({member, subscriptionId}) {
|
||||
if (member.paid) {
|
||||
if (isPaidMember({member})) {
|
||||
const subscriptions = member.subscriptions || [];
|
||||
return subscriptions.find(d => d.id === subscriptionId);
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue