0
Fork 0
mirror of https://github.com/TryGhost/Ghost.git synced 2025-02-10 23:36:14 -05:00

Added newsletter selection to offer signup

refs https://github.com/TryGhost/Team/issues/1490

Adds newsletter subscription selection page as intermediary before signing up to a site via offer url.
This commit is contained in:
Rishabh 2022-04-13 17:19:46 +05:30
parent 031aa5f2bc
commit 54b64c2634
3 changed files with 20 additions and 19 deletions

View file

@ -114,8 +114,8 @@ export default function NewsletterSelectionPage() {
id: d.id
};
});
const {name, email, plan} = pageData;
onAction('signup', {name, email, plan, newsletters});
const {name, email, plan, offerId} = pageData;
onAction('signup', {name, email, plan, newsletters, offerId});
}}
brandColor={brandColor}
label={label}

View file

@ -3,7 +3,7 @@ import AppContext from '../../AppContext';
import {ReactComponent as CheckmarkIcon} from '../../images/icons/checkmark.svg';
import CloseButton from '../common/CloseButton';
import InputForm from '../common/InputForm';
import {getCurrencySymbol, getProductFromId, hasMultipleProductsFeature, isSameCurrency, formatNumber} from '../../utils/helpers';
import {getCurrencySymbol, getProductFromId, hasMultipleProductsFeature, isSameCurrency, formatNumber, hasMultipleNewsletters} from '../../utils/helpers';
import {ValidateInputForm} from '../../utils/form';
const React = require('react');
@ -208,13 +208,22 @@ export default class OfferPage extends React.Component {
const {name, email, errors} = this.state;
const hasFormErrors = (errors && Object.values(errors).filter(d => !!d).length > 0);
if (!hasFormErrors) {
onAction('signup', {
const signupData = {
name, email, plan: price?.id,
offerId: offer?.id
});
this.setState({
errors: {}
});
};
if (hasMultipleNewsletters({site})) {
onAction('switchPage', {
page: 'signupNewsletter',
lastPage: 'signup',
pageData: signupData
});
} else {
onAction('signup', signupData);
this.setState({
errors: {}
});
}
}
});
}
@ -295,7 +304,7 @@ export default class OfferPage extends React.Component {
brandColor={brandColor}
label={label}
isRunning={isRunning}
tabIndex='3'
tabindex='3'
classes={'sticky bottom'}
/>
);

View file

@ -277,8 +277,7 @@ class SignupPage extends React.Component {
pageData: {name, email, plan}
});
this.setState({
errors: {},
showNewsletterSelection: true
errors: {}
});
} else {
this.setState({
@ -309,8 +308,7 @@ class SignupPage extends React.Component {
});
this.setState({
errors: {},
showNewsletterSelection: true
errors: {}
});
} else {
onAction('signup', {name, email, plan});
@ -580,12 +578,6 @@ class SignupPage extends React.Component {
return {sectionClass, footerClass};
}
onNewsletterSelectionBack() {
this.setState({
showNewsletterSelection: false
});
}
render() {
let {sectionClass} = this.getClassNames();
return (