From 83ac3c5f958fefd8c520dde6cb0872c5839ca409 Mon Sep 17 00:00:00 2001 From: Mrugesh Mohapatra Date: Tue, 5 Nov 2019 19:19:54 +0530 Subject: [PATCH] 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 --- .../Donation/components/DonateModal.js | 134 ------------------ client/src/components/Donation/index.js | 1 - client/src/components/layouts/Learn.js | 2 - .../redux/current-challenge-saga.js | 25 +--- 4 files changed, 2 insertions(+), 160 deletions(-) delete mode 100644 client/src/components/Donation/components/DonateModal.js delete mode 100644 client/src/components/Donation/index.js diff --git a/client/src/components/Donation/components/DonateModal.js b/client/src/components/Donation/components/DonateModal.js deleted file mode 100644 index ecfe6f3ae0..0000000000 --- a/client/src/components/Donation/components/DonateModal.js +++ /dev/null @@ -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 ( -
- -
- ); - } - - render() { - const { show } = this.props; - if (show) { - ga.modalview('/donation-modal'); - } - return ( - - - - - - Support Our NonProfit - - - - - - {this.renderMaybe()} - - - - - - - - ); - } -} - -DonateModal.displayName = 'DonateModal'; -DonateModal.propTypes = propTypes; - -export default connect( - mapStateToProps, - mapDispatchToProps, - (state, dispatch, own) => ({ ...state, ...dispatch, ...own }), - { - pure: false - } -)(DonateModal); diff --git a/client/src/components/Donation/index.js b/client/src/components/Donation/index.js deleted file mode 100644 index 39cf10aca2..0000000000 --- a/client/src/components/Donation/index.js +++ /dev/null @@ -1 +0,0 @@ -export { default } from './components/DonateModal'; diff --git a/client/src/components/layouts/Learn.js b/client/src/components/layouts/Learn.js index 657ffc767f..89f86c8695 100644 --- a/client/src/components/layouts/Learn.js +++ b/client/src/components/layouts/Learn.js @@ -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 (
{children}
-
); } diff --git a/client/src/templates/Challenges/redux/current-challenge-saga.js b/client/src/templates/Challenges/redux/current-challenge-saga.js index 656c9a3c13..685cad5191 100644 --- a/client/src/templates/Challenges/redux/current-challenge-saga.js +++ b/client/src/templates/Challenges/redux/current-challenge-saga.js @@ -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) ]; }