From d6b1c91bd20ab3ba330784b5ceeecb6dfe0ed94f Mon Sep 17 00:00:00 2001 From: VH Date: Wed, 16 Oct 2024 17:51:14 +0700 Subject: [PATCH 1/5] Implement Customers page --- src/CONST.ts | 1 + src/ROUTES.ts | 4 ++ src/SCREENS.ts | 1 + src/languages/en.ts | 1 + src/languages/es.ts | 1 + .../ModalStackNavigators/index.tsx | 1 + .../FULL_SCREEN_TO_RHP_MAPPING.ts | 1 + src/libs/Navigation/linkingConfig/config.ts | 1 + src/libs/Navigation/types.ts | 3 + .../import/QuickbooksDesktopCustomersPage.tsx | 69 +++++++++++++++++++ .../import/QuickbooksDesktopImportPage.tsx | 4 +- src/pages/workspace/accounting/utils.tsx | 6 +- 12 files changed, 90 insertions(+), 3 deletions(-) create mode 100644 src/pages/workspace/accounting/qbd/import/QuickbooksDesktopCustomersPage.tsx diff --git a/src/CONST.ts b/src/CONST.ts index caca91a59055..2ffebb5a7026 100755 --- a/src/CONST.ts +++ b/src/CONST.ts @@ -1495,6 +1495,7 @@ const CONST = { ENABLE_NEW_CATEGORIES: 'enableNewCategories', MAPPINGS: { CLASSES: 'classes', + CUSTOMERS: 'customers', }, }, diff --git a/src/ROUTES.ts b/src/ROUTES.ts index c2c404d7fea5..ef706bb4471a 100644 --- a/src/ROUTES.ts +++ b/src/ROUTES.ts @@ -722,6 +722,10 @@ const ROUTES = { route: 'settings/workspaces/:policyID/accounting/quickbooks-desktop/import/classes/displayed_as', getRoute: (policyID: string) => `settings/workspaces/${policyID}/accounting/quickbooks-desktop/import/classes/displayed_as` as const, }, + POLICY_ACCOUNTING_QUICKBOOKS_DESKTOP_CUSTOMERS: { + route: 'settings/workspaces/:policyID/accounting/quickbooks-desktop/import/customers', + getRoute: (policyID: string) => `settings/workspaces/${policyID}/accounting/quickbooks-desktop/import/customers` as const, + }, WORKSPACE_PROFILE_NAME: { route: 'settings/workspaces/:policyID/profile/name', getRoute: (policyID: string) => `settings/workspaces/${policyID}/profile/name` as const, diff --git a/src/SCREENS.ts b/src/SCREENS.ts index 3da0f86d651e..ce746b214df2 100644 --- a/src/SCREENS.ts +++ b/src/SCREENS.ts @@ -330,6 +330,7 @@ const SCREENS = { QUICKBOOKS_DESKTOP_CHART_OF_ACCOUNTS: 'Policy_Accounting_Quickbooks_Desktop_Import_Chart_Of_Accounts', QUICKBOOKS_DESKTOP_CLASSES: 'Policy_Accounting_Quickbooks_Desktop_Import_Classes', QUICKBOOKS_DESKTOP_CLASSES_DISPLAYED_AS: 'Policy_Accounting_Quickbooks_Desktop_Import_Classes_Dipslayed_As', + QUICKBOOKS_DESKTOP_CUSTOMERS: 'Policy_Accounting_Quickbooks_Desktop_Import_Customers', XERO_IMPORT: 'Policy_Accounting_Xero_Import', XERO_ORGANIZATION: 'Policy_Accounting_Xero_Customers', XERO_CHART_OF_ACCOUNTS: 'Policy_Accounting_Xero_Import_Chart_Of_Accounts', diff --git a/src/languages/en.ts b/src/languages/en.ts index 7d506c74042a..cfca0c0f7751 100755 --- a/src/languages/en.ts +++ b/src/languages/en.ts @@ -2459,6 +2459,7 @@ const translations = { classesDescription: 'Choose how to handle QuickBooks Desktop classes in Expensify.', tagsDisplayedAsDescription: 'Line item level', reportFieldsDisplayedAsDescription: 'Report level', + customersDescription: 'Choose how to handle QuickBooks Desktop customers/projects in Expensify.', }, qbo: { importDescription: 'Choose which coding configurations to import from QuickBooks Online to Expensify.', diff --git a/src/languages/es.ts b/src/languages/es.ts index c5d9adb0d1e4..57ad018f093d 100644 --- a/src/languages/es.ts +++ b/src/languages/es.ts @@ -2483,6 +2483,7 @@ const translations = { classesDescription: 'Elige cómo gestionar las clases de QuickBooks Desktop en Expensify.', tagsDisplayedAsDescription: 'Nivel de partida', reportFieldsDisplayedAsDescription: 'Nivel de informe', + customersDescription: 'Elige cómo gestionar los clientes/proyectos de QuickBooks Desktop en Expensify.', }, qbo: { importDescription: 'Elige que configuraciónes de codificación son importadas desde QuickBooks Online a Expensify.', diff --git a/src/libs/Navigation/AppNavigator/ModalStackNavigators/index.tsx b/src/libs/Navigation/AppNavigator/ModalStackNavigators/index.tsx index c32f63906443..d6645358a00b 100644 --- a/src/libs/Navigation/AppNavigator/ModalStackNavigators/index.tsx +++ b/src/libs/Navigation/AppNavigator/ModalStackNavigators/index.tsx @@ -334,6 +334,7 @@ const SettingsModalStackNavigator = createModalStackNavigator require('../../../../pages/workspace/accounting/qbd/import/QuickbooksDesktopClassesPage').default, [SCREENS.WORKSPACE.ACCOUNTING.QUICKBOOKS_DESKTOP_CLASSES_DISPLAYED_AS]: () => require('../../../../pages/workspace/accounting/qbd/import/QuickbooksDesktopClassesDisplayedAsPage').default, + [SCREENS.WORKSPACE.ACCOUNTING.QUICKBOOKS_DESKTOP_CUSTOMERS]: () => require('../../../../pages/workspace/accounting/qbd/import/QuickbooksDesktopCustomersPage').default, [SCREENS.REIMBURSEMENT_ACCOUNT]: () => require('../../../../pages/ReimbursementAccount/ReimbursementAccountPage').default, [SCREENS.GET_ASSISTANCE]: () => require('../../../../pages/GetAssistancePage').default, [SCREENS.SETTINGS.TWO_FACTOR_AUTH]: () => require('../../../../pages/settings/Security/TwoFactorAuth/TwoFactorAuthPage').default, diff --git a/src/libs/Navigation/linkingConfig/FULL_SCREEN_TO_RHP_MAPPING.ts b/src/libs/Navigation/linkingConfig/FULL_SCREEN_TO_RHP_MAPPING.ts index 552310dceae4..744b1ebc442c 100755 --- a/src/libs/Navigation/linkingConfig/FULL_SCREEN_TO_RHP_MAPPING.ts +++ b/src/libs/Navigation/linkingConfig/FULL_SCREEN_TO_RHP_MAPPING.ts @@ -58,6 +58,7 @@ const FULL_SCREEN_TO_RHP_MAPPING: Partial> = { SCREENS.WORKSPACE.ACCOUNTING.QUICKBOOKS_DESKTOP_CHART_OF_ACCOUNTS, SCREENS.WORKSPACE.ACCOUNTING.QUICKBOOKS_DESKTOP_CLASSES, SCREENS.WORKSPACE.ACCOUNTING.QUICKBOOKS_DESKTOP_CLASSES_DISPLAYED_AS, + SCREENS.WORKSPACE.ACCOUNTING.QUICKBOOKS_DESKTOP_CUSTOMERS, SCREENS.WORKSPACE.ACCOUNTING.XERO_IMPORT, SCREENS.WORKSPACE.ACCOUNTING.XERO_CHART_OF_ACCOUNTS, SCREENS.WORKSPACE.ACCOUNTING.XERO_ORGANIZATION, diff --git a/src/libs/Navigation/linkingConfig/config.ts b/src/libs/Navigation/linkingConfig/config.ts index 8f152e2d35de..e095f5661786 100644 --- a/src/libs/Navigation/linkingConfig/config.ts +++ b/src/libs/Navigation/linkingConfig/config.ts @@ -418,6 +418,7 @@ const config: LinkingOptions['config'] = { [SCREENS.WORKSPACE.ACCOUNTING.QUICKBOOKS_DESKTOP_CHART_OF_ACCOUNTS]: {path: ROUTES.POLICY_ACCOUNTING_QUICKBOOKS_DESKTOP_CHART_OF_ACCOUNTS.route}, [SCREENS.WORKSPACE.ACCOUNTING.QUICKBOOKS_DESKTOP_CLASSES]: {path: ROUTES.POLICY_ACCOUNTING_QUICKBOOKS_DESKTOP_CLASSES.route}, [SCREENS.WORKSPACE.ACCOUNTING.QUICKBOOKS_DESKTOP_CLASSES_DISPLAYED_AS]: {path: ROUTES.POLICY_ACCOUNTING_QUICKBOOKS_DESKTOP_CLASSES_DISPLAYED_AS.route}, + [SCREENS.WORKSPACE.ACCOUNTING.QUICKBOOKS_DESKTOP_CUSTOMERS]: {path: ROUTES.POLICY_ACCOUNTING_QUICKBOOKS_DESKTOP_CUSTOMERS.route}, [SCREENS.WORKSPACE.ACCOUNTING.XERO_IMPORT]: {path: ROUTES.POLICY_ACCOUNTING_XERO_IMPORT.route}, [SCREENS.WORKSPACE.ACCOUNTING.XERO_CHART_OF_ACCOUNTS]: {path: ROUTES.POLICY_ACCOUNTING_XERO_CHART_OF_ACCOUNTS.route}, [SCREENS.WORKSPACE.ACCOUNTING.XERO_ORGANIZATION]: {path: ROUTES.POLICY_ACCOUNTING_XERO_ORGANIZATION.route}, diff --git a/src/libs/Navigation/types.ts b/src/libs/Navigation/types.ts index cbd6a2af95bf..e500437f0844 100644 --- a/src/libs/Navigation/types.ts +++ b/src/libs/Navigation/types.ts @@ -472,6 +472,9 @@ type SettingsNavigatorParamList = { [SCREENS.WORKSPACE.ACCOUNTING.QUICKBOOKS_DESKTOP_CLASSES_DISPLAYED_AS]: { policyID: string; }; + [SCREENS.WORKSPACE.ACCOUNTING.QUICKBOOKS_DESKTOP_CUSTOMERS]: { + policyID: string; + }; [SCREENS.WORKSPACE.ACCOUNTING.XERO_IMPORT]: { policyID: string; }; diff --git a/src/pages/workspace/accounting/qbd/import/QuickbooksDesktopCustomersPage.tsx b/src/pages/workspace/accounting/qbd/import/QuickbooksDesktopCustomersPage.tsx new file mode 100644 index 000000000000..b0de290f8f5c --- /dev/null +++ b/src/pages/workspace/accounting/qbd/import/QuickbooksDesktopCustomersPage.tsx @@ -0,0 +1,69 @@ +import React from 'react'; +import ConnectionLayout from '@components/ConnectionLayout'; +import MenuItemWithTopDescription from '@components/MenuItemWithTopDescription'; +import useLocalize from '@hooks/useLocalize'; +import usePermissions from '@hooks/usePermissions'; +import useThemeStyles from '@hooks/useThemeStyles'; +import * as QuickbooksDesktop from '@libs/actions/connections/QuickbooksDesktop'; +import * as ErrorUtils from '@libs/ErrorUtils'; +import Navigation from '@libs/Navigation/Navigation'; +import * as PolicyUtils from '@libs/PolicyUtils'; +import type {WithPolicyProps} from '@pages/workspace/withPolicy'; +import withPolicyConnections from '@pages/workspace/withPolicyConnections'; +import ToggleSettingOptionRow from '@pages/workspace/workflows/ToggleSettingsOptionRow'; +import {clearQBDErrorField} from '@userActions/Policy/Policy'; +import CONST from '@src/CONST'; +import ROUTES from '@src/ROUTES'; + +function QuickbooksDesktopCustomersPage({policy}: WithPolicyProps) { + const {translate} = useLocalize(); + const styles = useThemeStyles(); + const {canUseNewDotQBD} = usePermissions(); + const policyID = policy?.id ?? '-1'; + const qbdConfig = policy?.connections?.quickbooksDesktop?.config; + const isSwitchOn = !!(qbdConfig?.mappings?.customers && qbdConfig.mappings.customers !== CONST.INTEGRATION_ENTITY_MAP_TYPES.NONE); + const isReportFieldsSelected = qbdConfig?.mappings?.customers === CONST.INTEGRATION_ENTITY_MAP_TYPES.REPORT_FIELD; + + return ( + Navigation.goBack(ROUTES.POLICY_ACCOUNTING_QUICKBOOKS_DESKTOP_IMPORT.getRoute(policyID))} + > + + QuickbooksDesktop.updateQuickbooksDesktopSyncClasses( + policyID, + isSwitchOn ? CONST.INTEGRATION_ENTITY_MAP_TYPES.NONE : CONST.INTEGRATION_ENTITY_MAP_TYPES.TAG, + qbdConfig?.mappings?.classes, + ) + } + pendingAction={PolicyUtils.settingsPendingAction([CONST.QUICKBOOKS_DESKTOP_CONFIG.MAPPINGS.CUSTOMERS], qbdConfig?.pendingFields)} + errors={ErrorUtils.getLatestErrorField(qbdConfig, CONST.QUICKBOOKS_DESKTOP_CONFIG.MAPPINGS.CUSTOMERS)} + onCloseError={() => clearQBDErrorField(policyID, CONST.QUICKBOOKS_DESKTOP_CONFIG.MAPPINGS.CUSTOMERS)} + /> + {isSwitchOn && ( + + )} + + ); +} + +QuickbooksDesktopCustomersPage.displayName = 'QuickbooksDesktopCustomersPage'; + +export default withPolicyConnections(QuickbooksDesktopCustomersPage); diff --git a/src/pages/workspace/accounting/qbd/import/QuickbooksDesktopImportPage.tsx b/src/pages/workspace/accounting/qbd/import/QuickbooksDesktopImportPage.tsx index 8aa21ebccdd8..3697dfeb0b22 100644 --- a/src/pages/workspace/accounting/qbd/import/QuickbooksDesktopImportPage.tsx +++ b/src/pages/workspace/accounting/qbd/import/QuickbooksDesktopImportPage.tsx @@ -41,9 +41,9 @@ function QuickbooksDesktopImportPage({policy}: WithPolicyProps) { }, { description: translate('workspace.qbd.customers'), - action: () => {}, // TODO: [QBD] will be implemented in https://github.com/Expensify/App/issues/49705 + action: () => Navigation.navigate(ROUTES.POLICY_ACCOUNTING_QUICKBOOKS_DESKTOP_CUSTOMERS.getRoute(policyID)), title: translate(`workspace.accounting.importTypes.${mappings?.customers ?? CONST.INTEGRATION_ENTITY_MAP_TYPES.NONE}`), - subscribedSettings: [CONST.QUICKBOOKS_CONFIG.SYNC_CUSTOMERS], + subscribedSettings: [CONST.QUICKBOOKS_DESKTOP_CONFIG.MAPPINGS.CUSTOMERS], }, { description: translate('workspace.qbd.items'), diff --git a/src/pages/workspace/accounting/utils.tsx b/src/pages/workspace/accounting/utils.tsx index 7e694babdd5c..49518ef4a180 100644 --- a/src/pages/workspace/accounting/utils.tsx +++ b/src/pages/workspace/accounting/utils.tsx @@ -261,7 +261,11 @@ function getAccountingIntegrationData( onCardReconciliationPagePress: () => {}, onAdvancedPagePress: () => {}, // TODO: [QBD] Make sure all values are passed to subscribedSettings - subscribedImportSettings: [CONST.QUICKBOOKS_DESKTOP_CONFIG.ENABLE_NEW_CATEGORIES, CONST.QUICKBOOKS_DESKTOP_CONFIG.MAPPINGS.CLASSES], + subscribedImportSettings: [ + CONST.QUICKBOOKS_DESKTOP_CONFIG.ENABLE_NEW_CATEGORIES, + CONST.QUICKBOOKS_DESKTOP_CONFIG.MAPPINGS.CLASSES, + CONST.QUICKBOOKS_DESKTOP_CONFIG.MAPPINGS.CUSTOMERS, + ], subscribedExportSettings: [ CONST.QUICKBOOKS_DESKTOP_CONFIG.EXPORT_DATE, CONST.QUICKBOOKS_DESKTOP_CONFIG.EXPORTER, From 72171e6c1b457219ddc437fb62496c9d58c895b6 Mon Sep 17 00:00:00 2001 From: VH Date: Wed, 16 Oct 2024 17:54:08 +0700 Subject: [PATCH 2/5] Update correct action to update customers displayed as --- src/libs/API/types.ts | 2 ++ src/libs/actions/connections/QuickbooksDesktop.ts | 15 +++++++++++++++ .../qbd/import/QuickbooksDesktopCustomersPage.tsx | 2 +- 3 files changed, 18 insertions(+), 1 deletion(-) diff --git a/src/libs/API/types.ts b/src/libs/API/types.ts index 2463fc1cdc0c..9f1264b5cdca 100644 --- a/src/libs/API/types.ts +++ b/src/libs/API/types.ts @@ -265,6 +265,7 @@ const WRITE_COMMANDS = { UPDATE_QUICKBOOKS_DESKTOP_REIMBURSABLE_EXPENSES_EXPORT_DESTINATION: 'UpdateQuickbooksDesktopReimbursableExpensesExportDestination', UPDATE_QUICKBOOKS_DESKTOP_ENABLE_NEW_CATEGORIES: 'UpdateQuickbooksDesktopEnableNewCategories', UPDATE_QUICKBOOKS_DESKTOP_SYNC_CLASSES: 'UpdateQuickbooksDesktopSyncClasses', + UPDATE_QUICKBOOKS_DESKTOP_SYNC_CUSTOMERS: 'UpdateQuickbooksDesktopSyncCustomers', REMOVE_POLICY_CONNECTION: 'RemovePolicyConnection', SET_POLICY_TAXES_ENABLED: 'SetPolicyTaxesEnabled', DELETE_POLICY_TAXES: 'DeletePolicyTaxes', @@ -702,6 +703,7 @@ type WriteCommandParameters = { [WRITE_COMMANDS.UPDATE_QUICKBOOKS_DESKTOP_REIMBURSABLE_EXPENSES_EXPORT_DESTINATION]: Parameters.UpdateQuickbooksDesktopExpensesExportDestinationTypeParams; [WRITE_COMMANDS.UPDATE_QUICKBOOKS_DESKTOP_ENABLE_NEW_CATEGORIES]: Parameters.UpdateQuickbooksDesktopGenericTypeParams; [WRITE_COMMANDS.UPDATE_QUICKBOOKS_DESKTOP_SYNC_CLASSES]: Parameters.UpdateQuickbooksDesktopGenericTypeParams; + [WRITE_COMMANDS.UPDATE_QUICKBOOKS_DESKTOP_SYNC_CUSTOMERS]: Parameters.UpdateQuickbooksDesktopGenericTypeParams; [WRITE_COMMANDS.UPDATE_QUICKBOOKS_DESKTOP_EXPORT]: Parameters.UpdateQuickbooksDesktopGenericTypeParams; [WRITE_COMMANDS.UPDATE_POLICY_CONNECTION_CONFIG]: Parameters.UpdatePolicyConnectionConfigParams; [WRITE_COMMANDS.UPDATE_MANY_POLICY_CONNECTION_CONFIGS]: Parameters.UpdateManyPolicyConnectionConfigurationsParams; diff --git a/src/libs/actions/connections/QuickbooksDesktop.ts b/src/libs/actions/connections/QuickbooksDesktop.ts index 80f50dce7b8a..e84920ef56a8 100644 --- a/src/libs/actions/connections/QuickbooksDesktop.ts +++ b/src/libs/actions/connections/QuickbooksDesktop.ts @@ -395,6 +395,20 @@ function updateQuickbooksDesktopSyncClasses( + policyID: string, + settingValue: TSettingValue, + oldSettingValue?: TSettingValue, +) { + const onyxData = buildOnyxDataForQuickbooksDesktopMappingsConfiguration(policyID, CONST.QUICKBOOKS_DESKTOP_CONFIG.MAPPINGS.CUSTOMERS, settingValue, oldSettingValue); + const parameters: UpdateQuickbooksDesktopGenericTypeParams = { + policyID, + settingValue, + idempotencyKey: String(CONST.QUICKBOOKS_DESKTOP_CONFIG.MAPPINGS.CUSTOMERS), + }; + API.write(WRITE_COMMANDS.UPDATE_QUICKBOOKS_DESKTOP_SYNC_CLASSES, parameters, onyxData); +} + function updateQuickbooksDesktopPreferredExporter( policyID: string, settingValue: TSettingValue, @@ -434,4 +448,5 @@ export { updateQuickbooksDesktopEnableNewCategories, updateQuickbooksDesktopExportDate, updateQuickbooksDesktopSyncClasses, + updateQuickbooksDesktopSyncCustomers, }; diff --git a/src/pages/workspace/accounting/qbd/import/QuickbooksDesktopCustomersPage.tsx b/src/pages/workspace/accounting/qbd/import/QuickbooksDesktopCustomersPage.tsx index b0de290f8f5c..e59b5ac317fb 100644 --- a/src/pages/workspace/accounting/qbd/import/QuickbooksDesktopCustomersPage.tsx +++ b/src/pages/workspace/accounting/qbd/import/QuickbooksDesktopCustomersPage.tsx @@ -42,7 +42,7 @@ function QuickbooksDesktopCustomersPage({policy}: WithPolicyProps) { switchAccessibilityLabel={translate('workspace.qbd.customers')} isActive={isSwitchOn} onToggle={() => - QuickbooksDesktop.updateQuickbooksDesktopSyncClasses( + QuickbooksDesktop.updateQuickbooksDesktopSyncCustomers( policyID, isSwitchOn ? CONST.INTEGRATION_ENTITY_MAP_TYPES.NONE : CONST.INTEGRATION_ENTITY_MAP_TYPES.TAG, qbdConfig?.mappings?.classes, From eaef5478f53529736f20008cdca54f10d14060a4 Mon Sep 17 00:00:00 2001 From: VH Date: Wed, 16 Oct 2024 18:05:06 +0700 Subject: [PATCH 3/5] Implement displayed as for QBD customers --- src/ROUTES.ts | 4 + src/SCREENS.ts | 1 + .../ModalStackNavigators/index.tsx | 2 + .../FULL_SCREEN_TO_RHP_MAPPING.ts | 1 + src/libs/Navigation/linkingConfig/config.ts | 1 + src/libs/Navigation/types.ts | 3 + ...ckbooksDesktopCustomersDisplayedAsPage.tsx | 81 +++++++++++++++++++ .../import/QuickbooksDesktopCustomersPage.tsx | 21 +++-- 8 files changed, 108 insertions(+), 6 deletions(-) create mode 100644 src/pages/workspace/accounting/qbd/import/QuickbooksDesktopCustomersDisplayedAsPage.tsx diff --git a/src/ROUTES.ts b/src/ROUTES.ts index ef706bb4471a..2dd24f013c26 100644 --- a/src/ROUTES.ts +++ b/src/ROUTES.ts @@ -726,6 +726,10 @@ const ROUTES = { route: 'settings/workspaces/:policyID/accounting/quickbooks-desktop/import/customers', getRoute: (policyID: string) => `settings/workspaces/${policyID}/accounting/quickbooks-desktop/import/customers` as const, }, + POLICY_ACCOUNTING_QUICKBOOKS_DESKTOP_CUSTOMERS_DISPLAYED_AS: { + route: 'settings/workspaces/:policyID/accounting/quickbooks-desktop/import/customers/displayed_as', + getRoute: (policyID: string) => `settings/workspaces/${policyID}/accounting/quickbooks-desktop/import/customers/displayed_as` as const, + }, WORKSPACE_PROFILE_NAME: { route: 'settings/workspaces/:policyID/profile/name', getRoute: (policyID: string) => `settings/workspaces/${policyID}/profile/name` as const, diff --git a/src/SCREENS.ts b/src/SCREENS.ts index ce746b214df2..05f5d8aea703 100644 --- a/src/SCREENS.ts +++ b/src/SCREENS.ts @@ -331,6 +331,7 @@ const SCREENS = { QUICKBOOKS_DESKTOP_CLASSES: 'Policy_Accounting_Quickbooks_Desktop_Import_Classes', QUICKBOOKS_DESKTOP_CLASSES_DISPLAYED_AS: 'Policy_Accounting_Quickbooks_Desktop_Import_Classes_Dipslayed_As', QUICKBOOKS_DESKTOP_CUSTOMERS: 'Policy_Accounting_Quickbooks_Desktop_Import_Customers', + QUICKBOOKS_DESKTOP_CUSTOMERS_DISPLAYED_AS: 'Policy_Accounting_Quickbooks_Desktop_Import_Customers_Dipslayed_As', XERO_IMPORT: 'Policy_Accounting_Xero_Import', XERO_ORGANIZATION: 'Policy_Accounting_Xero_Customers', XERO_CHART_OF_ACCOUNTS: 'Policy_Accounting_Xero_Import_Chart_Of_Accounts', diff --git a/src/libs/Navigation/AppNavigator/ModalStackNavigators/index.tsx b/src/libs/Navigation/AppNavigator/ModalStackNavigators/index.tsx index d6645358a00b..1d2a86f8906d 100644 --- a/src/libs/Navigation/AppNavigator/ModalStackNavigators/index.tsx +++ b/src/libs/Navigation/AppNavigator/ModalStackNavigators/index.tsx @@ -335,6 +335,8 @@ const SettingsModalStackNavigator = createModalStackNavigator require('../../../../pages/workspace/accounting/qbd/import/QuickbooksDesktopClassesDisplayedAsPage').default, [SCREENS.WORKSPACE.ACCOUNTING.QUICKBOOKS_DESKTOP_CUSTOMERS]: () => require('../../../../pages/workspace/accounting/qbd/import/QuickbooksDesktopCustomersPage').default, + [SCREENS.WORKSPACE.ACCOUNTING.QUICKBOOKS_DESKTOP_CUSTOMERS_DISPLAYED_AS]: () => + require('../../../../pages/workspace/accounting/qbd/import/QuickbooksDesktopCustomersDisplayedAsPage').default, [SCREENS.REIMBURSEMENT_ACCOUNT]: () => require('../../../../pages/ReimbursementAccount/ReimbursementAccountPage').default, [SCREENS.GET_ASSISTANCE]: () => require('../../../../pages/GetAssistancePage').default, [SCREENS.SETTINGS.TWO_FACTOR_AUTH]: () => require('../../../../pages/settings/Security/TwoFactorAuth/TwoFactorAuthPage').default, diff --git a/src/libs/Navigation/linkingConfig/FULL_SCREEN_TO_RHP_MAPPING.ts b/src/libs/Navigation/linkingConfig/FULL_SCREEN_TO_RHP_MAPPING.ts index 744b1ebc442c..f2fbe0b5930a 100755 --- a/src/libs/Navigation/linkingConfig/FULL_SCREEN_TO_RHP_MAPPING.ts +++ b/src/libs/Navigation/linkingConfig/FULL_SCREEN_TO_RHP_MAPPING.ts @@ -59,6 +59,7 @@ const FULL_SCREEN_TO_RHP_MAPPING: Partial> = { SCREENS.WORKSPACE.ACCOUNTING.QUICKBOOKS_DESKTOP_CLASSES, SCREENS.WORKSPACE.ACCOUNTING.QUICKBOOKS_DESKTOP_CLASSES_DISPLAYED_AS, SCREENS.WORKSPACE.ACCOUNTING.QUICKBOOKS_DESKTOP_CUSTOMERS, + SCREENS.WORKSPACE.ACCOUNTING.QUICKBOOKS_DESKTOP_CUSTOMERS_DISPLAYED_AS, SCREENS.WORKSPACE.ACCOUNTING.XERO_IMPORT, SCREENS.WORKSPACE.ACCOUNTING.XERO_CHART_OF_ACCOUNTS, SCREENS.WORKSPACE.ACCOUNTING.XERO_ORGANIZATION, diff --git a/src/libs/Navigation/linkingConfig/config.ts b/src/libs/Navigation/linkingConfig/config.ts index e095f5661786..93db7cbfc9ca 100644 --- a/src/libs/Navigation/linkingConfig/config.ts +++ b/src/libs/Navigation/linkingConfig/config.ts @@ -419,6 +419,7 @@ const config: LinkingOptions['config'] = { [SCREENS.WORKSPACE.ACCOUNTING.QUICKBOOKS_DESKTOP_CLASSES]: {path: ROUTES.POLICY_ACCOUNTING_QUICKBOOKS_DESKTOP_CLASSES.route}, [SCREENS.WORKSPACE.ACCOUNTING.QUICKBOOKS_DESKTOP_CLASSES_DISPLAYED_AS]: {path: ROUTES.POLICY_ACCOUNTING_QUICKBOOKS_DESKTOP_CLASSES_DISPLAYED_AS.route}, [SCREENS.WORKSPACE.ACCOUNTING.QUICKBOOKS_DESKTOP_CUSTOMERS]: {path: ROUTES.POLICY_ACCOUNTING_QUICKBOOKS_DESKTOP_CUSTOMERS.route}, + [SCREENS.WORKSPACE.ACCOUNTING.QUICKBOOKS_DESKTOP_CUSTOMERS_DISPLAYED_AS]: {path: ROUTES.POLICY_ACCOUNTING_QUICKBOOKS_DESKTOP_CUSTOMERS_DISPLAYED_AS.route}, [SCREENS.WORKSPACE.ACCOUNTING.XERO_IMPORT]: {path: ROUTES.POLICY_ACCOUNTING_XERO_IMPORT.route}, [SCREENS.WORKSPACE.ACCOUNTING.XERO_CHART_OF_ACCOUNTS]: {path: ROUTES.POLICY_ACCOUNTING_XERO_CHART_OF_ACCOUNTS.route}, [SCREENS.WORKSPACE.ACCOUNTING.XERO_ORGANIZATION]: {path: ROUTES.POLICY_ACCOUNTING_XERO_ORGANIZATION.route}, diff --git a/src/libs/Navigation/types.ts b/src/libs/Navigation/types.ts index e500437f0844..70974dcc2f80 100644 --- a/src/libs/Navigation/types.ts +++ b/src/libs/Navigation/types.ts @@ -475,6 +475,9 @@ type SettingsNavigatorParamList = { [SCREENS.WORKSPACE.ACCOUNTING.QUICKBOOKS_DESKTOP_CUSTOMERS]: { policyID: string; }; + [SCREENS.WORKSPACE.ACCOUNTING.QUICKBOOKS_DESKTOP_CUSTOMERS_DISPLAYED_AS]: { + policyID: string; + }; [SCREENS.WORKSPACE.ACCOUNTING.XERO_IMPORT]: { policyID: string; }; diff --git a/src/pages/workspace/accounting/qbd/import/QuickbooksDesktopCustomersDisplayedAsPage.tsx b/src/pages/workspace/accounting/qbd/import/QuickbooksDesktopCustomersDisplayedAsPage.tsx new file mode 100644 index 000000000000..a4b0a94bfd5e --- /dev/null +++ b/src/pages/workspace/accounting/qbd/import/QuickbooksDesktopCustomersDisplayedAsPage.tsx @@ -0,0 +1,81 @@ +import React, {useCallback} from 'react'; +import RadioListItem from '@components/SelectionList/RadioListItem'; +import type {ListItem} from '@components/SelectionList/types'; +import SelectionScreen from '@components/SelectionScreen'; +import useLocalize from '@hooks/useLocalize'; +import usePermissions from '@hooks/usePermissions'; +import useThemeStyles from '@hooks/useThemeStyles'; +import * as QuickbooksDesktop from '@libs/actions/connections/QuickbooksDesktop'; +import * as ErrorUtils from '@libs/ErrorUtils'; +import * as PolicyUtils from '@libs/PolicyUtils'; +import Navigation from '@navigation/Navigation'; +import type {WithPolicyConnectionsProps} from '@pages/workspace/withPolicyConnections'; +import withPolicyConnections from '@pages/workspace/withPolicyConnections'; +import {clearQBDErrorField} from '@userActions/Policy/Policy'; +import CONST from '@src/CONST'; +import ROUTES from '@src/ROUTES'; + +type CardListItem = ListItem & { + value: keyof typeof CONST.INTEGRATION_ENTITY_MAP_TYPES; +}; + +function QuickbooksDesktopCustomersDisplayedAsPage({policy}: WithPolicyConnectionsProps) { + const {translate} = useLocalize(); + const {canUseNewDotQBD} = usePermissions(); + const styles = useThemeStyles(); + const policyID = policy?.id ?? '-1'; + const qbdConfig = policy?.connections?.quickbooksDesktop?.config; + + const data: CardListItem[] = [ + { + value: CONST.INTEGRATION_ENTITY_MAP_TYPES.TAG, + text: translate('workspace.common.tags'), + alternateText: translate('workspace.qbd.tagsDisplayedAsDescription'), + keyForList: CONST.INTEGRATION_ENTITY_MAP_TYPES.TAG, + isSelected: qbdConfig?.mappings?.customers === CONST.INTEGRATION_ENTITY_MAP_TYPES.TAG, + }, + { + value: CONST.INTEGRATION_ENTITY_MAP_TYPES.REPORT_FIELD, + text: translate('workspace.common.reportFields'), + alternateText: translate('workspace.qbd.reportFieldsDisplayedAsDescription'), + keyForList: CONST.INTEGRATION_ENTITY_MAP_TYPES.REPORT_FIELD, + isSelected: qbdConfig?.mappings?.customers === CONST.INTEGRATION_ENTITY_MAP_TYPES.REPORT_FIELD, + }, + ]; + + const selectDisplayedAs = useCallback( + (row: CardListItem) => { + if (row.value !== qbdConfig?.mappings?.customers) { + QuickbooksDesktop.updateQuickbooksDesktopSyncCustomers(policyID, row.value, qbdConfig?.mappings?.customers); + } + Navigation.goBack(ROUTES.POLICY_ACCOUNTING_QUICKBOOKS_DESKTOP_CUSTOMERS.getRoute(policyID)); + }, + [qbdConfig?.mappings?.customers, policyID], + ); + + return ( + Navigation.goBack(ROUTES.POLICY_ACCOUNTING_QUICKBOOKS_DESKTOP_CUSTOMERS.getRoute(policyID))} + onSelectRow={selectDisplayedAs} + initiallyFocusedOptionKey={data.find((mode) => mode.isSelected)?.keyForList} + title="workspace.common.displayedAs" + shouldBeBlocked={!canUseNewDotQBD} // TODO: [QBD] remove it once the QBD beta is done + connectionName={CONST.POLICY.CONNECTIONS.NAME.QBD} + pendingAction={PolicyUtils.settingsPendingAction([CONST.QUICKBOOKS_DESKTOP_CONFIG.MAPPINGS.CUSTOMERS], qbdConfig?.pendingFields)} + errors={ErrorUtils.getLatestErrorField(qbdConfig, CONST.QUICKBOOKS_DESKTOP_CONFIG.MAPPINGS.CUSTOMERS)} + errorRowStyles={[styles.ph5, styles.pv3]} + onClose={() => clearQBDErrorField(policyID, CONST.QUICKBOOKS_DESKTOP_CONFIG.MAPPINGS.CUSTOMERS)} + shouldSingleExecuteRowSelect + /> + ); +} + +QuickbooksDesktopCustomersDisplayedAsPage.displayName = 'QuickbooksDesktopCustomersDisplayedAsPage'; + +export default withPolicyConnections(QuickbooksDesktopCustomersDisplayedAsPage); diff --git a/src/pages/workspace/accounting/qbd/import/QuickbooksDesktopCustomersPage.tsx b/src/pages/workspace/accounting/qbd/import/QuickbooksDesktopCustomersPage.tsx index e59b5ac317fb..e58826a12703 100644 --- a/src/pages/workspace/accounting/qbd/import/QuickbooksDesktopCustomersPage.tsx +++ b/src/pages/workspace/accounting/qbd/import/QuickbooksDesktopCustomersPage.tsx @@ -1,6 +1,7 @@ import React from 'react'; import ConnectionLayout from '@components/ConnectionLayout'; import MenuItemWithTopDescription from '@components/MenuItemWithTopDescription'; +import OfflineWithFeedback from '@components/OfflineWithFeedback'; import useLocalize from '@hooks/useLocalize'; import usePermissions from '@hooks/usePermissions'; import useThemeStyles from '@hooks/useThemeStyles'; @@ -53,12 +54,20 @@ function QuickbooksDesktopCustomersPage({policy}: WithPolicyProps) { onCloseError={() => clearQBDErrorField(policyID, CONST.QUICKBOOKS_DESKTOP_CONFIG.MAPPINGS.CUSTOMERS)} /> {isSwitchOn && ( - + + Navigation.navigate(ROUTES.POLICY_ACCOUNTING_QUICKBOOKS_DESKTOP_CUSTOMERS_DISPLAYED_AS.getRoute(policyID))} + brickRoadIndicator={ + PolicyUtils.areSettingsInErrorFields([CONST.QUICKBOOKS_DESKTOP_CONFIG.MAPPINGS.CUSTOMERS], qbdConfig?.errorFields) + ? CONST.BRICK_ROAD_INDICATOR_STATUS.ERROR + : undefined + } + /> + )} ); From 0d0ecedd21e8510a0139ec5c6ef2d27892482663 Mon Sep 17 00:00:00 2001 From: VH Date: Wed, 16 Oct 2024 18:19:07 +0700 Subject: [PATCH 4/5] Fix wrong API command --- src/libs/actions/connections/QuickbooksDesktop.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/libs/actions/connections/QuickbooksDesktop.ts b/src/libs/actions/connections/QuickbooksDesktop.ts index e84920ef56a8..e6270296b1a3 100644 --- a/src/libs/actions/connections/QuickbooksDesktop.ts +++ b/src/libs/actions/connections/QuickbooksDesktop.ts @@ -406,7 +406,7 @@ function updateQuickbooksDesktopSyncCustomers( From 49226674348c8e481e14aa1798b9559c8954c83a Mon Sep 17 00:00:00 2001 From: VH Date: Wed, 16 Oct 2024 18:41:06 +0700 Subject: [PATCH 5/5] Run prettier --- .../Navigation/AppNavigator/ModalStackNavigators/index.tsx | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/libs/Navigation/AppNavigator/ModalStackNavigators/index.tsx b/src/libs/Navigation/AppNavigator/ModalStackNavigators/index.tsx index 173e1c46861f..fabf7fb78591 100644 --- a/src/libs/Navigation/AppNavigator/ModalStackNavigators/index.tsx +++ b/src/libs/Navigation/AppNavigator/ModalStackNavigators/index.tsx @@ -336,7 +336,8 @@ const SettingsModalStackNavigator = createModalStackNavigator require('../../../../pages/workspace/accounting/qbd/import/QuickbooksDesktopClassesPage').default, [SCREENS.WORKSPACE.ACCOUNTING.QUICKBOOKS_DESKTOP_CLASSES_DISPLAYED_AS]: () => require('../../../../pages/workspace/accounting/qbd/import/QuickbooksDesktopClassesDisplayedAsPage').default, - [SCREENS.WORKSPACE.ACCOUNTING.QUICKBOOKS_DESKTOP_CUSTOMERS]: () => require('../../../../pages/workspace/accounting/qbd/import/QuickbooksDesktopCustomersPage').default, + [SCREENS.WORKSPACE.ACCOUNTING.QUICKBOOKS_DESKTOP_CUSTOMERS]: () => + require('../../../../pages/workspace/accounting/qbd/import/QuickbooksDesktopCustomersPage').default, [SCREENS.WORKSPACE.ACCOUNTING.QUICKBOOKS_DESKTOP_CUSTOMERS_DISPLAYED_AS]: () => require('../../../../pages/workspace/accounting/qbd/import/QuickbooksDesktopCustomersDisplayedAsPage').default, [SCREENS.REIMBURSEMENT_ACCOUNT]: () => require('../../../../pages/ReimbursementAccount/ReimbursementAccountPage').default,