Skip to content
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
11 changes: 5 additions & 6 deletions src/components/ConnectToQuickbooksDesktopFlow/index.tsx
Original file line number Diff line number Diff line change
@@ -1,20 +1,19 @@
import {useEffect} from 'react';
import useResponsiveLayout from '@hooks/useResponsiveLayout';
import {isMobile} from '@libs/Browser';
import Navigation from '@libs/Navigation/Navigation';
import ROUTES from '@src/ROUTES';
import type {ConnectToQuickbooksDesktopFlowProps} from './types';

function ConnectToQuickbooksDesktopFlow({policyID}: ConnectToQuickbooksDesktopFlowProps) {
// eslint-disable-next-line rulesdir/prefer-shouldUseNarrowLayout-instead-of-isSmallScreenWidth
const {isSmallScreenWidth} = useResponsiveLayout();
const isMobileWeb = isMobile();
Comment thread
FitseTLT marked this conversation as resolved.

function ConnectToQuickbooksDesktopFlow({policyID}: ConnectToQuickbooksDesktopFlowProps) {
useEffect(() => {
if (isSmallScreenWidth) {
if (isMobileWeb) {
Navigation.navigate(ROUTES.POLICY_ACCOUNTING_QUICKBOOKS_DESKTOP_SETUP_REQUIRED_DEVICE_MODAL.getRoute(policyID));
} else {
Navigation.navigate(ROUTES.POLICY_ACCOUNTING_QUICKBOOKS_DESKTOP_SETUP_MODAL.getRoute(policyID));
}
}, [isSmallScreenWidth, policyID]);
}, [policyID]);

return null;
}
Expand Down
8 changes: 1 addition & 7 deletions src/pages/workspace/accounting/AccountingContext.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import type {View} from 'react-native';
import type {OnyxEntry} from 'react-native-onyx';
import AccountingConnectionConfirmationModal from '@components/AccountingConnectionConfirmationModal';
import useLocalize from '@hooks/useLocalize';
import useResponsiveLayout from '@hooks/useResponsiveLayout';
import {removePolicyConnection} from '@libs/actions/connections';
import Navigation from '@libs/Navigation/Navigation';
import {isControlPolicy} from '@libs/PolicyUtils';
Expand Down Expand Up @@ -61,10 +60,6 @@ function AccountingContextProvider({children, policy}: AccountingContextProvider
const {translate} = useLocalize();
const policyID = policy?.id;

// We need to use isSmallScreenWidth instead of shouldUseNarrowLayout to allow QuickBooks Desktop setup to be shown only on large screens
// eslint-disable-next-line rulesdir/prefer-shouldUseNarrowLayout-instead-of-isSmallScreenWidth
const {isSmallScreenWidth} = useResponsiveLayout();

const startIntegrationFlow = React.useCallback(
(newActiveIntegration: ActiveIntegration) => {
if (!policyID) {
Expand All @@ -80,7 +75,6 @@ function AccountingContextProvider({children, policy}: AccountingContextProvider
newActiveIntegration.integrationToDisconnect,
newActiveIntegration.shouldDisconnectIntegrationBeforeConnecting,
undefined,
isSmallScreenWidth,
);
const workspaceUpgradeNavigationDetails = accountingIntegrationData?.workspaceUpgradeNavigationDetails;
if (workspaceUpgradeNavigationDetails && !isControlPolicy(policy)) {
Expand All @@ -94,7 +88,7 @@ function AccountingContextProvider({children, policy}: AccountingContextProvider
key: Math.random(),
});
},
[isSmallScreenWidth, policy, policyID, translate],
[policy, policyID, translate],
);

const closeConfirmationModal = () => {
Expand Down
7 changes: 5 additions & 2 deletions src/pages/workspace/accounting/utils.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import Text from '@components/Text';
import TextLink from '@components/TextLink';
import {isAuthenticationError} from '@libs/actions/connections';
import {getAdminPoliciesConnectedToSageIntacct} from '@libs/actions/Policy/Policy';
import getPlatform from '@libs/getPlatform';
import {translateLocal} from '@libs/Localize';
import {canUseTaxNetSuite} from '@libs/PolicyUtils';
import Navigation from '@navigation/Navigation';
Expand Down Expand Up @@ -39,6 +40,9 @@ import {
} from './netsuite/utils';
import type {AccountingIntegration} from './types';

const platform = getPlatform(true);
const isMobile = [CONST.PLATFORM.MOBILE_WEB, CONST.PLATFORM.IOS, CONST.PLATFORM.ANDROID].some((value) => value === platform);

function getAccountingIntegrationData(
connectionName: PolicyConnectionName,
policyID: string,
Expand All @@ -48,7 +52,6 @@ function getAccountingIntegrationData(
integrationToDisconnect?: ConnectionName,
shouldDisconnectIntegrationBeforeConnecting?: boolean,
canUseNetSuiteUSATax?: boolean,
isSmallScreenWidth?: boolean,
): AccountingIntegration | undefined {
const qboConfig = policy?.connections?.quickbooksOnline?.config;
const netsuiteConfig = policy?.connections?.netsuite?.options?.config;
Expand All @@ -68,7 +71,7 @@ function getAccountingIntegrationData(
if (integrationToDisconnect) {
return ROUTES.POLICY_ACCOUNTING.getRoute(policyID, connectionName, integrationToDisconnect, shouldDisconnectIntegrationBeforeConnecting);
}
if (isSmallScreenWidth) {
if (isMobile) {
return ROUTES.POLICY_ACCOUNTING_QUICKBOOKS_DESKTOP_SETUP_REQUIRED_DEVICE_MODAL.getRoute(policyID);
}
return ROUTES.POLICY_ACCOUNTING_QUICKBOOKS_DESKTOP_SETUP_MODAL.getRoute(policyID);
Expand Down
Loading