Skip to content
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

Only show fancy loading page when we are submitting verifications #5787

Merged
merged 5 commits into from
Oct 13, 2021
Merged
Show file tree
Hide file tree
Changes from 4 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: 18 additions & 5 deletions src/components/FullscreenLoadingIndicator.js
Original file line number Diff line number Diff line change
@@ -1,28 +1,41 @@
import _ from 'underscore';
import React from 'react';
import PropTypes from 'prop-types';
import {ActivityIndicator, StyleSheet, View} from 'react-native';
import styles from '../styles/styles';
import themeColors from '../styles/themes/default';
import stylePropTypes from '../styles/stylePropTypes';

const propTypes = {
/** Controls whether the loader is mounted and displayed */
visible: PropTypes.bool,

/** Additional style props */
style: stylePropTypes,
};

const defaultProps = {
visible: true,
style: [],
};

/**
* Loading indication component intended to cover the whole page, while the page prepares for initial render
*
* @returns {JSX.Element}
*/
const FullScreenLoadingIndicator = ({visible}) => visible && (
<View style={[StyleSheet.absoluteFillObject, styles.fullScreenLoading]}>
<ActivityIndicator color={themeColors.spinner} size="large" />
</View>
);
const FullScreenLoadingIndicator = ({visible, style}) => {
Jag96 marked this conversation as resolved.
Show resolved Hide resolved
if (!visible) {
return null;
}

const additionalStyles = _.isArray(style) ? style : [style];
return (
<View style={[StyleSheet.absoluteFillObject, styles.fullScreenLoading, ...additionalStyles]}>
<ActivityIndicator color={themeColors.spinner} size="large" />
</View>
);
};

FullScreenLoadingIndicator.propTypes = propTypes;
FullScreenLoadingIndicator.defaultProps = defaultProps;
Expand Down
48 changes: 48 additions & 0 deletions src/components/ReimbursementAccountLoadingIndicator.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
import React from 'react';
import {Image, StyleSheet, View} from 'react-native';
import PropTypes from 'prop-types';
import styles from '../styles/styles';
import CONST from '../CONST';
import withLocalize, {withLocalizePropTypes} from './withLocalize';
import Text from './Text';
import HeaderWithCloseButton from './HeaderWithCloseButton';
import Navigation from '../libs/Navigation/Navigation';
import ScreenWrapper from './ScreenWrapper';
import FullScreenLoadingIndicator from './FullscreenLoadingIndicator';

const propTypes = {
/** Whether the user is submitting verifications data */
isSubmittingVerificationsData: PropTypes.bool.isRequired,

...withLocalizePropTypes,
};

const ReimbursementAccountLoadingIndicator = ({translate, isSubmittingVerificationsData}) => (
<ScreenWrapper style={[StyleSheet.absoluteFillObject, styles.reimbursementAccountFullScreenLoading]}>
<HeaderWithCloseButton
title={translate('reimbursementAccountLoadingAnimation.oneMoment')}
onCloseButtonPress={Navigation.dismissModal}
/>
{isSubmittingVerificationsData ? (
<View style={[styles.pageWrapper]}>
<Image
source={{uri: `${CONST.CLOUDFRONT_URL}/images/icons/emptystates/emptystate_reviewing.gif`}}
style={[
styles.loadingVBAAnimation,
]}
/>
<View style={[styles.ph6]}>
<Text style={[styles.textAlignCenter]}>
{translate('reimbursementAccountLoadingAnimation.explanationLine')}
</Text>
</View>
</View>
) : (
<FullScreenLoadingIndicator style={[styles.flex1, styles.pRelative]} />
)}
</ScreenWrapper>
);

ReimbursementAccountLoadingIndicator.propTypes = propTypes;
Jag96 marked this conversation as resolved.
Show resolved Hide resolved

export default withLocalize(ReimbursementAccountLoadingIndicator);
39 changes: 0 additions & 39 deletions src/components/VBALoadingIndicator.js

This file was deleted.

2 changes: 1 addition & 1 deletion src/languages/en.js
Original file line number Diff line number Diff line change
Expand Up @@ -611,7 +611,7 @@ export default {
certify: 'Must certify information is true and accurate',
},
},
vbaLoadingAnimation: {
reimbursementAccountLoadingAnimation: {
oneMoment: 'One Moment',
explanationLine: 'We’re taking a look at your information. You will be able to continue with next steps shortly.',
},
Expand Down
2 changes: 1 addition & 1 deletion src/languages/es.js
Original file line number Diff line number Diff line change
Expand Up @@ -613,7 +613,7 @@ export default {
certify: 'Debe certificar que la información es verdadera y precisa',
},
},
vbaLoadingAnimation: {
reimbursementAccountLoadingAnimation: {
oneMoment: 'Un Momento',
explanationLine: 'Estamos verificando tu información y podrás continuar con los siguientes pasos en unos momentos.',
},
Expand Down
28 changes: 19 additions & 9 deletions src/pages/ReimbursementAccount/ReimbursementAccountPage.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import _ from 'underscore';
import lodashGet from 'lodash/get';
import React from 'react';
import {withOnyx} from 'react-native-onyx';
Expand All @@ -10,7 +11,7 @@ import {
hideBankAccountErrors,
} from '../../libs/actions/BankAccounts';
import ONYXKEYS from '../../ONYXKEYS';
import VBALoadingIndicator from '../../components/VBALoadingIndicator';
import ReimbursementAccountLoadingIndicator from '../../components/ReimbursementAccountLoadingIndicator';
import Permissions from '../../libs/Permissions';
import Navigation from '../../libs/Navigation/Navigation';
import CONST from '../../CONST';
Expand Down Expand Up @@ -150,8 +151,24 @@ class ReimbursementAccountPage extends React.Component {
return null;
}

// The SetupWithdrawalAccount flow allows us to continue the flow from various points depending on where the
// user left off. This view will refer to the achData as the single source of truth to determine which route to
// display. We can also specify a specific route to navigate to via route params when the component first
// mounts which will set the achData.currentStep after the account data is fetched and overwrite the logical
// next step.
const achData = lodashGet(this.props, 'reimbursementAccount.achData', {});
const currentStep = achData.currentStep || CONST.BANK_ACCOUNT.STEP.BANK_ACCOUNT;
if (this.props.reimbursementAccount.loading) {
return <VBALoadingIndicator />;
const isSubmittingVerificationsData = _.contains([
CONST.BANK_ACCOUNT.STEP.COMPANY,
CONST.BANK_ACCOUNT.STEP.REQUESTOR,
CONST.BANK_ACCOUNT.STEP.ACH_CONTRACT,
], currentStep);
return (
<ReimbursementAccountLoadingIndicator
isSubmittingVerificationsData={isSubmittingVerificationsData}
/>
);
}

let errorComponent;
Expand Down Expand Up @@ -188,13 +205,6 @@ class ReimbursementAccountPage extends React.Component {
);
}

// The SetupWithdrawalAccount flow allows us to continue the flow from various points depending on where the
// user left off. This view will refer to the achData as the single source of truth to determine which route to
// display. We can also specify a specific route to navigate to via route params when the component first
// mounts which will set the achData.currentStep after the account data is fetched and overwrite the logical
// next step.
const achData = lodashGet(this.props, 'reimbursementAccount.achData', {});
const currentStep = achData.currentStep || CONST.BANK_ACCOUNT.STEP.BANK_ACCOUNT;
return (
<ScreenWrapper>
<KeyboardAvoidingView>
Expand Down
2 changes: 1 addition & 1 deletion src/styles/styles.js
Original file line number Diff line number Diff line change
Expand Up @@ -1812,7 +1812,7 @@ const styles = {
zIndex: 10,
},

vbaFullScreenLoading: {
reimbursementAccountFullScreenLoading: {
backgroundColor: themeColors.componentBG,
opacity: 0.8,
justifyContent: 'flex-start',
Expand Down