Skip to content

PROD-2504 - prevent FCC donate modal #37

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 26, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 3 additions & 20 deletions client/src/components/layouts/learn.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,8 @@ import { Loader } from '../../components/helpers';
import {
userSelector,
userFetchStateSelector,
isSignedInSelector,
tryToShowDonationModal
isSignedInSelector
} from '../../redux';
import DonateModal from '../Donation/donation-modal';

import './prism.css';
import './prism-night.css';
Expand Down Expand Up @@ -37,28 +35,16 @@ const mapStateToProps = createSelector(
})
);

const mapDispatchToProps = {
tryToShowDonationModal
};
const mapDispatchToProps = {};

type LearnLayoutProps = {
isSignedIn?: boolean;
fetchState: FetchState;
user: User;
tryToShowDonationModal: () => void;
children?: React.ReactNode;
};

function LearnLayout({
fetchState,
tryToShowDonationModal,
children
}: LearnLayoutProps): JSX.Element {
useEffect(() => {
tryToShowDonationModal();
// eslint-disable-next-line react-hooks/exhaustive-deps
}, []);

function LearnLayout({ fetchState, children }: LearnLayoutProps): JSX.Element {
useEffect(() => {
return () => {
const metaTag = document.querySelector(`meta[name="robots"]`);
Expand All @@ -78,9 +64,6 @@ function LearnLayout({
<meta content='noindex' name='robots' />
</Helmet>
<main id='learn-app-wrapper'>{children}</main>
{/* eslint-disable-next-line @typescript-eslint/ban-ts-comment */
/* @ts-ignore */}
<DonateModal />
</>
);
}
Expand Down
2 changes: 0 additions & 2 deletions client/src/redux/action-types.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ export const actionTypes = createTypes(
[
'appMount',
'hardGoTo',
'allowBlockDonationRequests',
'closeDonationModal',
'hideCodeAlly',
'preventBlockDonationRequests',
Expand All @@ -16,7 +15,6 @@ export const actionTypes = createTypes(
'serverStatusChange',
'resetUserData',
'tryToShowCodeAlly',
'tryToShowDonationModal',
'executeGA',
'showCodeAlly',
'submitComplete',
Expand Down
15 changes: 0 additions & 15 deletions client/src/redux/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import { createAcceptTermsSaga } from './accept-terms-saga';
import { actionTypes } from './action-types';
import { createAppMountSaga } from './app-mount-saga';
import { createCodeAllySaga } from './codeally-saga';
import { createDonationSaga } from './donation-saga';
import failedUpdatesEpic from './failed-updates-epic';
import { createFetchUserSaga } from './fetch-user-saga';
import { createGaSaga } from './ga-saga';
Expand Down Expand Up @@ -76,7 +75,6 @@ export const sagas = [
...createAcceptTermsSaga(actionTypes),
...createAppMountSaga(actionTypes),
...createCodeAllySaga(actionTypes),
...createDonationSaga(actionTypes),
...createGaSaga(actionTypes),
...createFetchUserSaga(actionTypes),
...createShowCertSaga(actionTypes),
Expand All @@ -87,15 +85,8 @@ export const sagas = [

export const appMount = createAction(actionTypes.appMount);

export const tryToShowDonationModal = createAction(
actionTypes.tryToShowDonationModal
);

export const executeGA = createAction(actionTypes.executeGA);

export const allowBlockDonationRequests = createAction(
actionTypes.allowBlockDonationRequests
);
export const closeDonationModal = createAction(actionTypes.closeDonationModal);
export const openDonationModal = createAction(actionTypes.openDonationModal);
export const preventBlockDonationRequests = createAction(
Expand Down Expand Up @@ -444,12 +435,6 @@ export const reducer = handleActions(
}
};
},
[actionTypes.allowBlockDonationRequests]: (state, { payload }) => {
return {
...state,
recentlyClaimedBlock: payload
};
},
[actionTypes.updateDonationFormState]: (state, { payload }) => ({
...state,
donationFormState: { ...state.donationFormState, ...payload }
Expand Down
21 changes: 1 addition & 20 deletions client/src/templates/Challenges/components/completion-modal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,7 @@ import { createSelector } from 'reselect';
import { dasherize } from '../../../../../utils/slugs';
import { isProject } from '../../../../utils/challenge-types';
import Login from '../../../components/Header/components/Login';
import {
isSignedInSelector,
executeGA,
allowBlockDonationRequests
} from '../../../redux';
import { isSignedInSelector, executeGA } from '../../../redux';
import { AllChallengeNode, ChallengeFiles } from '../../../redux/prop-types';

import {
Expand Down Expand Up @@ -68,9 +64,6 @@ const mapDispatchToProps = function (dispatch: Dispatch) {
submitChallenge: () => {
dispatch(submitChallenge());
},
allowBlockDonationRequests: (block: string) => {
dispatch(allowBlockDonationRequests(block));
},
executeGA
};
return () => dispatchers;
Expand All @@ -97,7 +90,6 @@ export function getCompletedPercent(
}

interface CompletionModalsProps {
allowBlockDonationRequests: (arg0: string) => void;
block: string;
blockName: string;
certification: string;
Expand Down Expand Up @@ -187,17 +179,6 @@ export class CompletionModalInner extends Component<

handleSubmit(): void {
this.props.submitChallenge();
this.checkBlockCompletion();
}

// check block completion for donation
checkBlockCompletion(): void {
if (
this.state.completedPercent === 100 &&
!this.props.completedChallengesIds.includes(this.props.id)
) {
this.props.allowBlockDonationRequests(this.props.blockName);
}
}

componentWillUnmount(): void {
Expand Down
4 changes: 1 addition & 3 deletions client/src/templates/Challenges/components/tool-panel.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
import {
Button,
} from '@freecodecamp/react-bootstrap';
import { Button } from '@freecodecamp/react-bootstrap';
import React from 'react';
import { useTranslation } from 'react-i18next';
import { connect } from 'react-redux';
Expand Down
6 changes: 0 additions & 6 deletions client/src/templates/Introduction/super-block-intro.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ import { bindActionCreators, Dispatch } from 'redux';
import { createSelector } from 'reselect';

import { SuperBlocks } from '../../../../config/certification-settings';
import DonateModal from '../../components/Donation/donation-modal';
import Login from '../../components/Header/components/Login';
import Map from '../../components/Map';
import { Spacer } from '../../components/helpers';
Expand All @@ -20,7 +19,6 @@ import {
userFetchStateSelector,
signInLoadingSelector,
isSignedInSelector,
tryToShowDonationModal,
userSelector
} from '../../redux';
import { MarkdownRemark, AllChallengeNode, User } from '../../redux/prop-types';
Expand Down Expand Up @@ -54,7 +52,6 @@ type SuperBlockProp = {
resetExpansion: () => void;
t: TFunction;
toggleBlock: (arg0: string) => void;
tryToShowDonationModal: () => void;
user: User;
};

Expand Down Expand Up @@ -86,7 +83,6 @@ const mapStateToProps = (state: Record<string, unknown>) => {
const mapDispatchToProps = (dispatch: Dispatch) =>
bindActionCreators(
{
tryToShowDonationModal,
resetExpansion,
toggleBlock: b => toggleBlock(b)
},
Expand All @@ -96,7 +92,6 @@ const mapDispatchToProps = (dispatch: Dispatch) =>
const SuperBlockIntroductionPage = (props: SuperBlockProp) => {
useEffect(() => {
initializeExpandedState();
props.tryToShowDonationModal();

setTimeout(() => {
configureAnchors({ offset: -40, scrollDuration: 400 });
Expand Down Expand Up @@ -245,7 +240,6 @@ const SuperBlockIntroductionPage = (props: SuperBlockProp) => {
</Col>
</Row>
</Grid>
<DonateModal location={props.location} />
</>
);
};
Expand Down