fix: point to the subdomain instead

This commit is contained in:
Mrugesh Mohapatra
2019-10-04 19:47:12 +05:30
committed by mrugesh
parent 1cfd52209a
commit e5e5353ff1
7 changed files with 14 additions and 166 deletions

View File

@ -23,7 +23,9 @@ exports[`<Footer /> matches snapshot 1`] = `
Donations to freeCodeCamp go toward our education initiatives, and help pay for servers, services, and staff. You can  Donations to freeCodeCamp go toward our education initiatives, and help pay for servers, services, and staff. You can 
<a <a
className="inline" className="inline"
href="/donate" href="https://donate.freecodecamp.org"
rel="noopener noreferrer"
target="_blank"
> >
make a tax-deductible donation here make a tax-deductible donation here
</a> </a>
@ -46,7 +48,9 @@ exports[`<Footer /> matches snapshot 1`] = `
About About
</a> </a>
<a <a
href="/donate" href="https://donate.freecodecamp.org"
rel="noopener noreferrer"
target="_blank"
> >
Donate Donate
</a> </a>

View File

@ -4,7 +4,7 @@
"title": "Our Nonprofit", "title": "Our Nonprofit",
"links": [ "links": [
{ "to": "/news/about/", "text": "About" }, { "to": "/news/about/", "text": "About" },
{ "to": "/donate", "text": "Donate", "internal": true }, { "to": "https://donate.freecodecamp.org", "text": "Donate" },
{ "to": "/news/shop/", "text": "Shop" }, { "to": "/news/shop/", "text": "Shop" },
{ {
"to": "https://www.linkedin.com/school/free-code-camp/people/", "to": "https://www.linkedin.com/school/free-code-camp/people/",

View File

@ -38,7 +38,11 @@ function Footer() {
<p> <p>
Donations to freeCodeCamp go toward our education initiatives, and Donations to freeCodeCamp go toward our education initiatives, and
help pay for servers, services, and staff. You can&nbsp; help pay for servers, services, and staff. You can&nbsp;
<Link className='inline' to='/donate'> <Link
className='inline'
external={true}
to='https://donate.freecodecamp.org'
>
make a tax-deductible donation here make a tax-deductible donation here
</Link> </Link>
. .

View File

@ -1,137 +0,0 @@
import React, { Component, Fragment } from 'react';
import PropTypes from 'prop-types';
import Helmet from 'react-helmet';
import { StripeProvider, Elements } from 'react-stripe-elements';
import { Grid, Row, Col, Button } from '@freecodecamp/react-bootstrap';
import { connect } from 'react-redux';
import { createSelector } from 'reselect';
import { stripePublicKey, apiLocation } from '../../config/env.json';
import { Spacer, Loader } from '../components/helpers';
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';
import { signInLoadingSelector, isSignedInSelector, hardGoTo } from '../redux';
const mapStateToProps = createSelector(
signInLoadingSelector,
isSignedInSelector,
(showLoading, isSignedIn) => ({
showLoading,
isSignedIn
})
);
const mapDispatchToProps = dispatch => ({
navigate: location => dispatch(hardGoTo(location))
});
const propTypes = {
isSignedIn: PropTypes.bool.isRequired,
navigate: PropTypes.func.isRequired,
showLoading: PropTypes.bool.isRequired
};
export class DonatePage extends Component {
constructor(...props) {
super(...props);
this.state = {
stripe: null,
showOtherOptions: false
};
this.handleStripeLoad = this.handleStripeLoad.bind(this);
this.toggleOtherOptions = this.toggleOtherOptions.bind(this);
}
componentDidMount() {
if (window.Stripe) {
/* eslint-disable react/no-did-mount-set-state */
this.setState(state => ({
...state,
stripe: window.Stripe(stripePublicKey)
}));
} else if (document.querySelector('#stripe-js')) {
document
.querySelector('#stripe-js')
.addEventListener('load', this.handleStripeLoad);
}
}
componentWillUnmount() {
const stripeMountPoint = document.querySelector('#stripe-js');
if (stripeMountPoint) {
stripeMountPoint.removeEventListener('load', this.handleStripeLoad);
}
}
handleStripeLoad() {
// Create Stripe instance once Stripe.js loads
console.info('stripe has loaded');
this.setState(state => ({
...state,
stripe: window.Stripe(stripePublicKey)
}));
}
toggleOtherOptions() {
this.setState(({ showOtherOptions }) => ({
showOtherOptions: !showOtherOptions
}));
}
render() {
const { showOtherOptions, stripe } = this.state;
const { showLoading, isSignedIn, navigate } = this.props;
if (showLoading) {
return <Loader fullScreen={true} />;
}
if (!showLoading && !isSignedIn) {
return navigate(`${apiLocation}/signin`);
}
return (
<Fragment>
<Helmet title='Support our nonprofit | freeCodeCamp.org' />
<Spacer />
<Grid>
<Row>
<Col sm={10} smOffset={1} xs={12}>
<h2 className='text-center'>Become a Supporter</h2>
<DonateText />
</Col>
<Col md={8} mdOffset={2} sm={10} smOffset={1} xs={12}>
<hr />
<StripeProvider stripe={stripe}>
<Elements>
<DonateForm />
</Elements>
</StripeProvider>
<div className='text-center'>
<PoweredByStripe />
<Spacer />
<Button onClick={this.toggleOtherOptions}>
{`${
showOtherOptions ? 'Hide' : 'Show'
} other ways to donate.`}
</Button>
</div>
<Spacer />
</Col>
</Row>
</Grid>
{showOtherOptions && <DonateOther />}
</Fragment>
);
}
}
DonatePage.displayName = 'DonatePage';
DonatePage.propTypes = propTypes;
export default connect(
mapStateToProps,
mapDispatchToProps
)(DonatePage);

View File

@ -1,25 +0,0 @@
/* global jest, expect */
import React from 'react';
import 'jest-dom/extend-expect';
import ShallowRenderer from 'react-test-renderer/shallow';
import { apiLocation } from '../../config/env.json';
import { DonatePage } from './donate';
describe('<ShowSettings />', () => {
it('redirects to signin page when user not logged in', () => {
const shallow = new ShallowRenderer();
shallow.render(<DonatePage {...loggedOutProps} />);
expect(navigate).toHaveBeenCalledTimes(1);
expect(navigate).toHaveBeenCalledWith(`${apiLocation}/signin`);
expect(true).toBeTruthy();
});
});
const navigate = jest.fn();
const loggedOutProps = {
createFlashMessage: () => {},
isSignedIn: false,
showLoading: false,
navigate: navigate
};

View File

@ -15,6 +15,7 @@ exports[`createRedirects matches the snapshot 1`] = `
/code-of-conduct https://news.example.com/code-of-conduct 200 /code-of-conduct https://news.example.com/code-of-conduct 200
/copyright https://news.example.com/copyright-policy 200 /copyright https://news.example.com/copyright-policy 200
/copyright-policy https://news.example.com/copyright-policy 200 /copyright-policy https://news.example.com/copyright-policy 200
/donate https://donate.freecodecamp.org 200
/privacy https://news.example.com/privacy-policy 200 /privacy https://news.example.com/privacy-policy 200
/privacy-policy https://news.example.com/privacy-policy 200 /privacy-policy https://news.example.com/privacy-policy 200
/shop https://news.example.com/shop 200 /shop https://news.example.com/shop 200

View File

@ -36,6 +36,7 @@ const template = `
/code-of-conduct #{{NEWS}}/code-of-conduct 200 /code-of-conduct #{{NEWS}}/code-of-conduct 200
/copyright #{{NEWS}}/copyright-policy 200 /copyright #{{NEWS}}/copyright-policy 200
/copyright-policy #{{NEWS}}/copyright-policy 200 /copyright-policy #{{NEWS}}/copyright-policy 200
/donate https://donate.freecodecamp.org 200
/privacy #{{NEWS}}/privacy-policy 200 /privacy #{{NEWS}}/privacy-policy 200
/privacy-policy #{{NEWS}}/privacy-policy 200 /privacy-policy #{{NEWS}}/privacy-policy 200
/shop #{{NEWS}}/shop 200 /shop #{{NEWS}}/shop 200