chore(donate): remove unused donate modal wiring
This commit removed the donate modal and related wiring, although some of the state mapping is still around. The remaining state mapping can either be removed, or kept for now, because it will be replaced as is for the newer motivation based donation prompts
This commit is contained in:
committed by
mrugesh
parent
a36e0d8351
commit
83ac3c5f95
@ -1,134 +0,0 @@
|
||||
import React, { Component } from 'react';
|
||||
import PropTypes from 'prop-types';
|
||||
import { bindActionCreators } from 'redux';
|
||||
import { connect } from 'react-redux';
|
||||
import { createSelector } from 'reselect';
|
||||
import { Modal, Button } from '@freecodecamp/react-bootstrap';
|
||||
import { StripeProvider, Elements } from 'react-stripe-elements';
|
||||
|
||||
import { stripePublicKey } from '../../../../config/env.json';
|
||||
|
||||
import ga from '../../../analytics';
|
||||
import DonateForm from './DonateForm';
|
||||
import {
|
||||
closeDonationModal,
|
||||
isDonationModalOpenSelector
|
||||
} from '../../../redux';
|
||||
import { stripeScriptLoader } from '../../../utils/scriptLoaders';
|
||||
|
||||
import PoweredByStripe from './poweredByStripe';
|
||||
import DonateText from './DonateText';
|
||||
|
||||
import '../Donation.css';
|
||||
|
||||
const mapStateToProps = createSelector(
|
||||
isDonationModalOpenSelector,
|
||||
show => ({
|
||||
show
|
||||
})
|
||||
);
|
||||
|
||||
const mapDispatchToProps = dispatch =>
|
||||
bindActionCreators(
|
||||
{
|
||||
closeDonationModal
|
||||
},
|
||||
dispatch
|
||||
);
|
||||
|
||||
const propTypes = {
|
||||
closeDonationModal: PropTypes.func.isRequired,
|
||||
show: PropTypes.bool
|
||||
};
|
||||
|
||||
class DonateModal extends Component {
|
||||
constructor(...props) {
|
||||
super(...props);
|
||||
this.state = {
|
||||
stripe: null
|
||||
};
|
||||
this.renderMaybe = this.renderMaybe.bind(this);
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
handleStripeLoad() {
|
||||
// Create Stripe instance once Stripe.js loads
|
||||
this.setState(state => ({
|
||||
...state,
|
||||
stripe: window.Stripe(stripePublicKey)
|
||||
}));
|
||||
}
|
||||
|
||||
componentWillUnmount() {
|
||||
const stripeMountPoint = document.querySelector('#stripe-js');
|
||||
if (stripeMountPoint) {
|
||||
stripeMountPoint.removeEventListener('load', this.handleStripeLoad);
|
||||
}
|
||||
}
|
||||
|
||||
renderMaybe() {
|
||||
const { closeDonationModal } = this.props;
|
||||
const handleClick = e => {
|
||||
e.preventDefault();
|
||||
return closeDonationModal();
|
||||
};
|
||||
return (
|
||||
<div className='modal-close-btn-container'>
|
||||
<Button bsStyle='link' onClick={handleClick}>
|
||||
Close
|
||||
</Button>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
render() {
|
||||
const { show } = this.props;
|
||||
if (show) {
|
||||
ga.modalview('/donation-modal');
|
||||
}
|
||||
return (
|
||||
<StripeProvider stripe={this.state.stripe}>
|
||||
<Elements>
|
||||
<Modal bsSize='lg' className='donation-modal' show={show}>
|
||||
<Modal.Header className='fcc-modal'>
|
||||
<Modal.Title className='text-center'>
|
||||
Support Our NonProfit
|
||||
</Modal.Title>
|
||||
</Modal.Header>
|
||||
<Modal.Body>
|
||||
<DonateText />
|
||||
<DonateForm />
|
||||
{this.renderMaybe()}
|
||||
</Modal.Body>
|
||||
<Modal.Footer>
|
||||
<PoweredByStripe />
|
||||
</Modal.Footer>
|
||||
</Modal>
|
||||
</Elements>
|
||||
</StripeProvider>
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
DonateModal.displayName = 'DonateModal';
|
||||
DonateModal.propTypes = propTypes;
|
||||
|
||||
export default connect(
|
||||
mapStateToProps,
|
||||
mapDispatchToProps,
|
||||
(state, dispatch, own) => ({ ...state, ...dispatch, ...own }),
|
||||
{
|
||||
pure: false
|
||||
}
|
||||
)(DonateModal);
|
@ -1 +0,0 @@
|
||||
export { default } from './components/DonateModal';
|
@ -10,7 +10,6 @@ import {
|
||||
isSignedInSelector
|
||||
} from '../../redux';
|
||||
import createRedirect from '../../components/createRedirect';
|
||||
import DonateModal from '../Donation';
|
||||
|
||||
import 'prismjs/themes/prism.css';
|
||||
import './prism.css';
|
||||
@ -48,7 +47,6 @@ function LearnLayout({
|
||||
return (
|
||||
<Fragment>
|
||||
<main id='learn-app-wrapper'>{children}</main>
|
||||
<DonateModal />
|
||||
</Fragment>
|
||||
);
|
||||
}
|
||||
|
@ -3,12 +3,8 @@ import store from 'store';
|
||||
|
||||
import {
|
||||
isSignedInSelector,
|
||||
openDonationModal,
|
||||
showDonationSelector,
|
||||
donationRequested,
|
||||
updateComplete,
|
||||
updateFailed,
|
||||
userSelector
|
||||
updateFailed
|
||||
} from '../../../redux';
|
||||
|
||||
import { post } from '../../../utils/ajax';
|
||||
@ -41,26 +37,9 @@ function* updateSuccessMessageSaga() {
|
||||
yield put(updateSuccessMessage(randomCompliment()));
|
||||
}
|
||||
|
||||
function* showDonateModalSaga() {
|
||||
let { isDonating } = yield select(userSelector);
|
||||
let shouldShowDonate = yield select(showDonationSelector);
|
||||
/**
|
||||
* We are disabling donation modals for now.
|
||||
*/
|
||||
shouldShowDonate = false;
|
||||
/**
|
||||
* We are disabling donation modals for now.
|
||||
*/
|
||||
if (!isDonating && shouldShowDonate) {
|
||||
yield put(openDonationModal());
|
||||
yield put(donationRequested());
|
||||
}
|
||||
}
|
||||
|
||||
export function createCurrentChallengeSaga(types) {
|
||||
return [
|
||||
takeEvery(types.challengeMounted, currentChallengeSaga),
|
||||
takeEvery(types.challengeMounted, updateSuccessMessageSaga),
|
||||
takeEvery(types.challengeMounted, showDonateModalSaga)
|
||||
takeEvery(types.challengeMounted, updateSuccessMessageSaga)
|
||||
];
|
||||
}
|
||||
|
Reference in New Issue
Block a user