mirror of
https://github.com/TryGhost/Ghost.git
synced 2025-02-10 23:36:14 -05:00
Added checkout on offer page
refs https://github.com/TryGhost/Team/issues/1138
This commit is contained in:
parent
c13516e7e5
commit
09e9432c20
1 changed files with 26 additions and 1 deletions
|
@ -4,6 +4,7 @@ import {ReactComponent as CheckmarkIcon} from '../../images/icons/checkmark.svg'
|
|||
import CloseButton from '../common/CloseButton';
|
||||
import InputForm from '../common/InputForm';
|
||||
import {getCurrencySymbol, getProductFromId} from '../../utils/helpers';
|
||||
import {ValidateInputForm} from '../../utils/form';
|
||||
const React = require('react');
|
||||
|
||||
export const OfferPageStyles = `
|
||||
|
@ -199,7 +200,31 @@ export default class OfferPage extends React.Component {
|
|||
}
|
||||
|
||||
handleSignup(e) {
|
||||
return;
|
||||
e.preventDefault();
|
||||
const {pageData: offer, site} = this.context;
|
||||
if (!offer) {
|
||||
return null;
|
||||
}
|
||||
const product = getProductFromId({site, productId: offer.tier.id});
|
||||
const price = offer.cadence === 'month' ? product.monthlyPrice : product.yearlyPrice;
|
||||
this.setState((state) => {
|
||||
return {
|
||||
errors: ValidateInputForm({fields: this.getInputFields({state})})
|
||||
};
|
||||
}, () => {
|
||||
const {onAction} = this.context;
|
||||
const {name, email, errors} = this.state;
|
||||
const hasFormErrors = (errors && Object.values(errors).filter(d => !!d).length > 0);
|
||||
if (!hasFormErrors) {
|
||||
onAction('signup', {
|
||||
name, email, plan: price?.id,
|
||||
offerId: offer?.id
|
||||
});
|
||||
this.setState({
|
||||
errors: {}
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
handleInputChange(e, field) {
|
||||
|
|
Loading…
Add table
Reference in a new issue