diff --git a/src/pages/workspace/accounting/qbd/QuickBooksDesktopSetupPage.tsx b/src/pages/workspace/accounting/qbd/QuickBooksDesktopSetupPage.tsx index 5e90c3db4ed1..a71d73798758 100644 --- a/src/pages/workspace/accounting/qbd/QuickBooksDesktopSetupPage.tsx +++ b/src/pages/workspace/accounting/qbd/QuickBooksDesktopSetupPage.tsx @@ -1,11 +1,10 @@ import React, {useCallback, useEffect, useState} from 'react'; -import {View} from 'react-native'; +import {ActivityIndicator, View} from 'react-native'; import Computer from '@assets/images/laptop-with-second-screen-sync.svg'; import FullPageOfflineBlockingView from '@components/BlockingViews/FullPageOfflineBlockingView'; import Button from '@components/Button'; import CopyTextToClipboard from '@components/CopyTextToClipboard'; import FixedFooter from '@components/FixedFooter'; -import FullScreenLoadingIndicator from '@components/FullscreenLoadingIndicator'; import HeaderWithBackButton from '@components/HeaderWithBackButton'; import Icon from '@components/Icon'; import * as Illustrations from '@components/Icon/Illustrations'; @@ -16,6 +15,7 @@ import TextLink from '@components/TextLink'; import useEnvironment from '@hooks/useEnvironment'; import useLocalize from '@hooks/useLocalize'; import useNetwork from '@hooks/useNetwork'; +import useTheme from '@hooks/useTheme'; import useThemeStyles from '@hooks/useThemeStyles'; import {setConnectionError} from '@libs/actions/connections'; import * as QuickbooksDesktop from '@libs/actions/connections/QuickbooksDesktop'; @@ -31,10 +31,10 @@ type RequireQuickBooksDesktopModalProps = PlatformStackScreenProps(''); const hasResultOfFetchingSetupLink = !!codatSetupLink || hasError; @@ -42,20 +42,19 @@ function RequireQuickBooksDesktopModal({route}: RequireQuickBooksDesktopModalPro const ContentWrapper = hasResultOfFetchingSetupLink ? ({children}: React.PropsWithChildren) => children : FullPageOfflineBlockingView; const fetchSetupLink = useCallback(() => { - setIsLoading(true); setHasError(false); // eslint-disable-next-line rulesdir/no-thenable-actions-in-views QuickbooksDesktop.getQuickbooksDesktopCodatSetupLink(policyID).then((response) => { - if (response?.jsonCode) { - if (response.jsonCode === CONST.JSON_CODE.SUCCESS) { - setCodatSetupLink(String(response?.setupUrl ?? '')); - } else { - setConnectionError(policyID, CONST.POLICY.CONNECTIONS.NAME.QBD, translate('workspace.qbd.setupPage.setupErrorTitle')); - setHasError(true); - } + if (!response?.jsonCode) { + return; } - setIsLoading(false); + if (response.jsonCode === CONST.JSON_CODE.SUCCESS) { + setCodatSetupLink(String(response?.setupUrl ?? '')); + } else { + setConnectionError(policyID, CONST.POLICY.CONNECTIONS.NAME.QBD, translate('workspace.qbd.setupPage.setupErrorTitle')); + setHasError(true); + } }); }, [policyID, translate]); @@ -77,8 +76,7 @@ function RequireQuickBooksDesktopModal({route}: RequireQuickBooksDesktopModalPro }, }); - const shouldShowLoading = isLoading || !hasResultOfFetchingSetupLink; - const shouldShowError = !shouldShowLoading && hasError; + const shouldShowError = hasError; return ( Navigation.dismissModal()} /> - {shouldShowLoading && } {shouldShowError && ( )} - {!shouldShowLoading && !shouldShowError && ( + {!shouldShowError && ( @@ -122,10 +119,17 @@ function RequireQuickBooksDesktopModal({route}: RequireQuickBooksDesktopModalPro {translate('workspace.qbd.setupPage.title')} {translate('workspace.qbd.setupPage.body')} - + {!hasResultOfFetchingSetupLink ? ( + + ) : ( + + )}