0
Fork 0
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:
Rish 2020-10-02 15:57:58 +05:30
parent 96c72aa3c9
commit 465793a518
2 changed files with 13 additions and 4 deletions

View file

@ -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});

View file

@ -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);
}