Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(client): combine donate & donate-other pages into a single page #36137

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
@@ -1,9 +1,8 @@
import React, { Component, Fragment } from 'react';
import Helmet from 'react-helmet';
import { Grid, Col, Row } from '@freecodecamp/react-bootstrap';

import ReactGA from '../analytics/index.js';
import { Link, Spacer } from '../components/helpers';
import ReactGA from '../../../analytics/index.js';
import { Link, Spacer } from '../../helpers';

const paypalMonthlyDonations = [
{
Expand Down Expand Up @@ -51,7 +50,7 @@ const paypalOneTimeDonation = {
defaultValue: 'Make a one-time donation'
};

class DonateOtherPage extends Component {
class DonateOther extends Component {
renderForm(item) {
return (
<form
Expand Down Expand Up @@ -87,7 +86,6 @@ class DonateOtherPage extends Component {
render() {
return (
<Fragment>
<Helmet title='Other ways to donate | freeCodeCamp.org' />
<Spacer />
<Grid>
<Row>
Expand Down Expand Up @@ -212,9 +210,7 @@ class DonateOtherPage extends Component {
</h3>
<Spacer />
<div className='text-center'>
<Link to='/donate'>
Or donate using a Credit or Debit Card.
</Link>
<Link to='/donate'>Donate using a Credit or Debit card</Link>
</div>
<Spacer />
</Col>
Expand All @@ -226,6 +222,6 @@ class DonateOtherPage extends Component {
/* eslint-enable max-len */
}

DonateOtherPage.displayName = 'DonateOtherPage';
DonateOther.displayName = 'DonateOther';

export default DonateOtherPage;
export default DonateOther;
24 changes: 18 additions & 6 deletions client/src/pages/donate.js
@@ -1,12 +1,12 @@
import React, { Component, Fragment } from 'react';
import Helmet from 'react-helmet';
import { StripeProvider, Elements } from 'react-stripe-elements';
import { Row, Col } from '@freecodecamp/react-bootstrap';
import { Link } from 'gatsby';
import { Row, Col, Button } from '@freecodecamp/react-bootstrap';

import { stripePublicKey } from '../../config/env.json';

import Spacer from '../components/helpers/Spacer';
import DonateOther from '../components/Donation/components/DonateOther';
import DonateForm from '../components/Donation/components/DonateForm';
import DonateText from '../components/Donation/components/DonateText';
import PoweredByStripe from '../components/Donation/components/poweredByStripe';
Expand All @@ -17,9 +17,11 @@ class DonatePage extends Component {
constructor(...props) {
super(...props);
this.state = {
stripe: null
stripe: null,
showOtherOptions: false
};
this.handleStripeLoad = this.handleStripeLoad.bind(this);
this.toggleOtherOptions = this.toggleOtherOptions.bind(this);
}
componentDidMount() {
if (window.Stripe) {
Expand Down Expand Up @@ -52,7 +54,14 @@ class DonatePage extends Component {
}));
}

toggleOtherOptions() {
this.setState(({ showOtherOptions }) => ({
showOtherOptions: !showOtherOptions
}));
}

render() {
const { showOtherOptions, stripe } = this.state;
return (
<Fragment>
<Helmet title='Support our nonprofit | freeCodeCamp.org' />
Expand All @@ -64,19 +73,22 @@ class DonatePage extends Component {
</Col>
<Col sm={6} smOffset={3} xs={12}>
<hr />
<StripeProvider stripe={this.state.stripe}>
<StripeProvider stripe={stripe}>
<Elements>
<DonateForm />
</Elements>
</StripeProvider>
<div className='text-center'>
<Link to='/donate-other'>Other ways to donate.</Link>
<Spacer />
<PoweredByStripe />
<Spacer />
<Button onClick={this.toggleOtherOptions}>
{`${showOtherOptions ? 'Hide' : 'Show'} other ways to donate.`}
</Button>
</div>
<Spacer />
</Col>
</Row>
{showOtherOptions && <DonateOther />}
</Fragment>
);
}
Expand Down