fix: remove donation prevention (#37867)

This commit is contained in:
Ahmad Abdolsaheb
2019-12-06 08:43:23 +03:00
committed by GitHub
parent 7deecf8245
commit d7c4fd7fea
3 changed files with 12 additions and 50 deletions

View File

@ -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 = (
<Grid>
<Row className='certification-donation text-center'>
@ -158,11 +135,7 @@ class ShowCertification extends Component {
around the world. Make a tax-deductible supporting donation to our
nonprofit today.
</p>
<Link
className={'btn'}
onClick={preventDonationRequests}
to={'/donate'}
>
<Link className={'btn'} to={'/donate'}>
Check out our donation dashboard
</Link>
</Row>

View File

@ -2,8 +2,8 @@ import { put, select, takeEvery, delay } from 'redux-saga/effects';
import {
openDonationModal,
shouldRequestDonationSelector,
preventDonationRequests
preventDonationRequests,
shouldRequestDonationSelector
} from './';
function* showDonateModalSaga() {

View File

@ -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,