Skip to content

Commit

Permalink
Added listener for portal link changes
Browse files Browse the repository at this point in the history
refs #12365

- Listens to portal link changes in URL and opens direct checkout plans
  • Loading branch information
rishabhgrg committed Nov 20, 2020
1 parent 4dc22ca commit 8483ba1
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions ghost/portal/src/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -311,6 +311,7 @@ export default class App extends React.Component {
updateStateForPreviewLinks() {
const {site: previewSite, ...restPreviewData} = this.fetchPreviewData();
const {site: linkSite, ...restLinkData} = this.fetchLinkData();

const updatedState = {
site: {
...this.state.site,
Expand All @@ -320,6 +321,12 @@ export default class App extends React.Component {
...restLinkData,
...restPreviewData
};

if (!this.state.member && ['monthly', 'yearly'].includes(updatedState.pageQuery) && hasPlan({site: updatedState.site, plan: updatedState.pageQuery})) {
removePortalLinkFromUrl();
this.onAction('signup', {plan: capitalize(updatedState.pageQuery)});
}

this.setState(updatedState);
}

Expand Down

0 comments on commit 8483ba1

Please sign in to comment.