diff --git a/client/src/pages/email-sign-up.tsx b/client/src/pages/email-sign-up.tsx
index 0425eef67ea..397757d1bdb 100644
--- a/client/src/pages/email-sign-up.tsx
+++ b/client/src/pages/email-sign-up.tsx
@@ -1,8 +1,7 @@
import { Row, Col, Button, Grid } from '@freecodecamp/react-bootstrap';
import React, { useEffect, useRef } from 'react';
import Helmet from 'react-helmet';
-import type { TFunction } from 'i18next';
-import { withTranslation, Trans } from 'react-i18next';
+import { useTranslation, Trans } from 'react-i18next';
import { connect } from 'react-redux';
import { bindActionCreators } from 'redux';
import type { Dispatch } from 'redux';
@@ -24,7 +23,6 @@ interface AcceptPrivacyTermsProps {
acceptTerms: (accept: boolean | null) => void;
acceptedPrivacyTerms: boolean;
isSignedIn: boolean;
- t: TFunction;
showLoading: boolean;
completedChallengeCount?: number;
}
@@ -51,77 +49,78 @@ const mapDispatchToProps = (dispatch: Dispatch) =>
bindActionCreators({ acceptTerms }, dispatch);
const RedirectToLearn = createRedirect('/learn');
+function EmailListOptIn({
+ isSignedIn,
+ acceptTerms
+}: {
+ isSignedIn: boolean;
+ acceptTerms: (accepted: boolean) => void;
+}) {
+ const { t } = useTranslation();
+ if (isSignedIn) {
+ return (
+
+
+
+
+
+
+
+
+
+
+ );
+ } else {
+ return (
+
+
+
+
+
+ );
+ }
+}
+
function AcceptPrivacyTerms({
acceptTerms,
acceptedPrivacyTerms,
isSignedIn,
- t,
showLoading,
completedChallengeCount = 0
}: AcceptPrivacyTermsProps) {
+ const { t } = useTranslation();
const acceptedPrivacyRef = useRef(acceptedPrivacyTerms);
const acceptTermsRef = useRef(acceptTerms);
useEffect(() => {
acceptedPrivacyRef.current = acceptedPrivacyTerms;
acceptTermsRef.current = acceptTerms;
- });
-
- function onClick(isWeeklyEmailAccepted: boolean) {
- acceptTerms(isWeeklyEmailAccepted);
- }
-
- function renderEmailListOptIn(isSignedIn: boolean, showLoading: boolean) {
- if (showLoading) {
- return ;
- }
- if (isSignedIn) {
- return (
-
-
-
-
-
-
-
-
-
-
- );
- } else {
- return (
-
-
-
-
-
- );
- }
- }
+ // eslint-disable-next-line react-hooks/exhaustive-deps
+ }, []);
return acceptedPrivacyTerms ? (
@@ -160,7 +159,11 @@ function AcceptPrivacyTerms({
{t('misc.email-blast')}
- {renderEmailListOptIn(isSignedIn, showLoading)}
+ {showLoading ? (
+
+ ) : (
+
+ )}
@@ -170,7 +173,4 @@ function AcceptPrivacyTerms({
);
}
-export default connect(
- mapStateToProps,
- mapDispatchToProps
-)(withTranslation()(AcceptPrivacyTerms));
+export default connect(mapStateToProps, mapDispatchToProps)(AcceptPrivacyTerms);