Added listener for portal link changes

refs https://github.com/TryGhost/Ghost/issues/12365

- Listens to portal link changes in URL and opens direct checkout plans
This commit is contained in:
Rish 2020-11-20 10:42:03 +05:30
parent 4dc22ca568
commit 8483ba162d

View File

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