fix(client): add loader for email sign up (#45560)
Add a loader for the buttons. Co-authored-by: Oliver Eyton-Williams ojeytonwilliams@gmail.com
This commit is contained in:
committed by
GitHub
parent
40d7dc4af9
commit
111a402378
@@ -20,7 +20,18 @@ describe('<EmailSignUp />', () => {
|
|||||||
|
|
||||||
describe('Non-Authenticated user "not accepted terms and condition"', () => {
|
describe('Non-Authenticated user "not accepted terms and condition"', () => {
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
const initialState = { app: { appUsername: '', user: {} } };
|
const initialState = {
|
||||||
|
app: {
|
||||||
|
appUsername: '',
|
||||||
|
user: {},
|
||||||
|
userFetchState: {
|
||||||
|
pending: false,
|
||||||
|
complete: true,
|
||||||
|
errored: false,
|
||||||
|
error: null
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
const store = mockStore(initialState);
|
const store = mockStore(initialState);
|
||||||
const container = renderer.create(
|
const container = renderer.create(
|
||||||
@@ -57,6 +68,12 @@ describe('<EmailSignUp />', () => {
|
|||||||
acceptedPrivacyTerms: true,
|
acceptedPrivacyTerms: true,
|
||||||
name: 'John Doe'
|
name: 'John Doe'
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
userFetchState: {
|
||||||
|
pending: false,
|
||||||
|
complete: true,
|
||||||
|
errored: false,
|
||||||
|
error: null
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@@ -8,10 +8,15 @@ import type { Dispatch } from 'redux';
|
|||||||
import { createSelector } from 'reselect';
|
import { createSelector } from 'reselect';
|
||||||
import IntroDescription from '../components/Intro/components/IntroDescription';
|
import IntroDescription from '../components/Intro/components/IntroDescription';
|
||||||
import createRedirect from '../components/create-redirect';
|
import createRedirect from '../components/create-redirect';
|
||||||
import { ButtonSpacer, Spacer } from '../components/helpers';
|
import { ButtonSpacer, Spacer, Loader } from '../components/helpers';
|
||||||
import { apiLocation } from '../../../config/env.json';
|
import { apiLocation } from '../../../config/env.json';
|
||||||
|
|
||||||
import { acceptTerms, userSelector, isSignedInSelector } from '../redux';
|
import {
|
||||||
|
acceptTerms,
|
||||||
|
userSelector,
|
||||||
|
isSignedInSelector,
|
||||||
|
signInLoadingSelector
|
||||||
|
} from '../redux';
|
||||||
|
|
||||||
import './email-sign-up.css';
|
import './email-sign-up.css';
|
||||||
interface AcceptPrivacyTermsProps {
|
interface AcceptPrivacyTermsProps {
|
||||||
@@ -19,17 +24,21 @@ interface AcceptPrivacyTermsProps {
|
|||||||
acceptedPrivacyTerms: boolean;
|
acceptedPrivacyTerms: boolean;
|
||||||
isSignedIn: boolean;
|
isSignedIn: boolean;
|
||||||
t: TFunction;
|
t: TFunction;
|
||||||
|
showLoading: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
const mapStateToProps = createSelector(
|
const mapStateToProps = createSelector(
|
||||||
userSelector,
|
userSelector,
|
||||||
isSignedInSelector,
|
isSignedInSelector,
|
||||||
|
signInLoadingSelector,
|
||||||
(
|
(
|
||||||
{ acceptedPrivacyTerms }: { acceptedPrivacyTerms: boolean },
|
{ acceptedPrivacyTerms }: { acceptedPrivacyTerms: boolean },
|
||||||
isSignedIn: boolean
|
isSignedIn: boolean,
|
||||||
|
showLoading: boolean
|
||||||
) => ({
|
) => ({
|
||||||
acceptedPrivacyTerms,
|
acceptedPrivacyTerms,
|
||||||
isSignedIn
|
isSignedIn,
|
||||||
|
showLoading
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
const mapDispatchToProps = (dispatch: Dispatch) =>
|
const mapDispatchToProps = (dispatch: Dispatch) =>
|
||||||
@@ -40,7 +49,8 @@ function AcceptPrivacyTerms({
|
|||||||
acceptTerms,
|
acceptTerms,
|
||||||
acceptedPrivacyTerms,
|
acceptedPrivacyTerms,
|
||||||
isSignedIn,
|
isSignedIn,
|
||||||
t
|
t,
|
||||||
|
showLoading
|
||||||
}: AcceptPrivacyTermsProps) {
|
}: AcceptPrivacyTermsProps) {
|
||||||
const acceptedPrivacyRef = useRef(acceptedPrivacyTerms);
|
const acceptedPrivacyRef = useRef(acceptedPrivacyTerms);
|
||||||
const acceptTermsRef = useRef(acceptTerms);
|
const acceptTermsRef = useRef(acceptTerms);
|
||||||
@@ -67,7 +77,10 @@ function AcceptPrivacyTerms({
|
|||||||
acceptTerms(isWeeklyEmailAccepted);
|
acceptTerms(isWeeklyEmailAccepted);
|
||||||
}
|
}
|
||||||
|
|
||||||
function renderEmailListOptin(isSignedIn: boolean) {
|
function renderEmailListOptin(isSignedIn: boolean, showLoading: boolean) {
|
||||||
|
if (showLoading) {
|
||||||
|
return <Loader fullScreen={true} />;
|
||||||
|
}
|
||||||
if (isSignedIn) {
|
if (isSignedIn) {
|
||||||
return (
|
return (
|
||||||
<Row>
|
<Row>
|
||||||
@@ -138,7 +151,7 @@ function AcceptPrivacyTerms({
|
|||||||
<p>{t('misc.email-blast')}</p>
|
<p>{t('misc.email-blast')}</p>
|
||||||
<Spacer />
|
<Spacer />
|
||||||
</Col>
|
</Col>
|
||||||
{renderEmailListOptin(isSignedIn)}
|
{renderEmailListOptin(isSignedIn, showLoading)}
|
||||||
<Col xs={12}>
|
<Col xs={12}>
|
||||||
<Spacer />
|
<Spacer />
|
||||||
</Col>
|
</Col>
|
||||||
|
Reference in New Issue
Block a user