diff --git a/client/src/client-only-routes/ShowCertification.js b/client/src/client-only-routes/ShowCertification.js index 41267ef498..b1eb7b86ff 100644 --- a/client/src/client-only-routes/ShowCertification.js +++ b/client/src/client-only-routes/ShowCertification.js @@ -11,9 +11,7 @@ import { showCert, userFetchStateSelector, usernameSelector, - isDonatingSelector, - isDonationRequestedSelector, - preventDonationRequests + isDonatingSelector } from '../redux'; import validCertNames from '../../utils/validCertNames'; import { createFlashMessage } from '../components/Flash/redux'; @@ -41,9 +39,7 @@ const propTypes = { errored: PropTypes.bool }), isDonating: PropTypes.bool, - isDonationRequested: PropTypes.bool, issueDate: PropTypes.string, - preventDonationRequests: PropTypes.func, showCert: PropTypes.func.isRequired, signedInUserName: PropTypes.string, userFetchState: PropTypes.shape({ @@ -62,31 +58,19 @@ const mapStateToProps = (state, { certName }) => { usernameSelector, userFetchStateSelector, isDonatingSelector, - isDonationRequestedSelector, - ( - cert, - fetchState, - signedInUserName, - userFetchState, - isDonating, - isDonationRequested - ) => ({ + (cert, fetchState, signedInUserName, userFetchState, isDonating) => ({ cert, fetchState, validCertName, signedInUserName, userFetchState, - isDonating, - isDonationRequested + isDonating }) ); }; const mapDispatchToProps = dispatch => - bindActionCreators( - { createFlashMessage, showCert, preventDonationRequests }, - dispatch - ); + bindActionCreators({ createFlashMessage, showCert }, dispatch); class ShowCertification extends Component { componentDidMount() { @@ -103,10 +87,8 @@ class ShowCertification extends Component { validCertName, createFlashMessage, certName, - preventDonationRequests, signedInUserName, isDonating, - isDonationRequested, userFetchState } = this.props; @@ -142,12 +124,7 @@ class ShowCertification extends Component { let conditionalDonationMessage = ''; - if ( - userComplete && - signedInUserName === username && - !isDonating && - !isDonationRequested - ) { + if (userComplete && signedInUserName === username && !isDonating) { conditionalDonationMessage = ( @@ -158,11 +135,7 @@ class ShowCertification extends Component { around the world. Make a tax-deductible supporting donation to our nonprofit today.

- + Check out our donation dashboard
diff --git a/client/src/redux/donation-saga.js b/client/src/redux/donation-saga.js index f486c5e56d..1657302127 100644 --- a/client/src/redux/donation-saga.js +++ b/client/src/redux/donation-saga.js @@ -2,8 +2,8 @@ import { put, select, takeEvery, delay } from 'redux-saga/effects'; import { openDonationModal, - shouldRequestDonationSelector, - preventDonationRequests + preventDonationRequests, + shouldRequestDonationSelector } from './'; function* showDonateModalSaga() { diff --git a/client/src/redux/index.js b/client/src/redux/index.js index ed21b69934..338808dde3 100644 --- a/client/src/redux/index.js +++ b/client/src/redux/index.js @@ -35,7 +35,6 @@ const initialState = { canRequestDonation: false, completionCount: 0, currentChallengeId: store.get(CURRENT_CHALLENGE_KEY), - donationRequested: false, showCert: {}, showCertFetchState: { ...defaultFetchState @@ -145,7 +144,6 @@ export const completedChallengesSelector = state => userSelector(state).completedChallenges || []; export const completionCountSelector = state => state[ns].completionCount; export const currentChallengeIdSelector = state => state[ns].currentChallengeId; -export const isDonationRequestedSelector = state => state[ns].donationRequested; export const isDonatingSelector = state => userSelector(state).isDonating; export const isOnlineSelector = state => state[ns].isOnline; @@ -157,18 +155,9 @@ export const signInLoadingSelector = state => export const showCertSelector = state => state[ns].showCert; export const showCertFetchStateSelector = state => state[ns].showCertFetchState; -export const shouldRequestDonationSelector = state => { - const isDonationRequested = isDonationRequestedSelector(state); - const isDonating = isDonatingSelector(state); - if ( - isDonationRequested === false && - isDonating === false && - state[ns].canRequestDonation - ) { - return true; - } - return false; -}; +export const shouldRequestDonationSelector = state => + !isDonatingSelector(state) && state[ns].canRequestDonation; + export const userByNameSelector = username => state => { const { user } = state[ns]; return username in user ? user[username] : {}; @@ -299,7 +288,7 @@ export const reducer = handleActions( }), [types.preventDonationRequests]: state => ({ ...state, - donationRequested: true + canRequestDonation: false }), [types.resetUserData]: state => ({ ...state,