0
Fork 0
mirror of https://github.com/TryGhost/Ghost.git synced 2025-02-17 23:44:39 -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 id: d.id
}; };
}); });
const {name, email, plan} = pageData; const {name, email, plan, offerId} = pageData;
onAction('signup', {name, email, plan, newsletters}); onAction('signup', {name, email, plan, newsletters, offerId});
}} }}
brandColor={brandColor} brandColor={brandColor}
label={label} label={label}

View file

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

View file

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