fix: remove donation prevention (#37867)
This commit is contained in:
@ -11,9 +11,7 @@ import {
|
|||||||
showCert,
|
showCert,
|
||||||
userFetchStateSelector,
|
userFetchStateSelector,
|
||||||
usernameSelector,
|
usernameSelector,
|
||||||
isDonatingSelector,
|
isDonatingSelector
|
||||||
isDonationRequestedSelector,
|
|
||||||
preventDonationRequests
|
|
||||||
} from '../redux';
|
} from '../redux';
|
||||||
import validCertNames from '../../utils/validCertNames';
|
import validCertNames from '../../utils/validCertNames';
|
||||||
import { createFlashMessage } from '../components/Flash/redux';
|
import { createFlashMessage } from '../components/Flash/redux';
|
||||||
@ -41,9 +39,7 @@ const propTypes = {
|
|||||||
errored: PropTypes.bool
|
errored: PropTypes.bool
|
||||||
}),
|
}),
|
||||||
isDonating: PropTypes.bool,
|
isDonating: PropTypes.bool,
|
||||||
isDonationRequested: PropTypes.bool,
|
|
||||||
issueDate: PropTypes.string,
|
issueDate: PropTypes.string,
|
||||||
preventDonationRequests: PropTypes.func,
|
|
||||||
showCert: PropTypes.func.isRequired,
|
showCert: PropTypes.func.isRequired,
|
||||||
signedInUserName: PropTypes.string,
|
signedInUserName: PropTypes.string,
|
||||||
userFetchState: PropTypes.shape({
|
userFetchState: PropTypes.shape({
|
||||||
@ -62,31 +58,19 @@ const mapStateToProps = (state, { certName }) => {
|
|||||||
usernameSelector,
|
usernameSelector,
|
||||||
userFetchStateSelector,
|
userFetchStateSelector,
|
||||||
isDonatingSelector,
|
isDonatingSelector,
|
||||||
isDonationRequestedSelector,
|
(cert, fetchState, signedInUserName, userFetchState, isDonating) => ({
|
||||||
(
|
|
||||||
cert,
|
|
||||||
fetchState,
|
|
||||||
signedInUserName,
|
|
||||||
userFetchState,
|
|
||||||
isDonating,
|
|
||||||
isDonationRequested
|
|
||||||
) => ({
|
|
||||||
cert,
|
cert,
|
||||||
fetchState,
|
fetchState,
|
||||||
validCertName,
|
validCertName,
|
||||||
signedInUserName,
|
signedInUserName,
|
||||||
userFetchState,
|
userFetchState,
|
||||||
isDonating,
|
isDonating
|
||||||
isDonationRequested
|
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
const mapDispatchToProps = dispatch =>
|
const mapDispatchToProps = dispatch =>
|
||||||
bindActionCreators(
|
bindActionCreators({ createFlashMessage, showCert }, dispatch);
|
||||||
{ createFlashMessage, showCert, preventDonationRequests },
|
|
||||||
dispatch
|
|
||||||
);
|
|
||||||
|
|
||||||
class ShowCertification extends Component {
|
class ShowCertification extends Component {
|
||||||
componentDidMount() {
|
componentDidMount() {
|
||||||
@ -103,10 +87,8 @@ class ShowCertification extends Component {
|
|||||||
validCertName,
|
validCertName,
|
||||||
createFlashMessage,
|
createFlashMessage,
|
||||||
certName,
|
certName,
|
||||||
preventDonationRequests,
|
|
||||||
signedInUserName,
|
signedInUserName,
|
||||||
isDonating,
|
isDonating,
|
||||||
isDonationRequested,
|
|
||||||
userFetchState
|
userFetchState
|
||||||
} = this.props;
|
} = this.props;
|
||||||
|
|
||||||
@ -142,12 +124,7 @@ class ShowCertification extends Component {
|
|||||||
|
|
||||||
let conditionalDonationMessage = '';
|
let conditionalDonationMessage = '';
|
||||||
|
|
||||||
if (
|
if (userComplete && signedInUserName === username && !isDonating) {
|
||||||
userComplete &&
|
|
||||||
signedInUserName === username &&
|
|
||||||
!isDonating &&
|
|
||||||
!isDonationRequested
|
|
||||||
) {
|
|
||||||
conditionalDonationMessage = (
|
conditionalDonationMessage = (
|
||||||
<Grid>
|
<Grid>
|
||||||
<Row className='certification-donation text-center'>
|
<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
|
around the world. Make a tax-deductible supporting donation to our
|
||||||
nonprofit today.
|
nonprofit today.
|
||||||
</p>
|
</p>
|
||||||
<Link
|
<Link className={'btn'} to={'/donate'}>
|
||||||
className={'btn'}
|
|
||||||
onClick={preventDonationRequests}
|
|
||||||
to={'/donate'}
|
|
||||||
>
|
|
||||||
Check out our donation dashboard
|
Check out our donation dashboard
|
||||||
</Link>
|
</Link>
|
||||||
</Row>
|
</Row>
|
||||||
|
@ -2,8 +2,8 @@ import { put, select, takeEvery, delay } from 'redux-saga/effects';
|
|||||||
|
|
||||||
import {
|
import {
|
||||||
openDonationModal,
|
openDonationModal,
|
||||||
shouldRequestDonationSelector,
|
preventDonationRequests,
|
||||||
preventDonationRequests
|
shouldRequestDonationSelector
|
||||||
} from './';
|
} from './';
|
||||||
|
|
||||||
function* showDonateModalSaga() {
|
function* showDonateModalSaga() {
|
||||||
|
@ -35,7 +35,6 @@ const initialState = {
|
|||||||
canRequestDonation: false,
|
canRequestDonation: false,
|
||||||
completionCount: 0,
|
completionCount: 0,
|
||||||
currentChallengeId: store.get(CURRENT_CHALLENGE_KEY),
|
currentChallengeId: store.get(CURRENT_CHALLENGE_KEY),
|
||||||
donationRequested: false,
|
|
||||||
showCert: {},
|
showCert: {},
|
||||||
showCertFetchState: {
|
showCertFetchState: {
|
||||||
...defaultFetchState
|
...defaultFetchState
|
||||||
@ -145,7 +144,6 @@ export const completedChallengesSelector = state =>
|
|||||||
userSelector(state).completedChallenges || [];
|
userSelector(state).completedChallenges || [];
|
||||||
export const completionCountSelector = state => state[ns].completionCount;
|
export const completionCountSelector = state => state[ns].completionCount;
|
||||||
export const currentChallengeIdSelector = state => state[ns].currentChallengeId;
|
export const currentChallengeIdSelector = state => state[ns].currentChallengeId;
|
||||||
export const isDonationRequestedSelector = state => state[ns].donationRequested;
|
|
||||||
export const isDonatingSelector = state => userSelector(state).isDonating;
|
export const isDonatingSelector = state => userSelector(state).isDonating;
|
||||||
|
|
||||||
export const isOnlineSelector = state => state[ns].isOnline;
|
export const isOnlineSelector = state => state[ns].isOnline;
|
||||||
@ -157,18 +155,9 @@ export const signInLoadingSelector = state =>
|
|||||||
export const showCertSelector = state => state[ns].showCert;
|
export const showCertSelector = state => state[ns].showCert;
|
||||||
export const showCertFetchStateSelector = state => state[ns].showCertFetchState;
|
export const showCertFetchStateSelector = state => state[ns].showCertFetchState;
|
||||||
|
|
||||||
export const shouldRequestDonationSelector = state => {
|
export const shouldRequestDonationSelector = state =>
|
||||||
const isDonationRequested = isDonationRequestedSelector(state);
|
!isDonatingSelector(state) && state[ns].canRequestDonation;
|
||||||
const isDonating = isDonatingSelector(state);
|
|
||||||
if (
|
|
||||||
isDonationRequested === false &&
|
|
||||||
isDonating === false &&
|
|
||||||
state[ns].canRequestDonation
|
|
||||||
) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
};
|
|
||||||
export const userByNameSelector = username => state => {
|
export const userByNameSelector = username => state => {
|
||||||
const { user } = state[ns];
|
const { user } = state[ns];
|
||||||
return username in user ? user[username] : {};
|
return username in user ? user[username] : {};
|
||||||
@ -299,7 +288,7 @@ export const reducer = handleActions(
|
|||||||
}),
|
}),
|
||||||
[types.preventDonationRequests]: state => ({
|
[types.preventDonationRequests]: state => ({
|
||||||
...state,
|
...state,
|
||||||
donationRequested: true
|
canRequestDonation: false
|
||||||
}),
|
}),
|
||||||
[types.resetUserData]: state => ({
|
[types.resetUserData]: state => ({
|
||||||
...state,
|
...state,
|
||||||
|
Reference in New Issue
Block a user