Skip to content

Commit f9a179e

Browse files
authored
Merge pull request #65568 from daledah/fix/65148
fix: card reconciliation for QBD is unresponsive
2 parents 8f3cc9a + e069f81 commit f9a179e

File tree

5 files changed

+29
-10
lines changed

5 files changed

+29
-10
lines changed

src/ROUTES.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1118,7 +1118,12 @@ const ROUTES = {
11181118
},
11191119
WORKSPACE_ACCOUNTING_QUICKBOOKS_DESKTOP_ADVANCED: {
11201120
route: 'workspaces/:policyID/accounting/quickbooks-desktop/advanced',
1121-
getRoute: (policyID: string) => `workspaces/${policyID}/accounting/quickbooks-desktop/advanced` as const,
1121+
getRoute: (policyID?: string, backTo?: string) => {
1122+
if (!policyID) {
1123+
Log.warn('Invalid policyID is used to build the WORKSPACE_ACCOUNTING_QUICKBOOKS_DESKTOP_ADVANCED route');
1124+
}
1125+
return getUrlWithBackToParam(`workspaces/${policyID}/accounting/quickbooks-desktop/advanced` as const, backTo);
1126+
},
11221127
},
11231128
POLICY_ACCOUNTING_QUICKBOOKS_DESKTOP_EXPORT_DATE_SELECT: {
11241129
route: 'workspaces/:policyID/accounting/quickbooks-desktop/export/date-select',

src/libs/Navigation/types.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -585,6 +585,7 @@ type SettingsNavigatorParamList = {
585585
};
586586
[SCREENS.WORKSPACE.ACCOUNTING.QUICKBOOKS_DESKTOP_ADVANCED]: {
587587
policyID: string;
588+
backTo?: Routes;
588589
};
589590
[SCREENS.WORKSPACE.ACCOUNTING.QUICKBOOKS_DESKTOP_EXPORT_DATE_SELECT]: {
590591
policyID: string;

src/pages/workspace/accounting/qbd/advanced/QuickbooksDesktopAdvancedPage.tsx

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,43 @@
1+
import {useRoute} from '@react-navigation/native';
12
import React from 'react';
23
import ConnectionLayout from '@components/ConnectionLayout';
34
import useLocalize from '@hooks/useLocalize';
45
import useThemeStyles from '@hooks/useThemeStyles';
5-
import * as QuickbooksDesktop from '@libs/actions/connections/QuickbooksDesktop';
6-
import * as ErrorUtils from '@libs/ErrorUtils';
6+
import {updateQuickbooksDesktopAutoSync, updateQuickbooksDesktopShouldAutoCreateVendor} from '@libs/actions/connections/QuickbooksDesktop';
7+
import {getLatestErrorField} from '@libs/ErrorUtils';
78
import Navigation from '@libs/Navigation/Navigation';
9+
import type {PlatformStackRouteProp} from '@libs/Navigation/PlatformStackNavigation/types';
10+
import type {SettingsNavigatorParamList} from '@libs/Navigation/types';
811
import {settingsPendingAction} from '@libs/PolicyUtils';
912
import type {WithPolicyConnectionsProps} from '@pages/workspace/withPolicyConnections';
1013
import withPolicyConnections from '@pages/workspace/withPolicyConnections';
1114
import ToggleSettingOptionRow from '@pages/workspace/workflows/ToggleSettingsOptionRow';
1215
import {clearQBDErrorField} from '@userActions/Policy/Policy';
1316
import CONST from '@src/CONST';
1417
import ROUTES from '@src/ROUTES';
18+
import type SCREENS from '@src/SCREENS';
1519

1620
function QuickbooksDesktopAdvancedPage({policy}: WithPolicyConnectionsProps) {
1721
const styles = useThemeStyles();
1822
const {translate} = useLocalize();
19-
const policyID = policy?.id ?? '-1';
23+
const policyID = policy?.id;
2024
const qbdConfig = policy?.connections?.quickbooksDesktop?.config;
25+
const route = useRoute<PlatformStackRouteProp<SettingsNavigatorParamList, typeof SCREENS.WORKSPACE.ACCOUNTING.QUICKBOOKS_DESKTOP_ADVANCED>>();
2126

2227
const qbdToggleSettingItems = [
2328
{
2429
title: translate('workspace.accounting.autoSync'),
2530
subtitle: translate('workspace.qbd.advancedConfig.autoSyncDescription'),
2631
switchAccessibilityLabel: translate('workspace.qbd.advancedConfig.autoSyncDescription'),
2732
isActive: !!qbdConfig?.autoSync?.enabled,
28-
onToggle: (isOn: boolean) => QuickbooksDesktop.updateQuickbooksDesktopAutoSync(policyID, isOn),
33+
onToggle: (isOn: boolean) => {
34+
if (!policyID) {
35+
return;
36+
}
37+
updateQuickbooksDesktopAutoSync(policyID, isOn);
38+
},
2939
subscribedSetting: CONST.QUICKBOOKS_DESKTOP_CONFIG.AUTO_SYNC,
30-
errors: ErrorUtils.getLatestErrorField(qbdConfig, CONST.QUICKBOOKS_DESKTOP_CONFIG.AUTO_SYNC),
40+
errors: getLatestErrorField(qbdConfig, CONST.QUICKBOOKS_DESKTOP_CONFIG.AUTO_SYNC),
3141
pendingAction: settingsPendingAction([CONST.QUICKBOOKS_DESKTOP_CONFIG.AUTO_SYNC], qbdConfig?.pendingFields),
3242
},
3343
{
@@ -36,10 +46,10 @@ function QuickbooksDesktopAdvancedPage({policy}: WithPolicyConnectionsProps) {
3646
switchAccessibilityLabel: translate('workspace.qbd.advancedConfig.createEntitiesDescription'),
3747
isActive: !!qbdConfig?.shouldAutoCreateVendor,
3848
onToggle: (isOn: boolean) => {
39-
QuickbooksDesktop.updateQuickbooksDesktopShouldAutoCreateVendor(policyID, isOn);
49+
updateQuickbooksDesktopShouldAutoCreateVendor(policyID, isOn);
4050
},
4151
subscribedSetting: CONST.QUICKBOOKS_DESKTOP_CONFIG.SHOULD_AUTO_CREATE_VENDOR,
42-
errors: ErrorUtils.getLatestErrorField(qbdConfig, CONST.QUICKBOOKS_DESKTOP_CONFIG.SHOULD_AUTO_CREATE_VENDOR),
52+
errors: getLatestErrorField(qbdConfig, CONST.QUICKBOOKS_DESKTOP_CONFIG.SHOULD_AUTO_CREATE_VENDOR),
4353
pendingAction: settingsPendingAction([CONST.QUICKBOOKS_DESKTOP_CONFIG.SHOULD_AUTO_CREATE_VENDOR], qbdConfig?.pendingFields),
4454
},
4555
];
@@ -53,7 +63,7 @@ function QuickbooksDesktopAdvancedPage({policy}: WithPolicyConnectionsProps) {
5363
featureName={CONST.POLICY.MORE_FEATURES.ARE_CONNECTIONS_ENABLED}
5464
contentContainerStyle={[styles.pb2, styles.ph5]}
5565
connectionName={CONST.POLICY.CONNECTIONS.NAME.QBD}
56-
onBackButtonPress={() => Navigation.goBack(ROUTES.POLICY_ACCOUNTING.getRoute(policyID))}
66+
onBackButtonPress={() => Navigation.goBack(route.params?.backTo ?? ROUTES.POLICY_ACCOUNTING.getRoute(policyID))}
5767
>
5868
{qbdToggleSettingItems.map((item) => (
5969
<ToggleSettingOptionRow

src/pages/workspace/accounting/reconciliation/CardReconciliationPage.tsx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,9 @@ function CardReconciliationPage({policy, route}: CardReconciliationPageProps) {
9999
case CONST.POLICY.CONNECTIONS.ROUTE.SAGE_INTACCT:
100100
Navigation.navigate(ROUTES.POLICY_ACCOUNTING_SAGE_INTACCT_ADVANCED.getRoute(policyID));
101101
break;
102+
case CONST.POLICY.CONNECTIONS.ROUTE.QBD:
103+
Navigation.navigate(ROUTES.WORKSPACE_ACCOUNTING_QUICKBOOKS_DESKTOP_ADVANCED.getRoute(policyID, Navigation.getActiveRoute()));
104+
break;
102105
default:
103106
break;
104107
}

src/pages/workspace/accounting/utils.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -281,7 +281,7 @@ function getAccountingIntegrationData(
281281
),
282282
onImportPagePress: () => Navigation.navigate(ROUTES.POLICY_ACCOUNTING_QUICKBOOKS_DESKTOP_IMPORT.getRoute(policyID)),
283283
onExportPagePress: () => Navigation.navigate(ROUTES.POLICY_ACCOUNTING_QUICKBOOKS_DESKTOP_EXPORT.getRoute(policyID)),
284-
onCardReconciliationPagePress: () => {},
284+
onCardReconciliationPagePress: () => Navigation.navigate(ROUTES.WORKSPACE_ACCOUNTING_CARD_RECONCILIATION.getRoute(policyID, CONST.POLICY.CONNECTIONS.ROUTE.QBD)),
285285
onAdvancedPagePress: () => Navigation.navigate(ROUTES.WORKSPACE_ACCOUNTING_QUICKBOOKS_DESKTOP_ADVANCED.getRoute(policyID)),
286286
subscribedImportSettings: [
287287
CONST.QUICKBOOKS_DESKTOP_CONFIG.ENABLE_NEW_CATEGORIES,

0 commit comments

Comments
 (0)