fix: replace donate page

This commit is contained in:
Ahmad Abdolsaheb
2019-12-10 18:51:15 +01:00
committed by mrugesh
parent 00f18dc21c
commit d7b7f0bfde
2 changed files with 76 additions and 120 deletions

View File

@ -1,30 +1,62 @@
import React from 'react'; import React from 'react';
import { Row, Col } from '@freecodecamp/react-bootstrap';
import { Spacer, Link } from '../../../components/helpers';
const DonateText = () => { const DonateText = () => {
return ( return (
<Row className='donate-text'> <div className='donate-text'>
<Col sm={10} smOffset={1} xs={12}> <Spacer />
<p>freeCodeCamp is a highly efficient education nonprofit.</p> <h3>How to donate to freeCodeCamp.org</h3>
<p>freeCodeCamp is a tax-exempt 501(c)(3) public charity.</p>
<p> <p>
In 2019 alone, we provided 18 million hours of free education to We get almost all of our budget from our supporters, who donate $5 per
people around the world. month to our nonprofit.
</p> </p>
<p> <p>
Since freeCodeCamp's total budget is only $373,000, that means every To become a supporter, just{' '}
dollar you donate to freeCodeCamp translates into 50 hours worth of <Link to='/learn'>start going through the curriculum</Link> and you will
technology education. see a prompt to donate.
</p> </p>
<p> <p>
When you donate to freeCodeCamp, you help people learn new skills and If you want to make a larger one-time donation, set up employer
provide for their families. matching, or support us in other ways, email team@freecodecamp.org and
we can help make that happen.
</p> </p>
<Spacer />
<h3> How does freeCodeCamp use these donations?</h3>
<p> <p>
You also help us create new resources for you to use to expand your 100% of donations go to pay for servers, and to pay teachers and
own technology skills. developers who help build our learning resources.
</p> </p>
</Col>
</Row> <p>
We earned the 2019 Platinum Seal of Transparency from Guidestar.org. You
can view all our nonprofit's details and download our accounting
documents [there](https://www.guidestar.org/profile/82-0779546).
</p>
<Spacer />
<h3> How do I stop my monthly recurring donation.</h3>
<p>
Easy. Just forward a donation receipt to team@freecodecamp.org and we'll
stop it.
</p>
<Spacer />
<h3>How do I restart my monthly recurring donation?</h3>
<p>
Email one of your old donation receipts to team@freecodecamp.org and
we'll restart it for you.
</p>
</div>
); );
}; };

View File

@ -1,78 +1,11 @@
import React, { Component, Fragment } from 'react'; import React, { Fragment } from 'react';
import Helmet from 'react-helmet'; import Helmet from 'react-helmet';
import PropTypes from 'prop-types'; import { Grid } from '@freecodecamp/react-bootstrap';
import { connect } from 'react-redux';
import { createSelector } from 'reselect';
import { Grid, Row, Col } from '@freecodecamp/react-bootstrap';
import { stripePublicKey } from '../../config/env.json'; import { Spacer, FullWidthRow } from '../components/helpers';
import { Spacer, Loader, FullWidthRow } from '../components/helpers';
import DonateForm from '../components/Donation/components/DonateForm';
import DonateText from '../components/Donation/components/DonateText'; import DonateText from '../components/Donation/components/DonateText';
import { signInLoadingSelector, userSelector } from '../redux';
import { stripeScriptLoader } from '../utils/scriptLoaders';
const propTypes = {
isDonating: PropTypes.bool,
showLoading: PropTypes.bool.isRequired
};
const mapStateToProps = createSelector(
userSelector,
signInLoadingSelector,
({ isDonating }, showLoading) => ({
isDonating,
showLoading
})
);
export class DonatePage extends Component {
constructor(...props) {
super(...props);
this.state = {
stripe: null
};
this.handleStripeLoad = this.handleStripeLoad.bind(this);
}
componentDidMount() {
if (window.Stripe) {
this.handleStripeLoad();
} else if (document.querySelector('#stripe-js')) {
document
.querySelector('#stripe-js')
.addEventListener('load', this.handleStripeLoad);
} else {
stripeScriptLoader(this.handleStripeLoad);
}
}
componentWillUnmount() {
const stripeMountPoint = document.querySelector('#stripe-js');
if (stripeMountPoint) {
stripeMountPoint.removeEventListener('load', this.handleStripeLoad);
}
}
handleStripeLoad() {
// Create Stripe instance once Stripe.js loads
if (stripePublicKey) {
this.setState(state => ({
...state,
stripe: window.Stripe(stripePublicKey)
}));
}
}
render() {
const { stripe } = this.state;
const { showLoading } = this.props;
if (showLoading) {
return <Loader fullScreen={true} />;
}
function DonatePage() {
return ( return (
<Fragment> <Fragment>
<Helmet title='Support our nonprofit | freeCodeCamp.org' /> <Helmet title='Support our nonprofit | freeCodeCamp.org' />
@ -81,25 +14,16 @@ export class DonatePage extends Component {
<Spacer /> <Spacer />
<FullWidthRow> <FullWidthRow>
<h1 className='text-center'>Become a Supporter</h1> <h1 className='text-center'>Become a Supporter</h1>
<DonateText />
</FullWidthRow> </FullWidthRow>
<Spacer /> <Spacer />
<Row>
<Col md={6}>
<DonateForm stripe={stripe} />
</Col>
<Col md={6}>
<DonateText />
</Col>
</Row>
<Spacer /> <Spacer />
</main> </main>
</Grid> </Grid>
</Fragment> </Fragment>
); );
} }
}
DonatePage.displayName = 'DonatePage'; DonatePage.displayName = 'DonatePage';
DonatePage.propTypes = propTypes;
export default connect(mapStateToProps)(DonatePage); export default DonatePage;