From 7938e75f4b7999aa842ed6643d718d4a66e54332 Mon Sep 17 00:00:00 2001 From: Manan Jadhav Date: Wed, 1 May 2024 20:18:36 +0530 Subject: [PATCH 01/29] feat: basic screens and navigation setup --- src/CONST.ts | 1 + src/ROUTES.ts | 12 ++++++++++++ src/SCREENS.ts | 3 +++ src/languages/en.ts | 6 ++++++ src/languages/es.ts | 6 ++++++ .../AppNavigator/ModalStackNavigators/index.tsx | 3 +++ .../linkingConfig/FULL_SCREEN_TO_RHP_MAPPING.ts | 3 +++ src/libs/Navigation/linkingConfig/config.ts | 3 +++ .../workspace/accounting/xero/XeroImportPage.tsx | 2 +- .../accounting/xero/XeroMapCostCentersToPage.tsx | 10 ++++++++++ .../accounting/xero/XeroMapRegionsToPage.tsx | 10 ++++++++++ .../accounting/xero/XeroTrackCategoriesPage.tsx | 10 ++++++++++ 12 files changed, 68 insertions(+), 1 deletion(-) create mode 100644 src/pages/workspace/accounting/xero/XeroMapCostCentersToPage.tsx create mode 100644 src/pages/workspace/accounting/xero/XeroMapRegionsToPage.tsx create mode 100644 src/pages/workspace/accounting/xero/XeroTrackCategoriesPage.tsx diff --git a/src/CONST.ts b/src/CONST.ts index 9d3042b64f80..411be788b645 100755 --- a/src/CONST.ts +++ b/src/CONST.ts @@ -1268,6 +1268,7 @@ const CONST = { XERO_CONFIG: { IMPORT_TAX_RATES: 'importTaxRates', + TRACK_CATEGORIES: 'trackCategories', }, QUICKBOOKS_EXPORT_ENTITY: { diff --git a/src/ROUTES.ts b/src/ROUTES.ts index 801914fc1515..c25dccb4a171 100644 --- a/src/ROUTES.ts +++ b/src/ROUTES.ts @@ -774,6 +774,18 @@ const ROUTES = { route: 'settings/workspaces/:policyID/accounting/xero/organization/:currentOrganizationID', getRoute: (policyID: string, currentOrganizationID: string) => `settings/workspaces/${policyID}/accounting/xero/organization/${currentOrganizationID}` as const, }, + POLICY_ACCOUNTING_XERO_TRACK_CATEGORIES: { + route: 'settings/workspaces/:policyID/accounting/xero/import/trackCategories', + getRoute: (policyID: string) => `settings/workspaces/${policyID}/accounting/xero/import/trackCategories` as const, + }, + POLICY_ACCOUNTING_XERO_MAP_COST_CENTERS: { + route: 'settings/workspaces/:policyID/accounting/xero/import/trackCategories/mapCostCenters', + getRoute: (policyID: string) => `settings/workspaces/${policyID}/accounting/xero/import/trackCategories/mapCostCenters` as const, + }, + POLICY_ACCOUNTING_XERO_MAP_REGIONS: { + route: 'settings/workspaces/:policyID/accounting/xero/import/trackCategories/mapRegions', + getRoute: (policyID: string) => `settings/workspaces/${policyID}/accounting/xero/import/trackCategories/mapRegions` as const, + }, POLICY_ACCOUNTING_XERO_TAXES: { route: 'settings/workspaces/:policyID/accounting/xero/import/taxes', getRoute: (policyID: string) => `settings/workspaces/${policyID}/accounting/xero/import/taxes` as const, diff --git a/src/SCREENS.ts b/src/SCREENS.ts index 56363b09c980..bd4e9783650b 100644 --- a/src/SCREENS.ts +++ b/src/SCREENS.ts @@ -237,6 +237,9 @@ const SCREENS = { XERO_IMPORT: 'Policy_Accounting_Xero_Import', XERO_ORGANIZATION: 'Policy_Accounting_Xero_Customers', XERO_TAXES: 'Policy_Accounting_Xero_Taxes', + XERO_TRACK_CATEGORIES: 'Policy_Accounting_Xero_Track_Categories', + XERO_MAP_COST_CENTERS: 'Policy_Accounting_Xero_Map_Cost_Centers', + XERO_MAP_REGIONS: 'Policy_Accounting_Xero_Map_Regions' }, INITIAL: 'Workspace_Initial', PROFILE: 'Workspace_Profile', diff --git a/src/languages/en.ts b/src/languages/en.ts index 4365ce6a6a88..f565dc073db9 100755 --- a/src/languages/en.ts +++ b/src/languages/en.ts @@ -1993,6 +1993,12 @@ export default { organizationDescription: 'Select the organization in Xero you are importing data from.', importDescription: 'Choose which coding configurations are imported from Xero to Expensify.', trackingCategories: 'Tracking categories', + trackingCategoriesDescription: 'Choose whether to import tracking categories and see where they are displayed.', + mapXeroCostCentersTo: 'Map Xero cost centers to', + mapXeroRegionsTo: 'Map Xero regions to', + mapXeroCostCentersToDescription: 'Choose where to map cost centers to when exporting to Xero.', + mapXeroCostRegionsToDescription: 'Choose where to map employee regions when exporting expense reports to Xero', + xeroContactDefault: 'Xero contact default', customers: 'Re-bill customers', taxesDescription: 'Choose whether to import tax rates and tax defaults from your accounting integration.', notImported: 'Not imported', diff --git a/src/languages/es.ts b/src/languages/es.ts index 3301734636ef..c92d431b43e1 100644 --- a/src/languages/es.ts +++ b/src/languages/es.ts @@ -2020,6 +2020,12 @@ export default { organizationDescription: 'Seleccione la organización en Xero desde la que está importando los datos.', importDescription: 'Elija qué configuraciones de codificación se importan de Xero a Expensify.', trackingCategories: 'Categorías de seguimiento', + trackingCategoriesDescription: 'Choose whether to import tracking categories and see where they are displayed.', + mapXeroCostCentersTo: 'Map Xero cost centers to', + mapXeroRegionsTo: 'Map Xero regions to', + mapXeroCostCentersToDescription: 'Choose where to map cost centers to when exporting to Xero.', + mapXeroCostRegionsToDescription: 'Choose where to map employee regions when exporting expense reports to Xero', + xeroContactDefault: 'Xero contact default', customers: 'Volver a facturar a los clientes', taxesDescription: 'Elige si quires importar las tasas de impuestos y los impuestos por defecto de tu integración de contaduría.', notImported: 'No importado', diff --git a/src/libs/Navigation/AppNavigator/ModalStackNavigators/index.tsx b/src/libs/Navigation/AppNavigator/ModalStackNavigators/index.tsx index 79fe3628a782..7e045f879582 100644 --- a/src/libs/Navigation/AppNavigator/ModalStackNavigators/index.tsx +++ b/src/libs/Navigation/AppNavigator/ModalStackNavigators/index.tsx @@ -296,6 +296,9 @@ const SettingsModalStackNavigator = createModalStackNavigator require('../../../../pages/workspace/accounting/xero/XeroImportPage').default as React.ComponentType, [SCREENS.WORKSPACE.ACCOUNTING.XERO_ORGANIZATION]: () => require('../../../../pages/workspace/accounting/xero/XeroOrganizationConfigurationPage').default as React.ComponentType, [SCREENS.WORKSPACE.ACCOUNTING.XERO_TAXES]: () => require('../../../../pages/workspace/accounting/xero/XeroTaxesConfigurationPage').default as React.ComponentType, + [SCREENS.WORKSPACE.ACCOUNTING.XERO_TRACK_CATEGORIES]: () => require('../../../../pages/workspace/accounting/xero/XeroTrackCategoriesPage').default as React.ComponentType, + [SCREENS.WORKSPACE.ACCOUNTING.XERO_MAP_COST_CENTERS]: () => require('../../../../pages/workspace/accounting/xero/XeroMapCostCentersToPage').default as React.ComponentType, + [SCREENS.WORKSPACE.ACCOUNTING.XERO_MAP_REGIONS]: () => require('../../../../pages/workspace/accounting/xero/XeroMapRegionsToPage').default as React.ComponentType, [SCREENS.WORKSPACE.WORKFLOWS_AUTO_REPORTING_FREQUENCY]: () => require('../../../../pages/workspace/workflows/WorkspaceAutoReportingFrequencyPage').default as React.ComponentType, [SCREENS.WORKSPACE.WORKFLOWS_AUTO_REPORTING_MONTHLY_OFFSET]: () => require('../../../../pages/workspace/workflows/WorkspaceAutoReportingMonthlyOffsetPage').default as React.ComponentType, 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 7712d1fc56a8..0c5953e0ee99 100755 --- a/src/libs/Navigation/linkingConfig/FULL_SCREEN_TO_RHP_MAPPING.ts +++ b/src/libs/Navigation/linkingConfig/FULL_SCREEN_TO_RHP_MAPPING.ts @@ -42,6 +42,9 @@ const FULL_SCREEN_TO_RHP_MAPPING: Partial> = { SCREENS.WORKSPACE.ACCOUNTING.XERO_IMPORT, SCREENS.WORKSPACE.ACCOUNTING.XERO_ORGANIZATION, SCREENS.WORKSPACE.ACCOUNTING.XERO_TAXES, + SCREENS.WORKSPACE.ACCOUNTING.XERO_TRACK_CATEGORIES, + SCREENS.WORKSPACE.ACCOUNTING.XERO_MAP_COST_CENTERS, + SCREENS.WORKSPACE.ACCOUNTING.XERO_MAP_REGIONS, ], [SCREENS.WORKSPACE.TAXES]: [ SCREENS.WORKSPACE.TAXES_SETTINGS, diff --git a/src/libs/Navigation/linkingConfig/config.ts b/src/libs/Navigation/linkingConfig/config.ts index fb27b9b63447..3d7df5c541cb 100644 --- a/src/libs/Navigation/linkingConfig/config.ts +++ b/src/libs/Navigation/linkingConfig/config.ts @@ -326,6 +326,9 @@ const config: LinkingOptions['config'] = { }, [SCREENS.WORKSPACE.ACCOUNTING.XERO_IMPORT]: {path: ROUTES.POLICY_ACCOUNTING_XERO_IMPORT.route}, [SCREENS.WORKSPACE.ACCOUNTING.XERO_ORGANIZATION]: {path: ROUTES.POLICY_ACCOUNTING_XERO_ORGANIZATION.route}, + [SCREENS.WORKSPACE.ACCOUNTING.XERO_TRACK_CATEGORIES]: {path: ROUTES.POLICY_ACCOUNTING_XERO_TRACK_CATEGORIES.route}, + [SCREENS.WORKSPACE.ACCOUNTING.XERO_MAP_COST_CENTERS]: {path: ROUTES.POLICY_ACCOUNTING_XERO_MAP_COST_CENTERS.route}, + [SCREENS.WORKSPACE.ACCOUNTING.XERO_MAP_REGIONS]: {path: ROUTES.POLICY_ACCOUNTING_XERO_MAP_REGIONS.route}, [SCREENS.WORKSPACE.ACCOUNTING.XERO_TAXES]: {path: ROUTES.POLICY_ACCOUNTING_XERO_TAXES.route}, [SCREENS.WORKSPACE.DESCRIPTION]: { path: ROUTES.WORKSPACE_PROFILE_DESCRIPTION.route, diff --git a/src/pages/workspace/accounting/xero/XeroImportPage.tsx b/src/pages/workspace/accounting/xero/XeroImportPage.tsx index af36bfcc42cd..180b977e56a5 100644 --- a/src/pages/workspace/accounting/xero/XeroImportPage.tsx +++ b/src/pages/workspace/accounting/xero/XeroImportPage.tsx @@ -36,7 +36,7 @@ function XeroImportPage({policy}: WithPolicyProps) { }, { description: translate('workspace.xero.trackingCategories'), - action: () => {}, + action: () => Navigation.navigate(ROUTES.POLICY_ACCOUNTING_XERO_TRACK_CATEGORIES.getRoute(policyID)), hasError: !!policy?.errors?.importTrackingCategories, title: importTrackingCategories ? translate('workspace.accounting.importedAsTags') : translate('workspace.xero.notImported'), pendingAction: pendingFields?.importTrackingCategories, diff --git a/src/pages/workspace/accounting/xero/XeroMapCostCentersToPage.tsx b/src/pages/workspace/accounting/xero/XeroMapCostCentersToPage.tsx new file mode 100644 index 000000000000..0bf7ffd044ea --- /dev/null +++ b/src/pages/workspace/accounting/xero/XeroMapCostCentersToPage.tsx @@ -0,0 +1,10 @@ +import React from 'react'; + +function XeroMapCostCentersToPage() { + return <> + Xero Cost Centers + +} + +XeroMapCostCentersToPage.displayName = 'XeroMapCostCentersToPage'; +export default XeroMapCostCentersToPage; \ No newline at end of file diff --git a/src/pages/workspace/accounting/xero/XeroMapRegionsToPage.tsx b/src/pages/workspace/accounting/xero/XeroMapRegionsToPage.tsx new file mode 100644 index 000000000000..682a169b8039 --- /dev/null +++ b/src/pages/workspace/accounting/xero/XeroMapRegionsToPage.tsx @@ -0,0 +1,10 @@ +import React from 'react'; + +function XeroMapRegionsToPage() { + return <> + XeroMapRegionsToPage + +} + +XeroMapRegionsToPage.displayName = 'XeroMapRegionsToPage'; +export default XeroMapRegionsToPage; \ No newline at end of file diff --git a/src/pages/workspace/accounting/xero/XeroTrackCategoriesPage.tsx b/src/pages/workspace/accounting/xero/XeroTrackCategoriesPage.tsx new file mode 100644 index 000000000000..3da0c6bef2ad --- /dev/null +++ b/src/pages/workspace/accounting/xero/XeroTrackCategoriesPage.tsx @@ -0,0 +1,10 @@ +import React from 'react'; + +function XeroTrackCategoriesPage() { + return <> + Xero Track Categories + +} + +XeroTrackCategoriesPage.displayName = 'XeroTrackCategoriesPage'; +export default XeroTrackCategoriesPage; \ No newline at end of file From 5a12e040676bc5b24f31ed654605a450c17b7393 Mon Sep 17 00:00:00 2001 From: Manan Jadhav Date: Thu, 2 May 2024 00:36:06 +0530 Subject: [PATCH 02/29] feat: added more config pages --- src/CONST.ts | 2 +- src/SCREENS.ts | 2 +- .../ModalStackNavigators/index.tsx | 6 +- src/libs/Navigation/types.ts | 3 + .../XeroMapCostCentersToConfigurationPage.tsx | 59 ++++++++++++ .../xero/XeroMapCostCentersToPage.tsx | 10 -- .../XeroMapRegionsToConfigurationPage.tsx | 8 ++ .../accounting/xero/XeroMapRegionsToPage.tsx | 10 -- .../xero/XeroTrackCategoriesPage.tsx | 10 -- .../XeroTrackingCategoryConfigurationPage.tsx | 93 +++++++++++++++++++ 10 files changed, 168 insertions(+), 35 deletions(-) create mode 100644 src/pages/workspace/accounting/xero/XeroMapCostCentersToConfigurationPage.tsx delete mode 100644 src/pages/workspace/accounting/xero/XeroMapCostCentersToPage.tsx create mode 100644 src/pages/workspace/accounting/xero/XeroMapRegionsToConfigurationPage.tsx delete mode 100644 src/pages/workspace/accounting/xero/XeroMapRegionsToPage.tsx delete mode 100644 src/pages/workspace/accounting/xero/XeroTrackCategoriesPage.tsx create mode 100644 src/pages/workspace/accounting/xero/XeroTrackingCategoryConfigurationPage.tsx diff --git a/src/CONST.ts b/src/CONST.ts index 411be788b645..0f28a92db8f6 100755 --- a/src/CONST.ts +++ b/src/CONST.ts @@ -1268,7 +1268,7 @@ const CONST = { XERO_CONFIG: { IMPORT_TAX_RATES: 'importTaxRates', - TRACK_CATEGORIES: 'trackCategories', + IMPORT_TRACK_CATEGORIES: 'importTrackingCategories', }, QUICKBOOKS_EXPORT_ENTITY: { diff --git a/src/SCREENS.ts b/src/SCREENS.ts index bd4e9783650b..2fe314968db2 100644 --- a/src/SCREENS.ts +++ b/src/SCREENS.ts @@ -239,7 +239,7 @@ const SCREENS = { XERO_TAXES: 'Policy_Accounting_Xero_Taxes', XERO_TRACK_CATEGORIES: 'Policy_Accounting_Xero_Track_Categories', XERO_MAP_COST_CENTERS: 'Policy_Accounting_Xero_Map_Cost_Centers', - XERO_MAP_REGIONS: 'Policy_Accounting_Xero_Map_Regions' + XERO_MAP_REGIONS: 'Policy_Accounting_Xero_Map_Regions', }, INITIAL: 'Workspace_Initial', PROFILE: 'Workspace_Profile', diff --git a/src/libs/Navigation/AppNavigator/ModalStackNavigators/index.tsx b/src/libs/Navigation/AppNavigator/ModalStackNavigators/index.tsx index 7e045f879582..59b0d2232c8b 100644 --- a/src/libs/Navigation/AppNavigator/ModalStackNavigators/index.tsx +++ b/src/libs/Navigation/AppNavigator/ModalStackNavigators/index.tsx @@ -296,9 +296,9 @@ const SettingsModalStackNavigator = createModalStackNavigator require('../../../../pages/workspace/accounting/xero/XeroImportPage').default as React.ComponentType, [SCREENS.WORKSPACE.ACCOUNTING.XERO_ORGANIZATION]: () => require('../../../../pages/workspace/accounting/xero/XeroOrganizationConfigurationPage').default as React.ComponentType, [SCREENS.WORKSPACE.ACCOUNTING.XERO_TAXES]: () => require('../../../../pages/workspace/accounting/xero/XeroTaxesConfigurationPage').default as React.ComponentType, - [SCREENS.WORKSPACE.ACCOUNTING.XERO_TRACK_CATEGORIES]: () => require('../../../../pages/workspace/accounting/xero/XeroTrackCategoriesPage').default as React.ComponentType, - [SCREENS.WORKSPACE.ACCOUNTING.XERO_MAP_COST_CENTERS]: () => require('../../../../pages/workspace/accounting/xero/XeroMapCostCentersToPage').default as React.ComponentType, - [SCREENS.WORKSPACE.ACCOUNTING.XERO_MAP_REGIONS]: () => require('../../../../pages/workspace/accounting/xero/XeroMapRegionsToPage').default as React.ComponentType, + [SCREENS.WORKSPACE.ACCOUNTING.XERO_TRACK_CATEGORIES]: () => require('../../../../pages/workspace/accounting/xero/XeroTrackingCategoryConfigurationPage').default as React.ComponentType, + [SCREENS.WORKSPACE.ACCOUNTING.XERO_MAP_COST_CENTERS]: () => require('../../../../pages/workspace/accounting/xero/XeroMapCostCentersToConfigurationPage').default as React.ComponentType, + [SCREENS.WORKSPACE.ACCOUNTING.XERO_MAP_REGIONS]: () => require('../../../../pages/workspace/accounting/xero/XeroMapRegionsToConfigurationPage').default as React.ComponentType, [SCREENS.WORKSPACE.WORKFLOWS_AUTO_REPORTING_FREQUENCY]: () => require('../../../../pages/workspace/workflows/WorkspaceAutoReportingFrequencyPage').default as React.ComponentType, [SCREENS.WORKSPACE.WORKFLOWS_AUTO_REPORTING_MONTHLY_OFFSET]: () => require('../../../../pages/workspace/workflows/WorkspaceAutoReportingMonthlyOffsetPage').default as React.ComponentType, diff --git a/src/libs/Navigation/types.ts b/src/libs/Navigation/types.ts index 7722de72645f..b5bebc400196 100644 --- a/src/libs/Navigation/types.ts +++ b/src/libs/Navigation/types.ts @@ -318,6 +318,9 @@ type SettingsNavigatorParamList = { [SCREENS.WORKSPACE.ACCOUNTING.XERO_TAXES]: { policyID: string; }; + [SCREENS.WORKSPACE.ACCOUNTING.XERO_TRACK_CATEGORIES]: { + policyID: string; + }; [SCREENS.GET_ASSISTANCE]: { backTo: Routes; }; diff --git a/src/pages/workspace/accounting/xero/XeroMapCostCentersToConfigurationPage.tsx b/src/pages/workspace/accounting/xero/XeroMapCostCentersToConfigurationPage.tsx new file mode 100644 index 000000000000..cb0ca49ff6fc --- /dev/null +++ b/src/pages/workspace/accounting/xero/XeroMapCostCentersToConfigurationPage.tsx @@ -0,0 +1,59 @@ +import React from 'react'; +import {View} from 'react-native'; +import HeaderWithBackButton from '@components/HeaderWithBackButton'; +import OfflineWithFeedback from '@components/OfflineWithFeedback'; +import ScreenWrapper from '@components/ScreenWrapper'; +import SelectionList from '@components/SelectionList'; +import RadioListItem from '@components/SelectionList/RadioListItem'; +import useLocalize from '@hooks/useLocalize'; +import useThemeStyles from '@hooks/useThemeStyles'; +import AccessOrNotFoundWrapper from '@pages/workspace/AccessOrNotFoundWrapper'; +import type {WithPolicyProps} from '@pages/workspace/withPolicy'; +import withPolicyConnections from '@pages/workspace/withPolicyConnections'; +import CONST from '@src/CONST'; + +function XeroMapCostCentersToConfigurationPage({policy}: WithPolicyProps) { + const {translate} = useLocalize(); + const styles = useThemeStyles(); + const policyID = policy?.id ?? ''; + + const optionsList = [ + { + value: 'DEFAULT', + text: translate(`workspace.xero.xeroContactDefault`), + keyForList: 'DEFAULT', + }, + { + value: 'TAGS', + text: 'Tags', + keyForList: 'TAGS', + isSelected: true, + }, + ]; + + return ( + + + + + {}} + /> + + + + ); +} + +XeroMapCostCentersToConfigurationPage.displayName = 'XeroMapCostCentersToConfigurationPage'; +export default withPolicyConnections(XeroMapCostCentersToConfigurationPage); diff --git a/src/pages/workspace/accounting/xero/XeroMapCostCentersToPage.tsx b/src/pages/workspace/accounting/xero/XeroMapCostCentersToPage.tsx deleted file mode 100644 index 0bf7ffd044ea..000000000000 --- a/src/pages/workspace/accounting/xero/XeroMapCostCentersToPage.tsx +++ /dev/null @@ -1,10 +0,0 @@ -import React from 'react'; - -function XeroMapCostCentersToPage() { - return <> - Xero Cost Centers - -} - -XeroMapCostCentersToPage.displayName = 'XeroMapCostCentersToPage'; -export default XeroMapCostCentersToPage; \ No newline at end of file diff --git a/src/pages/workspace/accounting/xero/XeroMapRegionsToConfigurationPage.tsx b/src/pages/workspace/accounting/xero/XeroMapRegionsToConfigurationPage.tsx new file mode 100644 index 000000000000..a9fd95a41060 --- /dev/null +++ b/src/pages/workspace/accounting/xero/XeroMapRegionsToConfigurationPage.tsx @@ -0,0 +1,8 @@ +import React from 'react'; + +function XeroMapRegionsToConfigurationPage() { + return <>XeroMapRegionsToPage; +} + +XeroMapRegionsToConfigurationPage.displayName = 'XeroMapRegionsToConfigurationPage'; +export default XeroMapRegionsToConfigurationPage; diff --git a/src/pages/workspace/accounting/xero/XeroMapRegionsToPage.tsx b/src/pages/workspace/accounting/xero/XeroMapRegionsToPage.tsx deleted file mode 100644 index 682a169b8039..000000000000 --- a/src/pages/workspace/accounting/xero/XeroMapRegionsToPage.tsx +++ /dev/null @@ -1,10 +0,0 @@ -import React from 'react'; - -function XeroMapRegionsToPage() { - return <> - XeroMapRegionsToPage - -} - -XeroMapRegionsToPage.displayName = 'XeroMapRegionsToPage'; -export default XeroMapRegionsToPage; \ No newline at end of file diff --git a/src/pages/workspace/accounting/xero/XeroTrackCategoriesPage.tsx b/src/pages/workspace/accounting/xero/XeroTrackCategoriesPage.tsx deleted file mode 100644 index 3da0c6bef2ad..000000000000 --- a/src/pages/workspace/accounting/xero/XeroTrackCategoriesPage.tsx +++ /dev/null @@ -1,10 +0,0 @@ -import React from 'react'; - -function XeroTrackCategoriesPage() { - return <> - Xero Track Categories - -} - -XeroTrackCategoriesPage.displayName = 'XeroTrackCategoriesPage'; -export default XeroTrackCategoriesPage; \ No newline at end of file diff --git a/src/pages/workspace/accounting/xero/XeroTrackingCategoryConfigurationPage.tsx b/src/pages/workspace/accounting/xero/XeroTrackingCategoryConfigurationPage.tsx new file mode 100644 index 000000000000..3ee0870c2c60 --- /dev/null +++ b/src/pages/workspace/accounting/xero/XeroTrackingCategoryConfigurationPage.tsx @@ -0,0 +1,93 @@ +import React, {useMemo} from 'react'; +import {View} from 'react-native'; +import HeaderWithBackButton from '@components/HeaderWithBackButton'; +import MenuItemWithTopDescription from '@components/MenuItemWithTopDescription'; +import OfflineWithFeedback from '@components/OfflineWithFeedback'; +import ScreenWrapper from '@components/ScreenWrapper'; +import Switch from '@components/Switch'; +import Text from '@components/Text'; +import useLocalize from '@hooks/useLocalize'; +import useThemeStyles from '@hooks/useThemeStyles'; +import * as Connections from '@libs/actions/connections'; +import Navigation from '@libs/Navigation/Navigation'; +import AccessOrNotFoundWrapper from '@pages/workspace/AccessOrNotFoundWrapper'; +import type {WithPolicyProps} from '@pages/workspace/withPolicy'; +import withPolicyConnections from '@pages/workspace/withPolicyConnections'; +import variables from '@styles/variables'; +import CONST from '@src/CONST'; +import ROUTES from '@src/ROUTES'; + +function XeroTrackingCategoryConfigurationPage({policy}: WithPolicyProps) { + const {translate} = useLocalize(); + const styles = useThemeStyles(); + const policyID = policy?.id ?? ''; + const {importTrackingCategories, pendingFields} = policy?.connections?.xero?.config ?? {}; + const menuItems = useMemo( + () => [ + { + title: translate('workspace.xero.mapXeroCostCentersTo'), + action: () => Navigation.navigate(ROUTES.POLICY_ACCOUNTING_XERO_MAP_COST_CENTERS.getRoute(policyID)), + }, + { + title: translate('workspace.xero.mapXeroRegionsTo'), + action: () => Navigation.navigate(ROUTES.POLICY_ACCOUNTING_XERO_MAP_REGIONS.getRoute(policyID)), + }, + ], + [translate, policyID], + ); + + return ( + + + + + {translate('workspace.xero.trackingCategoriesDescription')} + + + {translate('workspace.accounting.import')} + + + + + Connections.updatePolicyConnectionConfig( + policyID, + CONST.POLICY.CONNECTIONS.NAME.XERO, + CONST.XERO_CONFIG.IMPORT_TRACK_CATEGORIES, + !importTrackingCategories, + ) + } + /> + + + + + {importTrackingCategories && ( + + {menuItems.map((menuItem) => ( + + ))} + + )} + + + ); +} + +XeroTrackingCategoryConfigurationPage.displayName = 'XeroTrackCategoriesPage'; +export default withPolicyConnections(XeroTrackingCategoryConfigurationPage); From 605912d2c11b7b81e1e1985ee2fdebfc3dd64def Mon Sep 17 00:00:00 2001 From: Manan Jadhav Date: Thu, 2 May 2024 00:44:39 +0530 Subject: [PATCH 03/29] refactor: update the regions to page --- src/languages/en.ts | 2 +- src/languages/es.ts | 2 +- .../XeroMapCostCentersToConfigurationPage.tsx | 9 +-- .../XeroMapRegionsToConfigurationPage.tsx | 58 ++++++++++++++++++- 4 files changed, 62 insertions(+), 9 deletions(-) diff --git a/src/languages/en.ts b/src/languages/en.ts index f565dc073db9..6350559dc2f7 100755 --- a/src/languages/en.ts +++ b/src/languages/en.ts @@ -1997,7 +1997,7 @@ export default { mapXeroCostCentersTo: 'Map Xero cost centers to', mapXeroRegionsTo: 'Map Xero regions to', mapXeroCostCentersToDescription: 'Choose where to map cost centers to when exporting to Xero.', - mapXeroCostRegionsToDescription: 'Choose where to map employee regions when exporting expense reports to Xero', + mapXeroRegionsToDescription: 'Choose where to map employee regions when exporting expense reports to Xero', xeroContactDefault: 'Xero contact default', customers: 'Re-bill customers', taxesDescription: 'Choose whether to import tax rates and tax defaults from your accounting integration.', diff --git a/src/languages/es.ts b/src/languages/es.ts index c92d431b43e1..570038662769 100644 --- a/src/languages/es.ts +++ b/src/languages/es.ts @@ -2024,7 +2024,7 @@ export default { mapXeroCostCentersTo: 'Map Xero cost centers to', mapXeroRegionsTo: 'Map Xero regions to', mapXeroCostCentersToDescription: 'Choose where to map cost centers to when exporting to Xero.', - mapXeroCostRegionsToDescription: 'Choose where to map employee regions when exporting expense reports to Xero', + mapXeroRegionsToDescription: 'Choose where to map employee regions when exporting expense reports to Xero', xeroContactDefault: 'Xero contact default', customers: 'Volver a facturar a los clientes', taxesDescription: 'Elige si quires importar las tasas de impuestos y los impuestos por defecto de tu integración de contaduría.', diff --git a/src/pages/workspace/accounting/xero/XeroMapCostCentersToConfigurationPage.tsx b/src/pages/workspace/accounting/xero/XeroMapCostCentersToConfigurationPage.tsx index cb0ca49ff6fc..56557fdd4d13 100644 --- a/src/pages/workspace/accounting/xero/XeroMapCostCentersToConfigurationPage.tsx +++ b/src/pages/workspace/accounting/xero/XeroMapCostCentersToConfigurationPage.tsx @@ -1,7 +1,7 @@ import React from 'react'; import {View} from 'react-native'; +import Text from '@components/Text'; import HeaderWithBackButton from '@components/HeaderWithBackButton'; -import OfflineWithFeedback from '@components/OfflineWithFeedback'; import ScreenWrapper from '@components/ScreenWrapper'; import SelectionList from '@components/SelectionList'; import RadioListItem from '@components/SelectionList/RadioListItem'; @@ -42,14 +42,15 @@ function XeroMapCostCentersToConfigurationPage({policy}: WithPolicyProps) { shouldEnableMaxHeight testID={XeroMapCostCentersToConfigurationPage.displayName} > - + - {translate('workspace.xero.mapXeroCostCentersToDescription')} + + {}} /> - ); diff --git a/src/pages/workspace/accounting/xero/XeroMapRegionsToConfigurationPage.tsx b/src/pages/workspace/accounting/xero/XeroMapRegionsToConfigurationPage.tsx index a9fd95a41060..20032d8538bd 100644 --- a/src/pages/workspace/accounting/xero/XeroMapRegionsToConfigurationPage.tsx +++ b/src/pages/workspace/accounting/xero/XeroMapRegionsToConfigurationPage.tsx @@ -1,8 +1,60 @@ import React from 'react'; +import {View} from 'react-native'; +import Text from '@components/Text'; +import HeaderWithBackButton from '@components/HeaderWithBackButton'; +import ScreenWrapper from '@components/ScreenWrapper'; +import SelectionList from '@components/SelectionList'; +import RadioListItem from '@components/SelectionList/RadioListItem'; +import useLocalize from '@hooks/useLocalize'; +import useThemeStyles from '@hooks/useThemeStyles'; +import AccessOrNotFoundWrapper from '@pages/workspace/AccessOrNotFoundWrapper'; +import type {WithPolicyProps} from '@pages/workspace/withPolicy'; +import withPolicyConnections from '@pages/workspace/withPolicyConnections'; +import CONST from '@src/CONST'; -function XeroMapRegionsToConfigurationPage() { - return <>XeroMapRegionsToPage; +function XeroMapRegionsToConfigurationPage({policy}: WithPolicyProps) { + const {translate} = useLocalize(); + const styles = useThemeStyles(); + const policyID = policy?.id ?? ''; + + const optionsList = [ + { + value: 'DEFAULT', + text: translate(`workspace.xero.xeroContactDefault`), + keyForList: 'DEFAULT', + }, + { + value: 'TAGS', + text: 'Tags', + keyForList: 'TAGS', + isSelected: true, + }, + ]; + + return ( + + + + + {translate('workspace.xero.mapXeroRegionsToDescription')} + + {}} + /> + + + ); } XeroMapRegionsToConfigurationPage.displayName = 'XeroMapRegionsToConfigurationPage'; -export default XeroMapRegionsToConfigurationPage; +export default withPolicyConnections(XeroMapRegionsToConfigurationPage); From 7e4f15cb306027c8a459dbe3670e69359e9f30e0 Mon Sep 17 00:00:00 2001 From: Manan Jadhav Date: Thu, 2 May 2024 00:47:32 +0530 Subject: [PATCH 04/29] refactor: update translations --- src/languages/en.ts | 2 +- src/languages/es.ts | 12 ++++++------ 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/languages/en.ts b/src/languages/en.ts index 6350559dc2f7..ee2cc90026eb 100755 --- a/src/languages/en.ts +++ b/src/languages/en.ts @@ -1997,7 +1997,7 @@ export default { mapXeroCostCentersTo: 'Map Xero cost centers to', mapXeroRegionsTo: 'Map Xero regions to', mapXeroCostCentersToDescription: 'Choose where to map cost centers to when exporting to Xero.', - mapXeroRegionsToDescription: 'Choose where to map employee regions when exporting expense reports to Xero', + mapXeroRegionsToDescription: 'Choose where to map employee regions when exporting expense reports to Xero.', xeroContactDefault: 'Xero contact default', customers: 'Re-bill customers', taxesDescription: 'Choose whether to import tax rates and tax defaults from your accounting integration.', diff --git a/src/languages/es.ts b/src/languages/es.ts index 570038662769..46f1704bbc8b 100644 --- a/src/languages/es.ts +++ b/src/languages/es.ts @@ -2020,12 +2020,12 @@ export default { organizationDescription: 'Seleccione la organización en Xero desde la que está importando los datos.', importDescription: 'Elija qué configuraciones de codificación se importan de Xero a Expensify.', trackingCategories: 'Categorías de seguimiento', - trackingCategoriesDescription: 'Choose whether to import tracking categories and see where they are displayed.', - mapXeroCostCentersTo: 'Map Xero cost centers to', - mapXeroRegionsTo: 'Map Xero regions to', - mapXeroCostCentersToDescription: 'Choose where to map cost centers to when exporting to Xero.', - mapXeroRegionsToDescription: 'Choose where to map employee regions when exporting expense reports to Xero', - xeroContactDefault: 'Xero contact default', + trackingCategoriesDescription: 'Elija si desea importar categorías de seguimiento y vea dónde se muestran.', + mapXeroCostCentersTo: 'Asignar centros de costos de Xero a', + mapXeroRegionsTo: 'Asignar regiones de Xero a', + mapXeroCostCentersToDescription: 'Elija dónde asignar los centros de costos al exportar a Xero.', + mapXeroRegionsToDescription: 'Elija dónde asignar las regiones de los empleados al exportar informes de gastos a Xero.', + xeroContactDefault: 'Contacto predeterminado de Xero', customers: 'Volver a facturar a los clientes', taxesDescription: 'Elige si quires importar las tasas de impuestos y los impuestos por defecto de tu integración de contaduría.', notImported: 'No importado', From d20d27d1d6678f5e8cc45bb74dd51ea3710517c2 Mon Sep 17 00:00:00 2001 From: Manan Jadhav Date: Thu, 2 May 2024 22:45:15 +0530 Subject: [PATCH 05/29] fix: added fields --- src/CONST.ts | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/CONST.ts b/src/CONST.ts index 630dabc404f2..b7ce000b524f 100755 --- a/src/CONST.ts +++ b/src/CONST.ts @@ -1270,6 +1270,10 @@ const CONST = { IMPORT_CUSTOMERS: 'importCustomers', IMPORT_TAX_RATES: 'importTaxRates', IMPORT_TRACK_CATEGORIES: 'importTrackingCategories', + CATEGORY_FIELDS: { + COST_CENTERS: 'cost centers', + REGION: 'region', + } }, QUICKBOOKS_OUT_OF_POCKET_EXPENSE_ACCOUNT_TYPE: { From 9bf90d6286646e08ba6f521213aacf7eef677aa3 Mon Sep 17 00:00:00 2001 From: Manan Jadhav Date: Fri, 3 May 2024 08:30:56 +0530 Subject: [PATCH 06/29] feat: added tracking categories logic --- src/CONST.ts | 3 +- .../ConnectToXeroButton/index.native.tsx | 2 +- src/components/ConnectToXeroButton/index.tsx | 2 +- src/languages/en.ts | 5 ++- src/languages/es.ts | 13 ++++--- src/libs/actions/connections/ConnectToXero.ts | 17 ++++++++- .../XeroTrackingCategoryConfigurationPage.tsx | 35 ++++++++++++++----- src/types/onyx/Policy.ts | 17 ++++++--- 8 files changed, 71 insertions(+), 23 deletions(-) diff --git a/src/CONST.ts b/src/CONST.ts index 827c6f9fce88..cd06c295959c 100755 --- a/src/CONST.ts +++ b/src/CONST.ts @@ -1271,7 +1271,8 @@ const CONST = { IMPORT_CUSTOMERS: 'importCustomers', IMPORT_TAX_RATES: 'importTaxRates', IMPORT_TRACK_CATEGORIES: 'importTrackingCategories', - CATEGORY_FIELDS: { + TRACK_CATEGORY_PREFIX: 'trackingCategory_', + TRACK_CATEGORY_FIELDS: { COST_CENTERS: 'cost centers', REGION: 'region', } diff --git a/src/components/ConnectToXeroButton/index.native.tsx b/src/components/ConnectToXeroButton/index.native.tsx index 36c5af4a0575..f5e819136f00 100644 --- a/src/components/ConnectToXeroButton/index.native.tsx +++ b/src/components/ConnectToXeroButton/index.native.tsx @@ -11,7 +11,7 @@ import Modal from '@components/Modal'; import useLocalize from '@hooks/useLocalize'; import useThemeStyles from '@hooks/useThemeStyles'; import {removePolicyConnection} from '@libs/actions/connections'; -import getXeroSetupLink from '@libs/actions/connections/ConnectToXero'; +import {getXeroSetupLink} from '@libs/actions/connections/ConnectToXero'; import CONST from '@src/CONST'; import ONYXKEYS from '@src/ONYXKEYS'; import type {Session} from '@src/types/onyx'; diff --git a/src/components/ConnectToXeroButton/index.tsx b/src/components/ConnectToXeroButton/index.tsx index 8fad63e1a965..318c3bac4e2a 100644 --- a/src/components/ConnectToXeroButton/index.tsx +++ b/src/components/ConnectToXeroButton/index.tsx @@ -5,7 +5,7 @@ import useEnvironment from '@hooks/useEnvironment'; import useLocalize from '@hooks/useLocalize'; import useThemeStyles from '@hooks/useThemeStyles'; import {removePolicyConnection} from '@libs/actions/connections'; -import getXeroSetupLink from '@libs/actions/connections/ConnectToXero'; +import {getXeroSetupLink} from '@libs/actions/connections/ConnectToXero'; import * as Link from '@userActions/Link'; import CONST from '@src/CONST'; import type {ConnectToXeroButtonProps} from './types'; diff --git a/src/languages/en.ts b/src/languages/en.ts index 27452bcd3e76..87a3bdaf2a50 100755 --- a/src/languages/en.ts +++ b/src/languages/en.ts @@ -2004,11 +2004,14 @@ export default { mapXeroRegionsTo: 'Map Xero regions to', mapXeroCostCentersToDescription: 'Choose where to map cost centers to when exporting to Xero.', mapXeroRegionsToDescription: 'Choose where to map employee regions when exporting expense reports to Xero.', - xeroContactDefault: 'Xero contact default', customers: 'Re-bill customers', customersDescription: 'Import customer contacts. Billable expenses need tags for export. Expenses will carry the customer information to Xero for sales invoices.', taxesDescription: 'Choose whether to import tax rates and tax defaults from your accounting integration.', notImported: 'Not imported', + trackingCategoriesOptions: { + default: 'Xero contact default', + tag: 'Tags' + }, }, type: { free: 'Free', diff --git a/src/languages/es.ts b/src/languages/es.ts index bc3117b6be04..a93af09bfbe1 100644 --- a/src/languages/es.ts +++ b/src/languages/es.ts @@ -2031,17 +2031,20 @@ export default { organizationDescription: 'Seleccione la organización en Xero desde la que está importando los datos.', importDescription: 'Elija qué configuraciones de codificación se importan de Xero a Expensify.', trackingCategories: 'Categorías de seguimiento', - trackingCategoriesDescription: 'Elija si desea importar categorías de seguimiento y vea dónde se muestran.', - mapXeroCostCentersTo: 'Asignar centros de costos de Xero a', + trackingCategoriesDescription: 'Elige si deseas importar categorías de seguimiento y ver dónde se muestran.', + mapXeroCostCentersTo: 'Asignar centros de coste de Xero a', mapXeroRegionsTo: 'Asignar regiones de Xero a', - mapXeroCostCentersToDescription: 'Elija dónde asignar los centros de costos al exportar a Xero.', - mapXeroRegionsToDescription: 'Elija dónde asignar las regiones de los empleados al exportar informes de gastos a Xero.', - xeroContactDefault: 'Contacto predeterminado de Xero', + mapXeroCostCentersToDescription: 'Elige dónde mapear los centros de coste al exportar a Xero.', + mapXeroRegionsToDescription: 'Elige dónde asignar las regiones de los empleados al exportar informes de gastos a Xero.', customers: 'Volver a facturar a los clientes', customersDescription: 'Importar contactos de clientes. Los gastos facturables necesitan etiquetas para la exportación. Los gastos llevarán la información del cliente a Xero para las facturas de ventas.', taxesDescription: 'Elige si quires importar las tasas de impuestos y los impuestos por defecto de tu integración de contaduría.', notImported: 'No importado', + trackingCategoriesOptions: { + default: 'Contacto de Xero por defecto', + tag: 'Etiquetas' + }, }, type: { free: 'Gratis', diff --git a/src/libs/actions/connections/ConnectToXero.ts b/src/libs/actions/connections/ConnectToXero.ts index b5e8d7ab3298..99af19a1b0ab 100644 --- a/src/libs/actions/connections/ConnectToXero.ts +++ b/src/libs/actions/connections/ConnectToXero.ts @@ -1,6 +1,9 @@ import type {ConnectPolicyToAccountingIntegrationParams} from '@libs/API/parameters'; import {READ_COMMANDS} from '@libs/API/types'; import {getCommandURL} from '@libs/ApiUtils'; +import CONST from '@src/CONST'; +import type {OnyxEntry} from 'react-native-onyx'; +import type * as OnyxTypes from '@src/types/onyx'; const getXeroSetupLink = (policyID: string) => { const params: ConnectPolicyToAccountingIntegrationParams = {policyID}; @@ -8,4 +11,16 @@ const getXeroSetupLink = (policyID: string) => { return commandURL + new URLSearchParams(params).toString(); }; -export default getXeroSetupLink; +const getTrackingCategoryValue = (policy: OnyxEntry, key: string): string => { + const { trackingCategories } = policy?.connections?.xero?.data ?? {}; + const { mappings } = policy?.connections?.xero?.config ?? {}; + + const category = trackingCategories?.find((category) => category.name.toLowerCase() === key.toLowerCase()); + if (!category) { + return ""; + } + + return mappings?.[`${CONST.XERO_CONFIG.TRACK_CATEGORY_PREFIX}${category.id}`] ?? ""; +} + +export {getXeroSetupLink, getTrackingCategoryValue}; diff --git a/src/pages/workspace/accounting/xero/XeroTrackingCategoryConfigurationPage.tsx b/src/pages/workspace/accounting/xero/XeroTrackingCategoryConfigurationPage.tsx index 3ee0870c2c60..83df03212d98 100644 --- a/src/pages/workspace/accounting/xero/XeroTrackingCategoryConfigurationPage.tsx +++ b/src/pages/workspace/accounting/xero/XeroTrackingCategoryConfigurationPage.tsx @@ -16,24 +16,40 @@ import withPolicyConnections from '@pages/workspace/withPolicyConnections'; import variables from '@styles/variables'; import CONST from '@src/CONST'; import ROUTES from '@src/ROUTES'; +import { getTrackingCategoryValue } from '@libs/actions/connections/ConnectToXero'; +import { TranslationPaths } from '@src/languages/types'; function XeroTrackingCategoryConfigurationPage({policy}: WithPolicyProps) { const {translate} = useLocalize(); const styles = useThemeStyles(); const policyID = policy?.id ?? ''; const {importTrackingCategories, pendingFields} = policy?.connections?.xero?.config ?? {}; + const { trackingCategories } = policy?.connections?.xero?.data ?? {}; + const menuItems = useMemo( - () => [ - { - title: translate('workspace.xero.mapXeroCostCentersTo'), + () => { + const availableCategories = []; + + const costCenterCategoryValue = getTrackingCategoryValue(policy, CONST.XERO_CONFIG.TRACK_CATEGORY_FIELDS.COST_CENTERS); + const regionCategoryValue = getTrackingCategoryValue(policy, CONST.XERO_CONFIG.TRACK_CATEGORY_FIELDS.COST_CENTERS); + if (costCenterCategoryValue) { + availableCategories.push({ + description: translate('workspace.xero.mapXeroCostCentersTo'), action: () => Navigation.navigate(ROUTES.POLICY_ACCOUNTING_XERO_MAP_COST_CENTERS.getRoute(policyID)), - }, - { - title: translate('workspace.xero.mapXeroRegionsTo'), + title: translate(`workspace.xero.trackingCategoriesOptions.${costCenterCategoryValue.toLowerCase()}` as TranslationPaths) + }); + } + + if (trackingCategories?.find((category) => category.name.toLowerCase() === CONST.XERO_CONFIG.TRACK_CATEGORY_FIELDS.REGION)) { + availableCategories.push({ + description: translate('workspace.xero.mapXeroRegionsTo'), action: () => Navigation.navigate(ROUTES.POLICY_ACCOUNTING_XERO_MAP_REGIONS.getRoute(policyID)), - }, - ], - [translate, policyID], + title: translate(`workspace.xero.trackingCategoriesOptions.${regionCategoryValue.toLowerCase()}` as TranslationPaths) + }); + } + return availableCategories; + }, + [translate, policyID, trackingCategories], ); return ( @@ -78,6 +94,7 @@ function XeroTrackingCategoryConfigurationPage({policy}: WithPolicyProps) { diff --git a/src/types/onyx/Policy.ts b/src/types/onyx/Policy.ts index d64de6196985..3655c233cbef 100644 --- a/src/types/onyx/Policy.ts +++ b/src/types/onyx/Policy.ts @@ -207,6 +207,11 @@ type Tenant = { value: string; }; +type XeroTrackingCategory = { + id: string; + name: string; +} + type XeroConnectionData = { bankAccounts: unknown[]; countryCode: string; @@ -216,7 +221,13 @@ type XeroConnectionData = { name: string; }>; tenants: Tenant[]; - trackingCategories: unknown[]; + trackingCategories: XeroTrackingCategory[]; +}; + +type XeroMappingType = { + customer: string; +} & { + [key in `trackingCategory_${string}`]: string; }; /** @@ -244,9 +255,7 @@ type XeroConnectionConfig = OnyxCommon.OnyxValueWithOfflineFeedback<{ importTaxRates: boolean; importTrackingCategories: boolean; isConfigured: boolean; - mappings: { - customer: string; - }; + mappings: XeroMappingType; sync: { hasChosenAutoSyncOption: boolean; hasChosenSyncReimbursedReportsOption: boolean; From 0872f9cf77363fd0962a1b39850f16fc30ba2edb Mon Sep 17 00:00:00 2001 From: Manan Jadhav Date: Fri, 3 May 2024 09:14:15 +0530 Subject: [PATCH 07/29] feat: create views for cost centers and region --- src/CONST.ts | 4 +++ .../XeroMapCostCentersToConfigurationPage.tsx | 29 +++++++++--------- .../XeroMapRegionsToConfigurationPage.tsx | 30 ++++++++++--------- 3 files changed, 35 insertions(+), 28 deletions(-) diff --git a/src/CONST.ts b/src/CONST.ts index cd06c295959c..66b2ca8d6eb3 100755 --- a/src/CONST.ts +++ b/src/CONST.ts @@ -1275,6 +1275,10 @@ const CONST = { TRACK_CATEGORY_FIELDS: { COST_CENTERS: 'cost centers', REGION: 'region', + }, + TRACK_CATEGORY_OPTIONS: { + DEFAULT: 'DEFAULT', + TAG: 'TAG' } }, diff --git a/src/pages/workspace/accounting/xero/XeroMapCostCentersToConfigurationPage.tsx b/src/pages/workspace/accounting/xero/XeroMapCostCentersToConfigurationPage.tsx index 56557fdd4d13..b6444f3eeb9a 100644 --- a/src/pages/workspace/accounting/xero/XeroMapCostCentersToConfigurationPage.tsx +++ b/src/pages/workspace/accounting/xero/XeroMapCostCentersToConfigurationPage.tsx @@ -1,4 +1,4 @@ -import React from 'react'; +import React, { useMemo } from 'react'; import {View} from 'react-native'; import Text from '@components/Text'; import HeaderWithBackButton from '@components/HeaderWithBackButton'; @@ -10,26 +10,27 @@ import useThemeStyles from '@hooks/useThemeStyles'; import AccessOrNotFoundWrapper from '@pages/workspace/AccessOrNotFoundWrapper'; import type {WithPolicyProps} from '@pages/workspace/withPolicy'; import withPolicyConnections from '@pages/workspace/withPolicyConnections'; +import { getTrackingCategoryValue } from '@libs/actions/connections/ConnectToXero'; import CONST from '@src/CONST'; +import { TranslationPaths } from '@src/languages/types'; function XeroMapCostCentersToConfigurationPage({policy}: WithPolicyProps) { const {translate} = useLocalize(); const styles = useThemeStyles(); const policyID = policy?.id ?? ''; - const optionsList = [ - { - value: 'DEFAULT', - text: translate(`workspace.xero.xeroContactDefault`), - keyForList: 'DEFAULT', - }, - { - value: 'TAGS', - text: 'Tags', - keyForList: 'TAGS', - isSelected: true, - }, - ]; + const optionsList = useMemo(() => { + const costCenterCategoryValue = getTrackingCategoryValue(policy, CONST.XERO_CONFIG.TRACK_CATEGORY_FIELDS.COST_CENTERS); + + return Object.values(CONST.XERO_CONFIG.TRACK_CATEGORY_OPTIONS).map((option) => { + return { + value: option, + text: translate(`workspace.xero.trackingCategoriesOptions.${option.toLowerCase()}` as TranslationPaths), + keyForList: option, + isSelected: option.toLowerCase() === costCenterCategoryValue.toLowerCase() + } + }); + }, [policyID, translate]); return ( { + const costCenterCategoryValue = getTrackingCategoryValue(policy, CONST.XERO_CONFIG.TRACK_CATEGORY_FIELDS.REGION); + + return Object.values(CONST.XERO_CONFIG.TRACK_CATEGORY_OPTIONS).map((option) => { + return { + value: option, + text: translate(`workspace.xero.trackingCategoriesOptions.${option.toLowerCase()}` as TranslationPaths), + keyForList: option, + isSelected: option.toLowerCase() === costCenterCategoryValue.toLowerCase() + } + }); + }, [policyID, translate]); return ( Date: Fri, 3 May 2024 09:30:05 +0530 Subject: [PATCH 08/29] refactor: update category fetching logic --- src/libs/actions/connections/ConnectToXero.ts | 11 +++++++---- .../xero/XeroMapCostCentersToConfigurationPage.tsx | 8 +++++--- .../xero/XeroMapRegionsToConfigurationPage.tsx | 4 ++-- .../xero/XeroTrackingCategoryConfigurationPage.tsx | 6 +++--- 4 files changed, 17 insertions(+), 12 deletions(-) diff --git a/src/libs/actions/connections/ConnectToXero.ts b/src/libs/actions/connections/ConnectToXero.ts index 99af19a1b0ab..11aa904a678a 100644 --- a/src/libs/actions/connections/ConnectToXero.ts +++ b/src/libs/actions/connections/ConnectToXero.ts @@ -11,16 +11,19 @@ const getXeroSetupLink = (policyID: string) => { return commandURL + new URLSearchParams(params).toString(); }; -const getTrackingCategoryValue = (policy: OnyxEntry, key: string): string => { +const getTrackingCategory = (policy: OnyxEntry, key: string) => { const { trackingCategories } = policy?.connections?.xero?.data ?? {}; const { mappings } = policy?.connections?.xero?.config ?? {}; const category = trackingCategories?.find((category) => category.name.toLowerCase() === key.toLowerCase()); if (!category) { - return ""; + return undefined; } - return mappings?.[`${CONST.XERO_CONFIG.TRACK_CATEGORY_PREFIX}${category.id}`] ?? ""; + return { + ...category, + value: mappings?.[`${CONST.XERO_CONFIG.TRACK_CATEGORY_PREFIX}${category.id}`] ?? "" + }; } -export {getXeroSetupLink, getTrackingCategoryValue}; +export {getXeroSetupLink, getTrackingCategory}; diff --git a/src/pages/workspace/accounting/xero/XeroMapCostCentersToConfigurationPage.tsx b/src/pages/workspace/accounting/xero/XeroMapCostCentersToConfigurationPage.tsx index b6444f3eeb9a..a7720e5c8ef5 100644 --- a/src/pages/workspace/accounting/xero/XeroMapCostCentersToConfigurationPage.tsx +++ b/src/pages/workspace/accounting/xero/XeroMapCostCentersToConfigurationPage.tsx @@ -10,7 +10,7 @@ import useThemeStyles from '@hooks/useThemeStyles'; import AccessOrNotFoundWrapper from '@pages/workspace/AccessOrNotFoundWrapper'; import type {WithPolicyProps} from '@pages/workspace/withPolicy'; import withPolicyConnections from '@pages/workspace/withPolicyConnections'; -import { getTrackingCategoryValue } from '@libs/actions/connections/ConnectToXero'; +import { getTrackingCategory } from '@libs/actions/connections/ConnectToXero'; import CONST from '@src/CONST'; import { TranslationPaths } from '@src/languages/types'; @@ -19,15 +19,17 @@ function XeroMapCostCentersToConfigurationPage({policy}: WithPolicyProps) { const styles = useThemeStyles(); const policyID = policy?.id ?? ''; + const costCenterCategory = getTrackingCategory(policy, CONST.XERO_CONFIG.TRACK_CATEGORY_FIELDS.COST_CENTERS); + const optionsList = useMemo(() => { - const costCenterCategoryValue = getTrackingCategoryValue(policy, CONST.XERO_CONFIG.TRACK_CATEGORY_FIELDS.COST_CENTERS); + return Object.values(CONST.XERO_CONFIG.TRACK_CATEGORY_OPTIONS).map((option) => { return { value: option, text: translate(`workspace.xero.trackingCategoriesOptions.${option.toLowerCase()}` as TranslationPaths), keyForList: option, - isSelected: option.toLowerCase() === costCenterCategoryValue.toLowerCase() + isSelected: option.toLowerCase() === costCenterCategory?.value?.toLowerCase() } }); }, [policyID, translate]); diff --git a/src/pages/workspace/accounting/xero/XeroMapRegionsToConfigurationPage.tsx b/src/pages/workspace/accounting/xero/XeroMapRegionsToConfigurationPage.tsx index 5ccde7150d22..24d04be14804 100644 --- a/src/pages/workspace/accounting/xero/XeroMapRegionsToConfigurationPage.tsx +++ b/src/pages/workspace/accounting/xero/XeroMapRegionsToConfigurationPage.tsx @@ -11,7 +11,7 @@ import AccessOrNotFoundWrapper from '@pages/workspace/AccessOrNotFoundWrapper'; import type {WithPolicyProps} from '@pages/workspace/withPolicy'; import withPolicyConnections from '@pages/workspace/withPolicyConnections'; import CONST from '@src/CONST'; -import { getTrackingCategoryValue } from '@libs/actions/connections/ConnectToXero'; +import { getTrackingCategory } from '@libs/actions/connections/ConnectToXero'; import { TranslationPaths } from '@src/languages/types'; @@ -21,7 +21,7 @@ function XeroMapRegionsToConfigurationPage({policy}: WithPolicyProps) { const policyID = policy?.id ?? ''; const optionsList = useMemo(() => { - const costCenterCategoryValue = getTrackingCategoryValue(policy, CONST.XERO_CONFIG.TRACK_CATEGORY_FIELDS.REGION); + const costCenterCategoryValue = getTrackingCategory(policy, CONST.XERO_CONFIG.TRACK_CATEGORY_FIELDS.REGION)?.value ?? ""; return Object.values(CONST.XERO_CONFIG.TRACK_CATEGORY_OPTIONS).map((option) => { return { diff --git a/src/pages/workspace/accounting/xero/XeroTrackingCategoryConfigurationPage.tsx b/src/pages/workspace/accounting/xero/XeroTrackingCategoryConfigurationPage.tsx index 83df03212d98..55a2e2b5538c 100644 --- a/src/pages/workspace/accounting/xero/XeroTrackingCategoryConfigurationPage.tsx +++ b/src/pages/workspace/accounting/xero/XeroTrackingCategoryConfigurationPage.tsx @@ -16,7 +16,7 @@ import withPolicyConnections from '@pages/workspace/withPolicyConnections'; import variables from '@styles/variables'; import CONST from '@src/CONST'; import ROUTES from '@src/ROUTES'; -import { getTrackingCategoryValue } from '@libs/actions/connections/ConnectToXero'; +import { getTrackingCategory } from '@libs/actions/connections/ConnectToXero'; import { TranslationPaths } from '@src/languages/types'; function XeroTrackingCategoryConfigurationPage({policy}: WithPolicyProps) { @@ -30,8 +30,8 @@ function XeroTrackingCategoryConfigurationPage({policy}: WithPolicyProps) { () => { const availableCategories = []; - const costCenterCategoryValue = getTrackingCategoryValue(policy, CONST.XERO_CONFIG.TRACK_CATEGORY_FIELDS.COST_CENTERS); - const regionCategoryValue = getTrackingCategoryValue(policy, CONST.XERO_CONFIG.TRACK_CATEGORY_FIELDS.COST_CENTERS); + const costCenterCategoryValue = getTrackingCategory(policy, CONST.XERO_CONFIG.TRACK_CATEGORY_FIELDS.COST_CENTERS)?.value ?? ""; + const regionCategoryValue = getTrackingCategory(policy, CONST.XERO_CONFIG.TRACK_CATEGORY_FIELDS.REGION)?.value ?? ""; if (costCenterCategoryValue) { availableCategories.push({ description: translate('workspace.xero.mapXeroCostCentersTo'), From f1e8dbc515f1723588733312ec8fbdeff65aac4f Mon Sep 17 00:00:00 2001 From: Manan Jadhav Date: Fri, 3 May 2024 10:18:29 +0530 Subject: [PATCH 09/29] feat: update mapping --- .../XeroMapCostCentersToConfigurationPage.tsx | 17 +++++++++++++---- .../XeroTrackingCategoryConfigurationPage.tsx | 15 ++++++++------- 2 files changed, 21 insertions(+), 11 deletions(-) diff --git a/src/pages/workspace/accounting/xero/XeroMapCostCentersToConfigurationPage.tsx b/src/pages/workspace/accounting/xero/XeroMapCostCentersToConfigurationPage.tsx index a7720e5c8ef5..4bb9af400440 100644 --- a/src/pages/workspace/accounting/xero/XeroMapCostCentersToConfigurationPage.tsx +++ b/src/pages/workspace/accounting/xero/XeroMapCostCentersToConfigurationPage.tsx @@ -7,19 +7,21 @@ import SelectionList from '@components/SelectionList'; import RadioListItem from '@components/SelectionList/RadioListItem'; import useLocalize from '@hooks/useLocalize'; import useThemeStyles from '@hooks/useThemeStyles'; +import * as Connections from '@libs/actions/connections'; import AccessOrNotFoundWrapper from '@pages/workspace/AccessOrNotFoundWrapper'; import type {WithPolicyProps} from '@pages/workspace/withPolicy'; import withPolicyConnections from '@pages/workspace/withPolicyConnections'; import { getTrackingCategory } from '@libs/actions/connections/ConnectToXero'; import CONST from '@src/CONST'; import { TranslationPaths } from '@src/languages/types'; +import Navigation from '@libs/Navigation/Navigation'; function XeroMapCostCentersToConfigurationPage({policy}: WithPolicyProps) { const {translate} = useLocalize(); const styles = useThemeStyles(); const policyID = policy?.id ?? ''; - const costCenterCategory = getTrackingCategory(policy, CONST.XERO_CONFIG.TRACK_CATEGORY_FIELDS.COST_CENTERS); + const category = getTrackingCategory(policy, CONST.XERO_CONFIG.TRACK_CATEGORY_FIELDS.COST_CENTERS); const optionsList = useMemo(() => { @@ -29,15 +31,16 @@ function XeroMapCostCentersToConfigurationPage({policy}: WithPolicyProps) { value: option, text: translate(`workspace.xero.trackingCategoriesOptions.${option.toLowerCase()}` as TranslationPaths), keyForList: option, - isSelected: option.toLowerCase() === costCenterCategory?.value?.toLowerCase() + isSelected: option.toLowerCase() === category?.value?.toLowerCase() } }); }, [policyID, translate]); + return ( {}} + onSelectRow={(row) => { + Connections.updatePolicyConnectionConfig(policyID, CONST.POLICY.CONNECTIONS.NAME.XERO, CONST.XERO_CONFIG.MAPPINGS, { + ...(policy?.connections?.xero?.config?.mappings ?? {}), + ...(category?.id ? {[`${CONST.XERO_CONFIG.TRACK_CATEGORY_PREFIX}${category.id}`]: row.value}: {}) + }) + Navigation.goBack(); + }} /> diff --git a/src/pages/workspace/accounting/xero/XeroTrackingCategoryConfigurationPage.tsx b/src/pages/workspace/accounting/xero/XeroTrackingCategoryConfigurationPage.tsx index 55a2e2b5538c..e68e6d94a266 100644 --- a/src/pages/workspace/accounting/xero/XeroTrackingCategoryConfigurationPage.tsx +++ b/src/pages/workspace/accounting/xero/XeroTrackingCategoryConfigurationPage.tsx @@ -18,6 +18,7 @@ import CONST from '@src/CONST'; import ROUTES from '@src/ROUTES'; import { getTrackingCategory } from '@libs/actions/connections/ConnectToXero'; import { TranslationPaths } from '@src/languages/types'; +import { MenuItemProps } from '@components/MenuItem'; function XeroTrackingCategoryConfigurationPage({policy}: WithPolicyProps) { const {translate} = useLocalize(); @@ -26,7 +27,7 @@ function XeroTrackingCategoryConfigurationPage({policy}: WithPolicyProps) { const {importTrackingCategories, pendingFields} = policy?.connections?.xero?.config ?? {}; const { trackingCategories } = policy?.connections?.xero?.data ?? {}; - const menuItems = useMemo( + const menuItems: MenuItemProps[] = useMemo( () => { const availableCategories = []; @@ -35,7 +36,7 @@ function XeroTrackingCategoryConfigurationPage({policy}: WithPolicyProps) { if (costCenterCategoryValue) { availableCategories.push({ description: translate('workspace.xero.mapXeroCostCentersTo'), - action: () => Navigation.navigate(ROUTES.POLICY_ACCOUNTING_XERO_MAP_COST_CENTERS.getRoute(policyID)), + onPress: () => Navigation.navigate(ROUTES.POLICY_ACCOUNTING_XERO_MAP_COST_CENTERS.getRoute(policyID)), title: translate(`workspace.xero.trackingCategoriesOptions.${costCenterCategoryValue.toLowerCase()}` as TranslationPaths) }); } @@ -43,13 +44,13 @@ function XeroTrackingCategoryConfigurationPage({policy}: WithPolicyProps) { if (trackingCategories?.find((category) => category.name.toLowerCase() === CONST.XERO_CONFIG.TRACK_CATEGORY_FIELDS.REGION)) { availableCategories.push({ description: translate('workspace.xero.mapXeroRegionsTo'), - action: () => Navigation.navigate(ROUTES.POLICY_ACCOUNTING_XERO_MAP_REGIONS.getRoute(policyID)), + onPress: () => Navigation.navigate(ROUTES.POLICY_ACCOUNTING_XERO_MAP_REGIONS.getRoute(policyID)), title: translate(`workspace.xero.trackingCategoriesOptions.${regionCategoryValue.toLowerCase()}` as TranslationPaths) }); } return availableCategories; }, - [translate, policyID, trackingCategories], + [translate, policy, policyID, trackingCategories], ); return ( @@ -90,13 +91,13 @@ function XeroTrackingCategoryConfigurationPage({policy}: WithPolicyProps) { {importTrackingCategories && ( - {menuItems.map((menuItem) => ( + {menuItems.map((menuItem: MenuItemProps) => ( ))} From b24e8757e31e0b7779d6c8ad08abe5585f63d2ee Mon Sep 17 00:00:00 2001 From: Manan Jadhav Date: Fri, 3 May 2024 11:00:06 +0530 Subject: [PATCH 10/29] feat: added api for regions --- src/CONST.ts | 1 + .../XeroMapCostCentersToConfigurationPage.tsx | 7 ++++--- .../xero/XeroMapRegionsToConfigurationPage.tsx | 18 +++++++++++++----- 3 files changed, 18 insertions(+), 8 deletions(-) diff --git a/src/CONST.ts b/src/CONST.ts index 66b2ca8d6eb3..2522632df677 100755 --- a/src/CONST.ts +++ b/src/CONST.ts @@ -1271,6 +1271,7 @@ const CONST = { IMPORT_CUSTOMERS: 'importCustomers', IMPORT_TAX_RATES: 'importTaxRates', IMPORT_TRACK_CATEGORIES: 'importTrackingCategories', + MAPPINGS: 'mappings', TRACK_CATEGORY_PREFIX: 'trackingCategory_', TRACK_CATEGORY_FIELDS: { COST_CENTERS: 'cost centers', diff --git a/src/pages/workspace/accounting/xero/XeroMapCostCentersToConfigurationPage.tsx b/src/pages/workspace/accounting/xero/XeroMapCostCentersToConfigurationPage.tsx index 4bb9af400440..56f5410c2ac5 100644 --- a/src/pages/workspace/accounting/xero/XeroMapCostCentersToConfigurationPage.tsx +++ b/src/pages/workspace/accounting/xero/XeroMapCostCentersToConfigurationPage.tsx @@ -15,6 +15,7 @@ import { getTrackingCategory } from '@libs/actions/connections/ConnectToXero'; import CONST from '@src/CONST'; import { TranslationPaths } from '@src/languages/types'; import Navigation from '@libs/Navigation/Navigation'; +import ROUTES from '@src/ROUTES'; function XeroMapCostCentersToConfigurationPage({policy}: WithPolicyProps) { const {translate} = useLocalize(); @@ -55,12 +56,12 @@ function XeroMapCostCentersToConfigurationPage({policy}: WithPolicyProps) { { + onSelectRow={(option) => { Connections.updatePolicyConnectionConfig(policyID, CONST.POLICY.CONNECTIONS.NAME.XERO, CONST.XERO_CONFIG.MAPPINGS, { ...(policy?.connections?.xero?.config?.mappings ?? {}), - ...(category?.id ? {[`${CONST.XERO_CONFIG.TRACK_CATEGORY_PREFIX}${category.id}`]: row.value}: {}) + ...(category?.id ? {[`${CONST.XERO_CONFIG.TRACK_CATEGORY_PREFIX}${category.id}`]: option.value}: {}) }) - Navigation.goBack(); + Navigation.goBack(ROUTES.POLICY_ACCOUNTING_XERO_TRACK_CATEGORIES.getRoute(policyID)); }} /> diff --git a/src/pages/workspace/accounting/xero/XeroMapRegionsToConfigurationPage.tsx b/src/pages/workspace/accounting/xero/XeroMapRegionsToConfigurationPage.tsx index 24d04be14804..c20aaaa24c07 100644 --- a/src/pages/workspace/accounting/xero/XeroMapRegionsToConfigurationPage.tsx +++ b/src/pages/workspace/accounting/xero/XeroMapRegionsToConfigurationPage.tsx @@ -7,28 +7,30 @@ import SelectionList from '@components/SelectionList'; import RadioListItem from '@components/SelectionList/RadioListItem'; import useLocalize from '@hooks/useLocalize'; import useThemeStyles from '@hooks/useThemeStyles'; +import * as Connections from '@libs/actions/connections'; import AccessOrNotFoundWrapper from '@pages/workspace/AccessOrNotFoundWrapper'; import type {WithPolicyProps} from '@pages/workspace/withPolicy'; import withPolicyConnections from '@pages/workspace/withPolicyConnections'; import CONST from '@src/CONST'; import { getTrackingCategory } from '@libs/actions/connections/ConnectToXero'; import { TranslationPaths } from '@src/languages/types'; +import Navigation from '@libs/Navigation/Navigation'; +import ROUTES from '@src/ROUTES'; function XeroMapRegionsToConfigurationPage({policy}: WithPolicyProps) { const {translate} = useLocalize(); const styles = useThemeStyles(); const policyID = policy?.id ?? ''; + const category = getTrackingCategory(policy, CONST.XERO_CONFIG.TRACK_CATEGORY_FIELDS.REGION); const optionsList = useMemo(() => { - const costCenterCategoryValue = getTrackingCategory(policy, CONST.XERO_CONFIG.TRACK_CATEGORY_FIELDS.REGION)?.value ?? ""; - return Object.values(CONST.XERO_CONFIG.TRACK_CATEGORY_OPTIONS).map((option) => { return { value: option, text: translate(`workspace.xero.trackingCategoriesOptions.${option.toLowerCase()}` as TranslationPaths), keyForList: option, - isSelected: option.toLowerCase() === costCenterCategoryValue.toLowerCase() + isSelected: option.toLowerCase() === category?.value?.toLowerCase() } }); }, [policyID, translate]); @@ -36,7 +38,7 @@ function XeroMapRegionsToConfigurationPage({policy}: WithPolicyProps) { return ( {}} + onSelectRow={(option) => { + Connections.updatePolicyConnectionConfig(policyID, CONST.POLICY.CONNECTIONS.NAME.XERO, CONST.XERO_CONFIG.MAPPINGS, { + ...(policy?.connections?.xero?.config?.mappings ?? {}), + ...(category?.id ? {[`${CONST.XERO_CONFIG.TRACK_CATEGORY_PREFIX}${category.id}`]: option.value}: {}) + }) + Navigation.goBack(ROUTES.POLICY_ACCOUNTING_XERO_TRACK_CATEGORIES.getRoute(policyID)); + }} /> From 5c7ef82d85d789727cae211f93eb6f1b21031519 Mon Sep 17 00:00:00 2001 From: Manan Jadhav Date: Fri, 3 May 2024 11:15:29 +0530 Subject: [PATCH 11/29] style: lint fixes --- src/libs/actions/connections/ConnectToXero.ts | 2 +- .../XeroMapCostCentersToConfigurationPage.tsx | 20 ++++++++----------- .../XeroMapRegionsToConfigurationPage.tsx | 9 ++++----- 3 files changed, 13 insertions(+), 18 deletions(-) diff --git a/src/libs/actions/connections/ConnectToXero.ts b/src/libs/actions/connections/ConnectToXero.ts index 11aa904a678a..51652c97bc49 100644 --- a/src/libs/actions/connections/ConnectToXero.ts +++ b/src/libs/actions/connections/ConnectToXero.ts @@ -15,7 +15,7 @@ const getTrackingCategory = (policy: OnyxEntry, key: string) = const { trackingCategories } = policy?.connections?.xero?.data ?? {}; const { mappings } = policy?.connections?.xero?.config ?? {}; - const category = trackingCategories?.find((category) => category.name.toLowerCase() === key.toLowerCase()); + const category = trackingCategories?.find((currentCategory) => currentCategory.name.toLowerCase() === key.toLowerCase()); if (!category) { return undefined; } diff --git a/src/pages/workspace/accounting/xero/XeroMapCostCentersToConfigurationPage.tsx b/src/pages/workspace/accounting/xero/XeroMapCostCentersToConfigurationPage.tsx index 56f5410c2ac5..a70b5f2eb59a 100644 --- a/src/pages/workspace/accounting/xero/XeroMapCostCentersToConfigurationPage.tsx +++ b/src/pages/workspace/accounting/xero/XeroMapCostCentersToConfigurationPage.tsx @@ -24,18 +24,14 @@ function XeroMapCostCentersToConfigurationPage({policy}: WithPolicyProps) { const category = getTrackingCategory(policy, CONST.XERO_CONFIG.TRACK_CATEGORY_FIELDS.COST_CENTERS); - const optionsList = useMemo(() => { - - - return Object.values(CONST.XERO_CONFIG.TRACK_CATEGORY_OPTIONS).map((option) => { - return { - value: option, - text: translate(`workspace.xero.trackingCategoriesOptions.${option.toLowerCase()}` as TranslationPaths), - keyForList: option, - isSelected: option.toLowerCase() === category?.value?.toLowerCase() - } - }); - }, [policyID, translate]); + const optionsList = useMemo(() => ( + Object.values(CONST.XERO_CONFIG.TRACK_CATEGORY_OPTIONS).map((option) => ({ + value: option, + text: translate(`workspace.xero.trackingCategoriesOptions.${option.toLowerCase()}` as TranslationPaths), + keyForList: option, + isSelected: option.toLowerCase() === category?.value?.toLowerCase() + })) + ), [policyID, translate, category]); return ( diff --git a/src/pages/workspace/accounting/xero/XeroMapRegionsToConfigurationPage.tsx b/src/pages/workspace/accounting/xero/XeroMapRegionsToConfigurationPage.tsx index c20aaaa24c07..21b702909485 100644 --- a/src/pages/workspace/accounting/xero/XeroMapRegionsToConfigurationPage.tsx +++ b/src/pages/workspace/accounting/xero/XeroMapRegionsToConfigurationPage.tsx @@ -24,16 +24,15 @@ function XeroMapRegionsToConfigurationPage({policy}: WithPolicyProps) { const policyID = policy?.id ?? ''; const category = getTrackingCategory(policy, CONST.XERO_CONFIG.TRACK_CATEGORY_FIELDS.REGION); - const optionsList = useMemo(() => { - return Object.values(CONST.XERO_CONFIG.TRACK_CATEGORY_OPTIONS).map((option) => { - return { + const optionsList = useMemo(() => ( + Object.values(CONST.XERO_CONFIG.TRACK_CATEGORY_OPTIONS).map((option) => ( + { value: option, text: translate(`workspace.xero.trackingCategoriesOptions.${option.toLowerCase()}` as TranslationPaths), keyForList: option, isSelected: option.toLowerCase() === category?.value?.toLowerCase() } - }); - }, [policyID, translate]); + ))), [policyID, translate, category]); return ( Date: Fri, 3 May 2024 11:46:55 +0530 Subject: [PATCH 12/29] style: lint fixes --- .../accounting/xero/XeroMapCostCentersToConfigurationPage.tsx | 4 ++-- .../accounting/xero/XeroMapRegionsToConfigurationPage.tsx | 4 ++-- .../accounting/xero/XeroTrackingCategoryConfigurationPage.tsx | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/pages/workspace/accounting/xero/XeroMapCostCentersToConfigurationPage.tsx b/src/pages/workspace/accounting/xero/XeroMapCostCentersToConfigurationPage.tsx index a70b5f2eb59a..dd67501e0d7f 100644 --- a/src/pages/workspace/accounting/xero/XeroMapCostCentersToConfigurationPage.tsx +++ b/src/pages/workspace/accounting/xero/XeroMapCostCentersToConfigurationPage.tsx @@ -13,7 +13,7 @@ import type {WithPolicyProps} from '@pages/workspace/withPolicy'; import withPolicyConnections from '@pages/workspace/withPolicyConnections'; import { getTrackingCategory } from '@libs/actions/connections/ConnectToXero'; import CONST from '@src/CONST'; -import { TranslationPaths } from '@src/languages/types'; +import type { TranslationPaths } from '@src/languages/types'; import Navigation from '@libs/Navigation/Navigation'; import ROUTES from '@src/ROUTES'; @@ -31,7 +31,7 @@ function XeroMapCostCentersToConfigurationPage({policy}: WithPolicyProps) { keyForList: option, isSelected: option.toLowerCase() === category?.value?.toLowerCase() })) - ), [policyID, translate, category]); + ), [translate, category]); return ( diff --git a/src/pages/workspace/accounting/xero/XeroMapRegionsToConfigurationPage.tsx b/src/pages/workspace/accounting/xero/XeroMapRegionsToConfigurationPage.tsx index 21b702909485..4e7f1c1933db 100644 --- a/src/pages/workspace/accounting/xero/XeroMapRegionsToConfigurationPage.tsx +++ b/src/pages/workspace/accounting/xero/XeroMapRegionsToConfigurationPage.tsx @@ -13,7 +13,7 @@ import type {WithPolicyProps} from '@pages/workspace/withPolicy'; import withPolicyConnections from '@pages/workspace/withPolicyConnections'; import CONST from '@src/CONST'; import { getTrackingCategory } from '@libs/actions/connections/ConnectToXero'; -import { TranslationPaths } from '@src/languages/types'; +import type { TranslationPaths } from '@src/languages/types'; import Navigation from '@libs/Navigation/Navigation'; import ROUTES from '@src/ROUTES'; @@ -32,7 +32,7 @@ function XeroMapRegionsToConfigurationPage({policy}: WithPolicyProps) { keyForList: option, isSelected: option.toLowerCase() === category?.value?.toLowerCase() } - ))), [policyID, translate, category]); + ))), [translate, category]); return ( Date: Fri, 3 May 2024 11:52:55 +0530 Subject: [PATCH 13/29] refactor: use connection layout --- .../XeroMapCostCentersToConfigurationPage.tsx | 23 +++++-------------- .../XeroMapRegionsToConfigurationPage.tsx | 23 +++++-------------- 2 files changed, 12 insertions(+), 34 deletions(-) diff --git a/src/pages/workspace/accounting/xero/XeroMapCostCentersToConfigurationPage.tsx b/src/pages/workspace/accounting/xero/XeroMapCostCentersToConfigurationPage.tsx index dd67501e0d7f..b61207fefb20 100644 --- a/src/pages/workspace/accounting/xero/XeroMapCostCentersToConfigurationPage.tsx +++ b/src/pages/workspace/accounting/xero/XeroMapCostCentersToConfigurationPage.tsx @@ -1,14 +1,10 @@ import React, { useMemo } from 'react'; -import {View} from 'react-native'; -import Text from '@components/Text'; -import HeaderWithBackButton from '@components/HeaderWithBackButton'; -import ScreenWrapper from '@components/ScreenWrapper'; +import ConnectionLayout from '@components/ConnectionLayout'; import SelectionList from '@components/SelectionList'; import RadioListItem from '@components/SelectionList/RadioListItem'; import useLocalize from '@hooks/useLocalize'; import useThemeStyles from '@hooks/useThemeStyles'; import * as Connections from '@libs/actions/connections'; -import AccessOrNotFoundWrapper from '@pages/workspace/AccessOrNotFoundWrapper'; import type {WithPolicyProps} from '@pages/workspace/withPolicy'; import withPolicyConnections from '@pages/workspace/withPolicyConnections'; import { getTrackingCategory } from '@libs/actions/connections/ConnectToXero'; @@ -35,20 +31,14 @@ function XeroMapCostCentersToConfigurationPage({policy}: WithPolicyProps) { return ( - - - - - {translate('workspace.xero.mapXeroCostCentersToDescription')} - - - + ); } diff --git a/src/pages/workspace/accounting/xero/XeroMapRegionsToConfigurationPage.tsx b/src/pages/workspace/accounting/xero/XeroMapRegionsToConfigurationPage.tsx index 4e7f1c1933db..26026300cf46 100644 --- a/src/pages/workspace/accounting/xero/XeroMapRegionsToConfigurationPage.tsx +++ b/src/pages/workspace/accounting/xero/XeroMapRegionsToConfigurationPage.tsx @@ -1,14 +1,10 @@ import React, { useMemo } from 'react'; -import {View} from 'react-native'; -import Text from '@components/Text'; -import HeaderWithBackButton from '@components/HeaderWithBackButton'; -import ScreenWrapper from '@components/ScreenWrapper'; +import ConnectionLayout from '@components/ConnectionLayout'; import SelectionList from '@components/SelectionList'; import RadioListItem from '@components/SelectionList/RadioListItem'; import useLocalize from '@hooks/useLocalize'; import useThemeStyles from '@hooks/useThemeStyles'; import * as Connections from '@libs/actions/connections'; -import AccessOrNotFoundWrapper from '@pages/workspace/AccessOrNotFoundWrapper'; import type {WithPolicyProps} from '@pages/workspace/withPolicy'; import withPolicyConnections from '@pages/workspace/withPolicyConnections'; import CONST from '@src/CONST'; @@ -35,20 +31,14 @@ function XeroMapRegionsToConfigurationPage({policy}: WithPolicyProps) { ))), [translate, category]); return ( - - - - - {translate('workspace.xero.mapXeroRegionsToDescription')} - - - + ); } From 01eda9e6cc64a66b3e7da996255c15072046859c Mon Sep 17 00:00:00 2001 From: Manan Jadhav Date: Fri, 3 May 2024 12:00:34 +0530 Subject: [PATCH 14/29] refactor: use connection layout --- .../XeroTrackingCategoryConfigurationPage.tsx | 26 +++++++------------ 1 file changed, 10 insertions(+), 16 deletions(-) diff --git a/src/pages/workspace/accounting/xero/XeroTrackingCategoryConfigurationPage.tsx b/src/pages/workspace/accounting/xero/XeroTrackingCategoryConfigurationPage.tsx index 23f0d0163522..eb392a9d225f 100644 --- a/src/pages/workspace/accounting/xero/XeroTrackingCategoryConfigurationPage.tsx +++ b/src/pages/workspace/accounting/xero/XeroTrackingCategoryConfigurationPage.tsx @@ -1,16 +1,13 @@ import React, {useMemo} from 'react'; import {View} from 'react-native'; -import HeaderWithBackButton from '@components/HeaderWithBackButton'; import MenuItemWithTopDescription from '@components/MenuItemWithTopDescription'; import OfflineWithFeedback from '@components/OfflineWithFeedback'; -import ScreenWrapper from '@components/ScreenWrapper'; import Switch from '@components/Switch'; import Text from '@components/Text'; import useLocalize from '@hooks/useLocalize'; import useThemeStyles from '@hooks/useThemeStyles'; import * as Connections from '@libs/actions/connections'; import Navigation from '@libs/Navigation/Navigation'; -import AccessOrNotFoundWrapper from '@pages/workspace/AccessOrNotFoundWrapper'; import type {WithPolicyProps} from '@pages/workspace/withPolicy'; import withPolicyConnections from '@pages/workspace/withPolicyConnections'; import variables from '@styles/variables'; @@ -19,6 +16,7 @@ import ROUTES from '@src/ROUTES'; import { getTrackingCategory } from '@libs/actions/connections/ConnectToXero'; import type { TranslationPaths } from '@src/languages/types'; import type { MenuItemProps } from '@components/MenuItem'; +import ConnectionLayout from '@components/ConnectionLayout'; function XeroTrackingCategoryConfigurationPage({policy}: WithPolicyProps) { const {translate} = useLocalize(); @@ -54,20 +52,16 @@ function XeroTrackingCategoryConfigurationPage({policy}: WithPolicyProps) { ); return ( - - - - - {translate('workspace.xero.trackingCategoriesDescription')} - + + {translate('workspace.accounting.import')} @@ -98,12 +92,12 @@ function XeroTrackingCategoryConfigurationPage({policy}: WithPolicyProps) { description={menuItem.description} shouldShowRightIcon onPress={menuItem.onPress} + wrapperStyle={styles.sectionMenuItemTopDescription} /> ))} - )} - - + )} + ); } From b012ed6968e4a00d3b97109e39d7959d8a8d5ba2 Mon Sep 17 00:00:00 2001 From: Manan Jadhav Date: Fri, 3 May 2024 20:43:21 +0530 Subject: [PATCH 15/29] refactor: remove unused importants --- .../accounting/xero/XeroMapCostCentersToConfigurationPage.tsx | 2 -- .../accounting/xero/XeroMapRegionsToConfigurationPage.tsx | 2 -- 2 files changed, 4 deletions(-) diff --git a/src/pages/workspace/accounting/xero/XeroMapCostCentersToConfigurationPage.tsx b/src/pages/workspace/accounting/xero/XeroMapCostCentersToConfigurationPage.tsx index b61207fefb20..6739940b8802 100644 --- a/src/pages/workspace/accounting/xero/XeroMapCostCentersToConfigurationPage.tsx +++ b/src/pages/workspace/accounting/xero/XeroMapCostCentersToConfigurationPage.tsx @@ -3,7 +3,6 @@ import ConnectionLayout from '@components/ConnectionLayout'; import SelectionList from '@components/SelectionList'; import RadioListItem from '@components/SelectionList/RadioListItem'; import useLocalize from '@hooks/useLocalize'; -import useThemeStyles from '@hooks/useThemeStyles'; import * as Connections from '@libs/actions/connections'; import type {WithPolicyProps} from '@pages/workspace/withPolicy'; import withPolicyConnections from '@pages/workspace/withPolicyConnections'; @@ -15,7 +14,6 @@ import ROUTES from '@src/ROUTES'; function XeroMapCostCentersToConfigurationPage({policy}: WithPolicyProps) { const {translate} = useLocalize(); - const styles = useThemeStyles(); const policyID = policy?.id ?? ''; const category = getTrackingCategory(policy, CONST.XERO_CONFIG.TRACK_CATEGORY_FIELDS.COST_CENTERS); diff --git a/src/pages/workspace/accounting/xero/XeroMapRegionsToConfigurationPage.tsx b/src/pages/workspace/accounting/xero/XeroMapRegionsToConfigurationPage.tsx index 26026300cf46..53e12e57cb41 100644 --- a/src/pages/workspace/accounting/xero/XeroMapRegionsToConfigurationPage.tsx +++ b/src/pages/workspace/accounting/xero/XeroMapRegionsToConfigurationPage.tsx @@ -3,7 +3,6 @@ import ConnectionLayout from '@components/ConnectionLayout'; import SelectionList from '@components/SelectionList'; import RadioListItem from '@components/SelectionList/RadioListItem'; import useLocalize from '@hooks/useLocalize'; -import useThemeStyles from '@hooks/useThemeStyles'; import * as Connections from '@libs/actions/connections'; import type {WithPolicyProps} from '@pages/workspace/withPolicy'; import withPolicyConnections from '@pages/workspace/withPolicyConnections'; @@ -16,7 +15,6 @@ import ROUTES from '@src/ROUTES'; function XeroMapRegionsToConfigurationPage({policy}: WithPolicyProps) { const {translate} = useLocalize(); - const styles = useThemeStyles(); const policyID = policy?.id ?? ''; const category = getTrackingCategory(policy, CONST.XERO_CONFIG.TRACK_CATEGORY_FIELDS.REGION); From aed9941214642f3080f04712931efd06389dba3e Mon Sep 17 00:00:00 2001 From: Manan Jadhav Date: Sun, 5 May 2024 00:01:01 +0530 Subject: [PATCH 16/29] fix: update routes --- src/ROUTES.ts | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/ROUTES.ts b/src/ROUTES.ts index f9c47857ba1d..0a4459c23acb 100644 --- a/src/ROUTES.ts +++ b/src/ROUTES.ts @@ -781,16 +781,16 @@ const ROUTES = { getRoute: (policyID: string, currentOrganizationID: string) => `settings/workspaces/${policyID}/accounting/xero/organization/${currentOrganizationID}` as const, }, POLICY_ACCOUNTING_XERO_TRACK_CATEGORIES: { - route: 'settings/workspaces/:policyID/accounting/xero/import/trackCategories', - getRoute: (policyID: string) => `settings/workspaces/${policyID}/accounting/xero/import/trackCategories` as const, + route: 'settings/workspaces/:policyID/accounting/xero/import/tracking-categories', + getRoute: (policyID: string) => `settings/workspaces/${policyID}/accounting/xero/import/tracking-categories` as const, }, POLICY_ACCOUNTING_XERO_MAP_COST_CENTERS: { - route: 'settings/workspaces/:policyID/accounting/xero/import/trackCategories/mapCostCenters', - getRoute: (policyID: string) => `settings/workspaces/${policyID}/accounting/xero/import/trackCategories/mapCostCenters` as const, + route: 'settings/workspaces/:policyID/accounting/xero/import/tracking-categories/cost-centers', + getRoute: (policyID: string) => `settings/workspaces/${policyID}/accounting/xero/import/tracking-categories/cost-centers` as const, }, POLICY_ACCOUNTING_XERO_MAP_REGIONS: { - route: 'settings/workspaces/:policyID/accounting/xero/import/trackCategories/mapRegions', - getRoute: (policyID: string) => `settings/workspaces/${policyID}/accounting/xero/import/trackCategories/mapRegions` as const, + route: 'settings/workspaces/:policyID/accounting/xero/import/tracking-categories/region', + getRoute: (policyID: string) => `settings/workspaces/${policyID}/accounting/xero/import/tracking-categoriess/region` as const, }, POLICY_ACCOUNTING_XERO_CUSTOMER: { route: '/settings/workspaces/:policyID/accounting/xero/import/customers', From 1b58ea4aadf3adac238f35c1e621c098cee25c13 Mon Sep 17 00:00:00 2001 From: Manan Jadhav Date: Sun, 5 May 2024 00:19:00 +0530 Subject: [PATCH 17/29] refactor: rename keys --- src/CONST.ts | 8 ++++---- src/ROUTES.ts | 6 +++--- src/SCREENS.ts | 4 ++-- .../AppNavigator/ModalStackNavigators/index.tsx | 4 ++-- .../linkingConfig/FULL_SCREEN_TO_RHP_MAPPING.ts | 4 ++-- src/libs/Navigation/linkingConfig/config.ts | 6 +++--- src/libs/Navigation/types.ts | 9 +++++++-- src/libs/actions/connections/ConnectToXero.ts | 2 +- .../workspace/accounting/xero/XeroImportPage.tsx | 2 +- .../xero/XeroMapCostCentersToConfigurationPage.tsx | 8 ++++---- .../xero/XeroMapRegionsToConfigurationPage.tsx | 8 ++++---- .../xero/XeroTrackingCategoryConfigurationPage.tsx | 12 ++++++------ 12 files changed, 39 insertions(+), 34 deletions(-) diff --git a/src/CONST.ts b/src/CONST.ts index 5b68e5ae21c5..9fb61cee5adb 100755 --- a/src/CONST.ts +++ b/src/CONST.ts @@ -1283,14 +1283,14 @@ const CONST = { SYNC: 'sync', IMPORT_CUSTOMERS: 'importCustomers', IMPORT_TAX_RATES: 'importTaxRates', - IMPORT_TRACK_CATEGORIES: 'importTrackingCategories', + IMPORT_TRACKING_CATEGORIES: 'importTrackingCategories', MAPPINGS: 'mappings', - TRACK_CATEGORY_PREFIX: 'trackingCategory_', - TRACK_CATEGORY_FIELDS: { + TRACKING_CATEGORY_PREFIX: 'trackingCategory_', + TRACKING_CATEGORY_FIELDS: { COST_CENTERS: 'cost centers', REGION: 'region', }, - TRACK_CATEGORY_OPTIONS: { + TRACKING_CATEGORY_OPTIONS: { DEFAULT: 'DEFAULT', TAG: 'TAG' } diff --git a/src/ROUTES.ts b/src/ROUTES.ts index 0a4459c23acb..f1748a3d5506 100644 --- a/src/ROUTES.ts +++ b/src/ROUTES.ts @@ -780,15 +780,15 @@ const ROUTES = { route: 'settings/workspaces/:policyID/accounting/xero/organization/:currentOrganizationID', getRoute: (policyID: string, currentOrganizationID: string) => `settings/workspaces/${policyID}/accounting/xero/organization/${currentOrganizationID}` as const, }, - POLICY_ACCOUNTING_XERO_TRACK_CATEGORIES: { + POLICY_ACCOUNTING_XERO_TRACKING_CATEGORIES: { route: 'settings/workspaces/:policyID/accounting/xero/import/tracking-categories', getRoute: (policyID: string) => `settings/workspaces/${policyID}/accounting/xero/import/tracking-categories` as const, }, - POLICY_ACCOUNTING_XERO_MAP_COST_CENTERS: { + POLICY_ACCOUNTING_XERO_TRACKING_CATEGORIES_MAP_COST_CENTERS: { route: 'settings/workspaces/:policyID/accounting/xero/import/tracking-categories/cost-centers', getRoute: (policyID: string) => `settings/workspaces/${policyID}/accounting/xero/import/tracking-categories/cost-centers` as const, }, - POLICY_ACCOUNTING_XERO_MAP_REGIONS: { + POLICY_ACCOUNTING_XERO_TRACKING_CATEGORIES_MAP_REGION: { route: 'settings/workspaces/:policyID/accounting/xero/import/tracking-categories/region', getRoute: (policyID: string) => `settings/workspaces/${policyID}/accounting/xero/import/tracking-categoriess/region` as const, }, diff --git a/src/SCREENS.ts b/src/SCREENS.ts index 9fd4d5582350..1cb0d7e4016b 100644 --- a/src/SCREENS.ts +++ b/src/SCREENS.ts @@ -244,9 +244,9 @@ const SCREENS = { XERO_ORGANIZATION: 'Policy_Accounting_Xero_Customers', XERO_CUSTOMER: 'Policy_Acounting_Xero_Import_Customer', XERO_TAXES: 'Policy_Accounting_Xero_Taxes', - XERO_TRACK_CATEGORIES: 'Policy_Accounting_Xero_Track_Categories', + XERO_TRACKING_CATEGORIES: 'Policy_Accounting_Xero_Tracking_Categories', XERO_MAP_COST_CENTERS: 'Policy_Accounting_Xero_Map_Cost_Centers', - XERO_MAP_REGIONS: 'Policy_Accounting_Xero_Map_Regions', + XERO_MAP_REGION: 'Policy_Accounting_Xero_Map_Region', XERO_ADVANCED: 'Policy_Accounting_Xero_Advanced', }, INITIAL: 'Workspace_Initial', diff --git a/src/libs/Navigation/AppNavigator/ModalStackNavigators/index.tsx b/src/libs/Navigation/AppNavigator/ModalStackNavigators/index.tsx index 77d7aa4f75e0..c4785dca7187 100644 --- a/src/libs/Navigation/AppNavigator/ModalStackNavigators/index.tsx +++ b/src/libs/Navigation/AppNavigator/ModalStackNavigators/index.tsx @@ -305,9 +305,9 @@ const SettingsModalStackNavigator = createModalStackNavigator require('../../../../pages/workspace/accounting/xero/XeroOrganizationConfigurationPage').default as React.ComponentType, [SCREENS.WORKSPACE.ACCOUNTING.XERO_CUSTOMER]: () => require('../../../../pages/workspace/accounting/xero/import/XeroCustomerConfigurationPage').default as React.ComponentType, [SCREENS.WORKSPACE.ACCOUNTING.XERO_TAXES]: () => require('../../../../pages/workspace/accounting/xero/XeroTaxesConfigurationPage').default as React.ComponentType, - [SCREENS.WORKSPACE.ACCOUNTING.XERO_TRACK_CATEGORIES]: () => require('../../../../pages/workspace/accounting/xero/XeroTrackingCategoryConfigurationPage').default as React.ComponentType, + [SCREENS.WORKSPACE.ACCOUNTING.XERO_TRACKING_CATEGORIES]: () => require('../../../../pages/workspace/accounting/xero/XeroTrackingCategoryConfigurationPage').default as React.ComponentType, [SCREENS.WORKSPACE.ACCOUNTING.XERO_MAP_COST_CENTERS]: () => require('../../../../pages/workspace/accounting/xero/XeroMapCostCentersToConfigurationPage').default as React.ComponentType, - [SCREENS.WORKSPACE.ACCOUNTING.XERO_MAP_REGIONS]: () => require('../../../../pages/workspace/accounting/xero/XeroMapRegionsToConfigurationPage').default as React.ComponentType, + [SCREENS.WORKSPACE.ACCOUNTING.XERO_MAP_REGION]: () => require('../../../../pages/workspace/accounting/xero/XeroMapRegionsToConfigurationPage').default as React.ComponentType, [SCREENS.WORKSPACE.ACCOUNTING.XERO_ADVANCED]: () => require('../../../../pages/workspace/accounting/xero/advanced/XeroAdvancedPage').default as React.ComponentType, [SCREENS.WORKSPACE.WORKFLOWS_AUTO_REPORTING_FREQUENCY]: () => require('../../../../pages/workspace/workflows/WorkspaceAutoReportingFrequencyPage').default as React.ComponentType, [SCREENS.WORKSPACE.WORKFLOWS_AUTO_REPORTING_MONTHLY_OFFSET]: () => 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 43445fb234e5..503909121c00 100755 --- a/src/libs/Navigation/linkingConfig/FULL_SCREEN_TO_RHP_MAPPING.ts +++ b/src/libs/Navigation/linkingConfig/FULL_SCREEN_TO_RHP_MAPPING.ts @@ -44,9 +44,9 @@ const FULL_SCREEN_TO_RHP_MAPPING: Partial> = { SCREENS.WORKSPACE.ACCOUNTING.XERO_ORGANIZATION, SCREENS.WORKSPACE.ACCOUNTING.XERO_CUSTOMER, SCREENS.WORKSPACE.ACCOUNTING.XERO_TAXES, - SCREENS.WORKSPACE.ACCOUNTING.XERO_TRACK_CATEGORIES, + SCREENS.WORKSPACE.ACCOUNTING.XERO_TRACKING_CATEGORIES, SCREENS.WORKSPACE.ACCOUNTING.XERO_MAP_COST_CENTERS, - SCREENS.WORKSPACE.ACCOUNTING.XERO_MAP_REGIONS, + SCREENS.WORKSPACE.ACCOUNTING.XERO_MAP_REGION, SCREENS.WORKSPACE.ACCOUNTING.XERO_ADVANCED, ], [SCREENS.WORKSPACE.TAXES]: [ diff --git a/src/libs/Navigation/linkingConfig/config.ts b/src/libs/Navigation/linkingConfig/config.ts index 4147369084aa..2883195f1d94 100644 --- a/src/libs/Navigation/linkingConfig/config.ts +++ b/src/libs/Navigation/linkingConfig/config.ts @@ -329,9 +329,9 @@ const config: LinkingOptions['config'] = { }, [SCREENS.WORKSPACE.ACCOUNTING.XERO_IMPORT]: {path: ROUTES.POLICY_ACCOUNTING_XERO_IMPORT.route}, [SCREENS.WORKSPACE.ACCOUNTING.XERO_ORGANIZATION]: {path: ROUTES.POLICY_ACCOUNTING_XERO_ORGANIZATION.route}, - [SCREENS.WORKSPACE.ACCOUNTING.XERO_TRACK_CATEGORIES]: {path: ROUTES.POLICY_ACCOUNTING_XERO_TRACK_CATEGORIES.route}, - [SCREENS.WORKSPACE.ACCOUNTING.XERO_MAP_COST_CENTERS]: {path: ROUTES.POLICY_ACCOUNTING_XERO_MAP_COST_CENTERS.route}, - [SCREENS.WORKSPACE.ACCOUNTING.XERO_MAP_REGIONS]: {path: ROUTES.POLICY_ACCOUNTING_XERO_MAP_REGIONS.route}, + [SCREENS.WORKSPACE.ACCOUNTING.XERO_TRACKING_CATEGORIES]: {path: ROUTES.POLICY_ACCOUNTING_XERO_TRACKING_CATEGORIES.route}, + [SCREENS.WORKSPACE.ACCOUNTING.XERO_MAP_COST_CENTERS]: {path: ROUTES.POLICY_ACCOUNTING_XERO_TRACKING_CATEGORIES_MAP_COST_CENTERS.route}, + [SCREENS.WORKSPACE.ACCOUNTING.XERO_MAP_REGION]: {path: ROUTES.POLICY_ACCOUNTING_XERO_TRACKING_CATEGORIES_MAP_REGION.route}, [SCREENS.WORKSPACE.ACCOUNTING.XERO_CUSTOMER]: {path: ROUTES.POLICY_ACCOUNTING_XERO_CUSTOMER.route}, [SCREENS.WORKSPACE.ACCOUNTING.XERO_TAXES]: {path: ROUTES.POLICY_ACCOUNTING_XERO_TAXES.route}, [SCREENS.WORKSPACE.ACCOUNTING.XERO_ADVANCED]: {path: ROUTES.POLICY_ACCOUNTING_XERO_ADVANCED.route}, diff --git a/src/libs/Navigation/types.ts b/src/libs/Navigation/types.ts index e1f61d08a824..fde07e275aa6 100644 --- a/src/libs/Navigation/types.ts +++ b/src/libs/Navigation/types.ts @@ -324,8 +324,13 @@ type SettingsNavigatorParamList = { [SCREENS.WORKSPACE.ACCOUNTING.XERO_TAXES]: { policyID: string; }; - - [SCREENS.WORKSPACE.ACCOUNTING.XERO_TRACK_CATEGORIES]: { + [SCREENS.WORKSPACE.ACCOUNTING.XERO_TRACKING_CATEGORIES]: { + policyID: string; + }; + [SCREENS.WORKSPACE.ACCOUNTING.XERO_MAP_COST_CENTERS]: { + policyID: string; + }; + [SCREENS.WORKSPACE.ACCOUNTING.XERO_MAP_REGION]: { policyID: string; }; [SCREENS.WORKSPACE.ACCOUNTING.XERO_ADVANCED]: { diff --git a/src/libs/actions/connections/ConnectToXero.ts b/src/libs/actions/connections/ConnectToXero.ts index 51652c97bc49..7205690d2619 100644 --- a/src/libs/actions/connections/ConnectToXero.ts +++ b/src/libs/actions/connections/ConnectToXero.ts @@ -22,7 +22,7 @@ const getTrackingCategory = (policy: OnyxEntry, key: string) = return { ...category, - value: mappings?.[`${CONST.XERO_CONFIG.TRACK_CATEGORY_PREFIX}${category.id}`] ?? "" + value: mappings?.[`${CONST.XERO_CONFIG.TRACKING_CATEGORY_PREFIX}${category.id}`] ?? "" }; } diff --git a/src/pages/workspace/accounting/xero/XeroImportPage.tsx b/src/pages/workspace/accounting/xero/XeroImportPage.tsx index 4a0db25e9947..fbd0d6add7e5 100644 --- a/src/pages/workspace/accounting/xero/XeroImportPage.tsx +++ b/src/pages/workspace/accounting/xero/XeroImportPage.tsx @@ -36,7 +36,7 @@ function XeroImportPage({policy}: WithPolicyProps) { }, { description: translate('workspace.xero.trackingCategories'), - action: () => Navigation.navigate(ROUTES.POLICY_ACCOUNTING_XERO_TRACK_CATEGORIES.getRoute(policyID)), + action: () => Navigation.navigate(ROUTES.POLICY_ACCOUNTING_XERO_TRACKING_CATEGORIES.getRoute(policyID)), hasError: !!policy?.errors?.importTrackingCategories, title: importTrackingCategories ? translate('workspace.accounting.importTypes.TAG') : translate('workspace.xero.notImported'), pendingAction: pendingFields?.importTrackingCategories, diff --git a/src/pages/workspace/accounting/xero/XeroMapCostCentersToConfigurationPage.tsx b/src/pages/workspace/accounting/xero/XeroMapCostCentersToConfigurationPage.tsx index 6739940b8802..13282da8a5e3 100644 --- a/src/pages/workspace/accounting/xero/XeroMapCostCentersToConfigurationPage.tsx +++ b/src/pages/workspace/accounting/xero/XeroMapCostCentersToConfigurationPage.tsx @@ -16,10 +16,10 @@ function XeroMapCostCentersToConfigurationPage({policy}: WithPolicyProps) { const {translate} = useLocalize(); const policyID = policy?.id ?? ''; - const category = getTrackingCategory(policy, CONST.XERO_CONFIG.TRACK_CATEGORY_FIELDS.COST_CENTERS); + const category = getTrackingCategory(policy, CONST.XERO_CONFIG.TRACKING_CATEGORY_FIELDS.COST_CENTERS); const optionsList = useMemo(() => ( - Object.values(CONST.XERO_CONFIG.TRACK_CATEGORY_OPTIONS).map((option) => ({ + Object.values(CONST.XERO_CONFIG.TRACKING_CATEGORY_OPTIONS).map((option) => ({ value: option, text: translate(`workspace.xero.trackingCategoriesOptions.${option.toLowerCase()}` as TranslationPaths), keyForList: option, @@ -43,9 +43,9 @@ function XeroMapCostCentersToConfigurationPage({policy}: WithPolicyProps) { onSelectRow={(option) => { Connections.updatePolicyConnectionConfig(policyID, CONST.POLICY.CONNECTIONS.NAME.XERO, CONST.XERO_CONFIG.MAPPINGS, { ...(policy?.connections?.xero?.config?.mappings ?? {}), - ...(category?.id ? {[`${CONST.XERO_CONFIG.TRACK_CATEGORY_PREFIX}${category.id}`]: option.value}: {}) + ...(category?.id ? {[`${CONST.XERO_CONFIG.TRACKING_CATEGORY_PREFIX}${category.id}`]: option.value}: {}) }) - Navigation.goBack(ROUTES.POLICY_ACCOUNTING_XERO_TRACK_CATEGORIES.getRoute(policyID)); + Navigation.goBack(ROUTES.POLICY_ACCOUNTING_XERO_TRACKING_CATEGORIES.getRoute(policyID)); }} /> diff --git a/src/pages/workspace/accounting/xero/XeroMapRegionsToConfigurationPage.tsx b/src/pages/workspace/accounting/xero/XeroMapRegionsToConfigurationPage.tsx index 53e12e57cb41..d150ebae3589 100644 --- a/src/pages/workspace/accounting/xero/XeroMapRegionsToConfigurationPage.tsx +++ b/src/pages/workspace/accounting/xero/XeroMapRegionsToConfigurationPage.tsx @@ -16,10 +16,10 @@ import ROUTES from '@src/ROUTES'; function XeroMapRegionsToConfigurationPage({policy}: WithPolicyProps) { const {translate} = useLocalize(); const policyID = policy?.id ?? ''; - const category = getTrackingCategory(policy, CONST.XERO_CONFIG.TRACK_CATEGORY_FIELDS.REGION); + const category = getTrackingCategory(policy, CONST.XERO_CONFIG.TRACKING_CATEGORY_FIELDS.REGION); const optionsList = useMemo(() => ( - Object.values(CONST.XERO_CONFIG.TRACK_CATEGORY_OPTIONS).map((option) => ( + Object.values(CONST.XERO_CONFIG.TRACKING_CATEGORY_OPTIONS).map((option) => ( { value: option, text: translate(`workspace.xero.trackingCategoriesOptions.${option.toLowerCase()}` as TranslationPaths), @@ -43,9 +43,9 @@ function XeroMapRegionsToConfigurationPage({policy}: WithPolicyProps) { onSelectRow={(option) => { Connections.updatePolicyConnectionConfig(policyID, CONST.POLICY.CONNECTIONS.NAME.XERO, CONST.XERO_CONFIG.MAPPINGS, { ...(policy?.connections?.xero?.config?.mappings ?? {}), - ...(category?.id ? {[`${CONST.XERO_CONFIG.TRACK_CATEGORY_PREFIX}${category.id}`]: option.value}: {}) + ...(category?.id ? {[`${CONST.XERO_CONFIG.TRACKING_CATEGORY_PREFIX}${category.id}`]: option.value}: {}) }) - Navigation.goBack(ROUTES.POLICY_ACCOUNTING_XERO_TRACK_CATEGORIES.getRoute(policyID)); + Navigation.goBack(ROUTES.POLICY_ACCOUNTING_XERO_TRACKING_CATEGORIES.getRoute(policyID)); }} /> diff --git a/src/pages/workspace/accounting/xero/XeroTrackingCategoryConfigurationPage.tsx b/src/pages/workspace/accounting/xero/XeroTrackingCategoryConfigurationPage.tsx index eb392a9d225f..20c74dce1cf9 100644 --- a/src/pages/workspace/accounting/xero/XeroTrackingCategoryConfigurationPage.tsx +++ b/src/pages/workspace/accounting/xero/XeroTrackingCategoryConfigurationPage.tsx @@ -29,20 +29,20 @@ function XeroTrackingCategoryConfigurationPage({policy}: WithPolicyProps) { () => { const availableCategories = []; - const costCenterCategoryValue = getTrackingCategory(policy, CONST.XERO_CONFIG.TRACK_CATEGORY_FIELDS.COST_CENTERS)?.value ?? ""; - const regionCategoryValue = getTrackingCategory(policy, CONST.XERO_CONFIG.TRACK_CATEGORY_FIELDS.REGION)?.value ?? ""; + const costCenterCategoryValue = getTrackingCategory(policy, CONST.XERO_CONFIG.TRACKING_CATEGORY_FIELDS.COST_CENTERS)?.value ?? ""; + const regionCategoryValue = getTrackingCategory(policy, CONST.XERO_CONFIG.TRACKING_CATEGORY_FIELDS.REGION)?.value ?? ""; if (costCenterCategoryValue) { availableCategories.push({ description: translate('workspace.xero.mapXeroCostCentersTo'), - onPress: () => Navigation.navigate(ROUTES.POLICY_ACCOUNTING_XERO_MAP_COST_CENTERS.getRoute(policyID)), + onPress: () => Navigation.navigate(ROUTES.POLICY_ACCOUNTING_XERO_TRACKING_CATEGORIES_MAP_COST_CENTERS.getRoute(policyID)), title: translate(`workspace.xero.trackingCategoriesOptions.${costCenterCategoryValue.toLowerCase()}` as TranslationPaths) }); } - if (trackingCategories?.find((category) => category.name.toLowerCase() === CONST.XERO_CONFIG.TRACK_CATEGORY_FIELDS.REGION)) { + if (trackingCategories?.find((category) => category.name.toLowerCase() === CONST.XERO_CONFIG.TRACKING_CATEGORY_FIELDS.REGION)) { availableCategories.push({ description: translate('workspace.xero.mapXeroRegionsTo'), - onPress: () => Navigation.navigate(ROUTES.POLICY_ACCOUNTING_XERO_MAP_REGIONS.getRoute(policyID)), + onPress: () => Navigation.navigate(ROUTES.POLICY_ACCOUNTING_XERO_TRACKING_CATEGORIES_MAP_REGION.getRoute(policyID)), title: translate(`workspace.xero.trackingCategoriesOptions.${regionCategoryValue.toLowerCase()}` as TranslationPaths) }); } @@ -74,7 +74,7 @@ function XeroTrackingCategoryConfigurationPage({policy}: WithPolicyProps) { Connections.updatePolicyConnectionConfig( policyID, CONST.POLICY.CONNECTIONS.NAME.XERO, - CONST.XERO_CONFIG.IMPORT_TRACK_CATEGORIES, + CONST.XERO_CONFIG.IMPORT_TRACKING_CATEGORIES, !importTrackingCategories, ) } From d01ecf78b468edf0f13cf529dc3792c05130485c Mon Sep 17 00:00:00 2001 From: Manan Jadhav Date: Sun, 5 May 2024 00:23:01 +0530 Subject: [PATCH 18/29] style: lint fixes --- src/CONST.ts | 4 +- src/languages/en.ts | 2 +- src/languages/es.ts | 2 +- .../ModalStackNavigators/index.tsx | 3 +- src/libs/actions/connections/ConnectToXero.ts | 10 +- .../XeroMapCostCentersToConfigurationPage.tsx | 51 +++++----- .../XeroMapRegionsToConfigurationPage.tsx | 48 +++++----- .../XeroTrackingCategoryConfigurationPage.tsx | 95 +++++++++---------- src/types/onyx/Policy.ts | 2 +- 9 files changed, 108 insertions(+), 109 deletions(-) diff --git a/src/CONST.ts b/src/CONST.ts index 9fb61cee5adb..23b16d217bb4 100755 --- a/src/CONST.ts +++ b/src/CONST.ts @@ -1292,8 +1292,8 @@ const CONST = { }, TRACKING_CATEGORY_OPTIONS: { DEFAULT: 'DEFAULT', - TAG: 'TAG' - } + TAG: 'TAG', + }, }, QUICKBOOKS_REIMBURSABLE_ACCOUNT_TYPE: { diff --git a/src/languages/en.ts b/src/languages/en.ts index b46f2126d706..57429a971484 100755 --- a/src/languages/en.ts +++ b/src/languages/en.ts @@ -2031,7 +2031,7 @@ export default { notImported: 'Not imported', trackingCategoriesOptions: { default: 'Xero contact default', - tag: 'Tags' + tag: 'Tags', }, advancedConfig: { advanced: 'Advanced', diff --git a/src/languages/es.ts b/src/languages/es.ts index 339fda0b36c5..db4f1231a82a 100644 --- a/src/languages/es.ts +++ b/src/languages/es.ts @@ -2064,7 +2064,7 @@ export default { notImported: 'No importado', trackingCategoriesOptions: { default: 'Contacto de Xero por defecto', - tag: 'Etiquetas' + tag: 'Etiquetas', }, advancedConfig: { advanced: 'Avanzado', diff --git a/src/libs/Navigation/AppNavigator/ModalStackNavigators/index.tsx b/src/libs/Navigation/AppNavigator/ModalStackNavigators/index.tsx index c4785dca7187..86642efc8545 100644 --- a/src/libs/Navigation/AppNavigator/ModalStackNavigators/index.tsx +++ b/src/libs/Navigation/AppNavigator/ModalStackNavigators/index.tsx @@ -305,7 +305,8 @@ const SettingsModalStackNavigator = createModalStackNavigator require('../../../../pages/workspace/accounting/xero/XeroOrganizationConfigurationPage').default as React.ComponentType, [SCREENS.WORKSPACE.ACCOUNTING.XERO_CUSTOMER]: () => require('../../../../pages/workspace/accounting/xero/import/XeroCustomerConfigurationPage').default as React.ComponentType, [SCREENS.WORKSPACE.ACCOUNTING.XERO_TAXES]: () => require('../../../../pages/workspace/accounting/xero/XeroTaxesConfigurationPage').default as React.ComponentType, - [SCREENS.WORKSPACE.ACCOUNTING.XERO_TRACKING_CATEGORIES]: () => require('../../../../pages/workspace/accounting/xero/XeroTrackingCategoryConfigurationPage').default as React.ComponentType, + [SCREENS.WORKSPACE.ACCOUNTING.XERO_TRACKING_CATEGORIES]: () => + require('../../../../pages/workspace/accounting/xero/XeroTrackingCategoryConfigurationPage').default as React.ComponentType, [SCREENS.WORKSPACE.ACCOUNTING.XERO_MAP_COST_CENTERS]: () => require('../../../../pages/workspace/accounting/xero/XeroMapCostCentersToConfigurationPage').default as React.ComponentType, [SCREENS.WORKSPACE.ACCOUNTING.XERO_MAP_REGION]: () => require('../../../../pages/workspace/accounting/xero/XeroMapRegionsToConfigurationPage').default as React.ComponentType, [SCREENS.WORKSPACE.ACCOUNTING.XERO_ADVANCED]: () => require('../../../../pages/workspace/accounting/xero/advanced/XeroAdvancedPage').default as React.ComponentType, diff --git a/src/libs/actions/connections/ConnectToXero.ts b/src/libs/actions/connections/ConnectToXero.ts index 7205690d2619..fde22855a618 100644 --- a/src/libs/actions/connections/ConnectToXero.ts +++ b/src/libs/actions/connections/ConnectToXero.ts @@ -1,8 +1,8 @@ +import type {OnyxEntry} from 'react-native-onyx'; import type {ConnectPolicyToAccountingIntegrationParams} from '@libs/API/parameters'; import {READ_COMMANDS} from '@libs/API/types'; import {getCommandURL} from '@libs/ApiUtils'; import CONST from '@src/CONST'; -import type {OnyxEntry} from 'react-native-onyx'; import type * as OnyxTypes from '@src/types/onyx'; const getXeroSetupLink = (policyID: string) => { @@ -12,8 +12,8 @@ const getXeroSetupLink = (policyID: string) => { }; const getTrackingCategory = (policy: OnyxEntry, key: string) => { - const { trackingCategories } = policy?.connections?.xero?.data ?? {}; - const { mappings } = policy?.connections?.xero?.config ?? {}; + const {trackingCategories} = policy?.connections?.xero?.data ?? {}; + const {mappings} = policy?.connections?.xero?.config ?? {}; const category = trackingCategories?.find((currentCategory) => currentCategory.name.toLowerCase() === key.toLowerCase()); if (!category) { @@ -22,8 +22,8 @@ const getTrackingCategory = (policy: OnyxEntry, key: string) = return { ...category, - value: mappings?.[`${CONST.XERO_CONFIG.TRACKING_CATEGORY_PREFIX}${category.id}`] ?? "" + value: mappings?.[`${CONST.XERO_CONFIG.TRACKING_CATEGORY_PREFIX}${category.id}`] ?? '', }; -} +}; export {getXeroSetupLink, getTrackingCategory}; diff --git a/src/pages/workspace/accounting/xero/XeroMapCostCentersToConfigurationPage.tsx b/src/pages/workspace/accounting/xero/XeroMapCostCentersToConfigurationPage.tsx index 13282da8a5e3..a2c1b6421abb 100644 --- a/src/pages/workspace/accounting/xero/XeroMapCostCentersToConfigurationPage.tsx +++ b/src/pages/workspace/accounting/xero/XeroMapCostCentersToConfigurationPage.tsx @@ -1,32 +1,33 @@ -import React, { useMemo } from 'react'; +import React, {useMemo} from 'react'; import ConnectionLayout from '@components/ConnectionLayout'; import SelectionList from '@components/SelectionList'; import RadioListItem from '@components/SelectionList/RadioListItem'; import useLocalize from '@hooks/useLocalize'; import * as Connections from '@libs/actions/connections'; +import {getTrackingCategory} from '@libs/actions/connections/ConnectToXero'; +import Navigation from '@libs/Navigation/Navigation'; import type {WithPolicyProps} from '@pages/workspace/withPolicy'; import withPolicyConnections from '@pages/workspace/withPolicyConnections'; -import { getTrackingCategory } from '@libs/actions/connections/ConnectToXero'; import CONST from '@src/CONST'; -import type { TranslationPaths } from '@src/languages/types'; -import Navigation from '@libs/Navigation/Navigation'; +import type {TranslationPaths} from '@src/languages/types'; import ROUTES from '@src/ROUTES'; function XeroMapCostCentersToConfigurationPage({policy}: WithPolicyProps) { const {translate} = useLocalize(); const policyID = policy?.id ?? ''; - const category = getTrackingCategory(policy, CONST.XERO_CONFIG.TRACKING_CATEGORY_FIELDS.COST_CENTERS); - - const optionsList = useMemo(() => ( - Object.values(CONST.XERO_CONFIG.TRACKING_CATEGORY_OPTIONS).map((option) => ({ - value: option, - text: translate(`workspace.xero.trackingCategoriesOptions.${option.toLowerCase()}` as TranslationPaths), - keyForList: option, - isSelected: option.toLowerCase() === category?.value?.toLowerCase() - })) - ), [translate, category]); + const category = getTrackingCategory(policy, CONST.XERO_CONFIG.TRACKING_CATEGORY_FIELDS.COST_CENTERS); + const optionsList = useMemo( + () => + Object.values(CONST.XERO_CONFIG.TRACKING_CATEGORY_OPTIONS).map((option) => ({ + value: option, + text: translate(`workspace.xero.trackingCategoriesOptions.${option.toLowerCase()}` as TranslationPaths), + keyForList: option, + isSelected: option.toLowerCase() === category?.value?.toLowerCase(), + })), + [translate, category], + ); return ( - { - Connections.updatePolicyConnectionConfig(policyID, CONST.POLICY.CONNECTIONS.NAME.XERO, CONST.XERO_CONFIG.MAPPINGS, { - ...(policy?.connections?.xero?.config?.mappings ?? {}), - ...(category?.id ? {[`${CONST.XERO_CONFIG.TRACKING_CATEGORY_PREFIX}${category.id}`]: option.value}: {}) - }) - Navigation.goBack(ROUTES.POLICY_ACCOUNTING_XERO_TRACKING_CATEGORIES.getRoute(policyID)); - }} - /> + { + Connections.updatePolicyConnectionConfig(policyID, CONST.POLICY.CONNECTIONS.NAME.XERO, CONST.XERO_CONFIG.MAPPINGS, { + ...(policy?.connections?.xero?.config?.mappings ?? {}), + ...(category?.id ? {[`${CONST.XERO_CONFIG.TRACKING_CATEGORY_PREFIX}${category.id}`]: option.value} : {}), + }); + Navigation.goBack(ROUTES.POLICY_ACCOUNTING_XERO_TRACKING_CATEGORIES.getRoute(policyID)); + }} + /> ); } diff --git a/src/pages/workspace/accounting/xero/XeroMapRegionsToConfigurationPage.tsx b/src/pages/workspace/accounting/xero/XeroMapRegionsToConfigurationPage.tsx index d150ebae3589..043215339229 100644 --- a/src/pages/workspace/accounting/xero/XeroMapRegionsToConfigurationPage.tsx +++ b/src/pages/workspace/accounting/xero/XeroMapRegionsToConfigurationPage.tsx @@ -1,32 +1,32 @@ -import React, { useMemo } from 'react'; +import React, {useMemo} from 'react'; import ConnectionLayout from '@components/ConnectionLayout'; import SelectionList from '@components/SelectionList'; import RadioListItem from '@components/SelectionList/RadioListItem'; import useLocalize from '@hooks/useLocalize'; import * as Connections from '@libs/actions/connections'; +import {getTrackingCategory} from '@libs/actions/connections/ConnectToXero'; +import Navigation from '@libs/Navigation/Navigation'; import type {WithPolicyProps} from '@pages/workspace/withPolicy'; import withPolicyConnections from '@pages/workspace/withPolicyConnections'; import CONST from '@src/CONST'; -import { getTrackingCategory } from '@libs/actions/connections/ConnectToXero'; -import type { TranslationPaths } from '@src/languages/types'; -import Navigation from '@libs/Navigation/Navigation'; +import type {TranslationPaths} from '@src/languages/types'; import ROUTES from '@src/ROUTES'; - function XeroMapRegionsToConfigurationPage({policy}: WithPolicyProps) { const {translate} = useLocalize(); const policyID = policy?.id ?? ''; - const category = getTrackingCategory(policy, CONST.XERO_CONFIG.TRACKING_CATEGORY_FIELDS.REGION); + const category = getTrackingCategory(policy, CONST.XERO_CONFIG.TRACKING_CATEGORY_FIELDS.REGION); - const optionsList = useMemo(() => ( - Object.values(CONST.XERO_CONFIG.TRACKING_CATEGORY_OPTIONS).map((option) => ( - { + const optionsList = useMemo( + () => + Object.values(CONST.XERO_CONFIG.TRACKING_CATEGORY_OPTIONS).map((option) => ({ value: option, text: translate(`workspace.xero.trackingCategoriesOptions.${option.toLowerCase()}` as TranslationPaths), keyForList: option, - isSelected: option.toLowerCase() === category?.value?.toLowerCase() - } - ))), [translate, category]); + isSelected: option.toLowerCase() === category?.value?.toLowerCase(), + })), + [translate, category], + ); return ( - { - Connections.updatePolicyConnectionConfig(policyID, CONST.POLICY.CONNECTIONS.NAME.XERO, CONST.XERO_CONFIG.MAPPINGS, { - ...(policy?.connections?.xero?.config?.mappings ?? {}), - ...(category?.id ? {[`${CONST.XERO_CONFIG.TRACKING_CATEGORY_PREFIX}${category.id}`]: option.value}: {}) - }) - Navigation.goBack(ROUTES.POLICY_ACCOUNTING_XERO_TRACKING_CATEGORIES.getRoute(policyID)); - }} - /> - + { + Connections.updatePolicyConnectionConfig(policyID, CONST.POLICY.CONNECTIONS.NAME.XERO, CONST.XERO_CONFIG.MAPPINGS, { + ...(policy?.connections?.xero?.config?.mappings ?? {}), + ...(category?.id ? {[`${CONST.XERO_CONFIG.TRACKING_CATEGORY_PREFIX}${category.id}`]: option.value} : {}), + }); + Navigation.goBack(ROUTES.POLICY_ACCOUNTING_XERO_TRACKING_CATEGORIES.getRoute(policyID)); + }} + /> + ); } diff --git a/src/pages/workspace/accounting/xero/XeroTrackingCategoryConfigurationPage.tsx b/src/pages/workspace/accounting/xero/XeroTrackingCategoryConfigurationPage.tsx index 20c74dce1cf9..53f03fbaa485 100644 --- a/src/pages/workspace/accounting/xero/XeroTrackingCategoryConfigurationPage.tsx +++ b/src/pages/workspace/accounting/xero/XeroTrackingCategoryConfigurationPage.tsx @@ -1,5 +1,7 @@ import React, {useMemo} from 'react'; import {View} from 'react-native'; +import ConnectionLayout from '@components/ConnectionLayout'; +import type {MenuItemProps} from '@components/MenuItem'; import MenuItemWithTopDescription from '@components/MenuItemWithTopDescription'; import OfflineWithFeedback from '@components/OfflineWithFeedback'; import Switch from '@components/Switch'; @@ -7,35 +9,32 @@ import Text from '@components/Text'; import useLocalize from '@hooks/useLocalize'; import useThemeStyles from '@hooks/useThemeStyles'; import * as Connections from '@libs/actions/connections'; +import {getTrackingCategory} from '@libs/actions/connections/ConnectToXero'; import Navigation from '@libs/Navigation/Navigation'; import type {WithPolicyProps} from '@pages/workspace/withPolicy'; import withPolicyConnections from '@pages/workspace/withPolicyConnections'; import variables from '@styles/variables'; import CONST from '@src/CONST'; +import type {TranslationPaths} from '@src/languages/types'; import ROUTES from '@src/ROUTES'; -import { getTrackingCategory } from '@libs/actions/connections/ConnectToXero'; -import type { TranslationPaths } from '@src/languages/types'; -import type { MenuItemProps } from '@components/MenuItem'; -import ConnectionLayout from '@components/ConnectionLayout'; function XeroTrackingCategoryConfigurationPage({policy}: WithPolicyProps) { const {translate} = useLocalize(); const styles = useThemeStyles(); const policyID = policy?.id ?? ''; const {importTrackingCategories, pendingFields} = policy?.connections?.xero?.config ?? {}; - const { trackingCategories } = policy?.connections?.xero?.data ?? {}; + const {trackingCategories} = policy?.connections?.xero?.data ?? {}; - const menuItems: MenuItemProps[] = useMemo( - () => { + const menuItems: MenuItemProps[] = useMemo(() => { const availableCategories = []; - const costCenterCategoryValue = getTrackingCategory(policy, CONST.XERO_CONFIG.TRACKING_CATEGORY_FIELDS.COST_CENTERS)?.value ?? ""; - const regionCategoryValue = getTrackingCategory(policy, CONST.XERO_CONFIG.TRACKING_CATEGORY_FIELDS.REGION)?.value ?? ""; + const costCenterCategoryValue = getTrackingCategory(policy, CONST.XERO_CONFIG.TRACKING_CATEGORY_FIELDS.COST_CENTERS)?.value ?? ''; + const regionCategoryValue = getTrackingCategory(policy, CONST.XERO_CONFIG.TRACKING_CATEGORY_FIELDS.REGION)?.value ?? ''; if (costCenterCategoryValue) { availableCategories.push({ description: translate('workspace.xero.mapXeroCostCentersTo'), onPress: () => Navigation.navigate(ROUTES.POLICY_ACCOUNTING_XERO_TRACKING_CATEGORIES_MAP_COST_CENTERS.getRoute(policyID)), - title: translate(`workspace.xero.trackingCategoriesOptions.${costCenterCategoryValue.toLowerCase()}` as TranslationPaths) + title: translate(`workspace.xero.trackingCategoriesOptions.${costCenterCategoryValue.toLowerCase()}` as TranslationPaths), }); } @@ -43,13 +42,11 @@ function XeroTrackingCategoryConfigurationPage({policy}: WithPolicyProps) { availableCategories.push({ description: translate('workspace.xero.mapXeroRegionsTo'), onPress: () => Navigation.navigate(ROUTES.POLICY_ACCOUNTING_XERO_TRACKING_CATEGORIES_MAP_REGION.getRoute(policyID)), - title: translate(`workspace.xero.trackingCategoriesOptions.${regionCategoryValue.toLowerCase()}` as TranslationPaths) + title: translate(`workspace.xero.trackingCategoriesOptions.${regionCategoryValue.toLowerCase()}` as TranslationPaths), }); } return availableCategories; - }, - [translate, policy, policyID, trackingCategories], - ); + }, [translate, policy, policyID, trackingCategories]); return ( - - - {translate('workspace.accounting.import')} - - - - - Connections.updatePolicyConnectionConfig( - policyID, - CONST.POLICY.CONNECTIONS.NAME.XERO, - CONST.XERO_CONFIG.IMPORT_TRACKING_CATEGORIES, - !importTrackingCategories, - ) - } - /> - - + + + {translate('workspace.accounting.import')} - - {importTrackingCategories && ( - - {menuItems.map((menuItem: MenuItemProps) => ( - + + + Connections.updatePolicyConnectionConfig( + policyID, + CONST.POLICY.CONNECTIONS.NAME.XERO, + CONST.XERO_CONFIG.IMPORT_TRACKING_CATEGORIES, + !importTrackingCategories, + ) + } /> - ))} - - )} - + + + + + {importTrackingCategories && ( + + {menuItems.map((menuItem: MenuItemProps) => ( + + ))} + + )} + ); } diff --git a/src/types/onyx/Policy.ts b/src/types/onyx/Policy.ts index 7db56c5a96f8..002e8820504a 100644 --- a/src/types/onyx/Policy.ts +++ b/src/types/onyx/Policy.ts @@ -208,7 +208,7 @@ type Tenant = { type XeroTrackingCategory = { id: string; name: string; -} +}; type XeroConnectionData = { bankAccounts: unknown[]; From ffd6e3c6cc95ddb8d68caf0233514af1762f374d Mon Sep 17 00:00:00 2001 From: Manan Jadhav Date: Sun, 5 May 2024 00:25:30 +0530 Subject: [PATCH 19/29] fix: typo in url --- src/ROUTES.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/ROUTES.ts b/src/ROUTES.ts index f1748a3d5506..52eeef6c424f 100644 --- a/src/ROUTES.ts +++ b/src/ROUTES.ts @@ -790,7 +790,7 @@ const ROUTES = { }, POLICY_ACCOUNTING_XERO_TRACKING_CATEGORIES_MAP_REGION: { route: 'settings/workspaces/:policyID/accounting/xero/import/tracking-categories/region', - getRoute: (policyID: string) => `settings/workspaces/${policyID}/accounting/xero/import/tracking-categoriess/region` as const, + getRoute: (policyID: string) => `settings/workspaces/${policyID}/accounting/xero/import/tracking-categories/region` as const, }, POLICY_ACCOUNTING_XERO_CUSTOMER: { route: '/settings/workspaces/:policyID/accounting/xero/import/customers', From 2fefa854e9d175eb1cf5281299ff97a6ca982060 Mon Sep 17 00:00:00 2001 From: Manan Jadhav Date: Sun, 5 May 2024 11:58:11 +0530 Subject: [PATCH 20/29] refactor: move api call to useCallback --- .../XeroMapCostCentersToConfigurationPage.tsx | 21 ++++++++++++------- .../XeroMapRegionsToConfigurationPage.tsx | 20 +++++++++++------- 2 files changed, 25 insertions(+), 16 deletions(-) diff --git a/src/pages/workspace/accounting/xero/XeroMapCostCentersToConfigurationPage.tsx b/src/pages/workspace/accounting/xero/XeroMapCostCentersToConfigurationPage.tsx index a2c1b6421abb..4635c712580e 100644 --- a/src/pages/workspace/accounting/xero/XeroMapCostCentersToConfigurationPage.tsx +++ b/src/pages/workspace/accounting/xero/XeroMapCostCentersToConfigurationPage.tsx @@ -1,4 +1,4 @@ -import React, {useMemo} from 'react'; +import React, {useMemo, useCallback} from 'react'; import ConnectionLayout from '@components/ConnectionLayout'; import SelectionList from '@components/SelectionList'; import RadioListItem from '@components/SelectionList/RadioListItem'; @@ -29,6 +29,17 @@ function XeroMapCostCentersToConfigurationPage({policy}: WithPolicyProps) { [translate, category], ); + const updateMapping = useCallback((option: {value: string}) => { + if (option.value !== category?.value) { + Connections.updatePolicyConnectionConfig(policyID, CONST.POLICY.CONNECTIONS.NAME.XERO, CONST.XERO_CONFIG.MAPPINGS, { + ...(policy?.connections?.xero?.config?.mappings ?? {}), + ...(category?.id ? {[`${CONST.XERO_CONFIG.TRACKING_CATEGORY_PREFIX}${category.id}`]: option.value} : {}), + }); + } + Navigation.goBack(ROUTES.POLICY_ACCOUNTING_XERO_TRACKING_CATEGORIES.getRoute(policyID)); + }, [category, policyID,policy?.connections?.xero?.config?.mappings]); + + return ( { - Connections.updatePolicyConnectionConfig(policyID, CONST.POLICY.CONNECTIONS.NAME.XERO, CONST.XERO_CONFIG.MAPPINGS, { - ...(policy?.connections?.xero?.config?.mappings ?? {}), - ...(category?.id ? {[`${CONST.XERO_CONFIG.TRACKING_CATEGORY_PREFIX}${category.id}`]: option.value} : {}), - }); - Navigation.goBack(ROUTES.POLICY_ACCOUNTING_XERO_TRACKING_CATEGORIES.getRoute(policyID)); - }} + onSelectRow={updateMapping} /> ); diff --git a/src/pages/workspace/accounting/xero/XeroMapRegionsToConfigurationPage.tsx b/src/pages/workspace/accounting/xero/XeroMapRegionsToConfigurationPage.tsx index 043215339229..cc5abd1678df 100644 --- a/src/pages/workspace/accounting/xero/XeroMapRegionsToConfigurationPage.tsx +++ b/src/pages/workspace/accounting/xero/XeroMapRegionsToConfigurationPage.tsx @@ -1,4 +1,4 @@ -import React, {useMemo} from 'react'; +import React, {useCallback, useMemo} from 'react'; import ConnectionLayout from '@components/ConnectionLayout'; import SelectionList from '@components/SelectionList'; import RadioListItem from '@components/SelectionList/RadioListItem'; @@ -28,6 +28,16 @@ function XeroMapRegionsToConfigurationPage({policy}: WithPolicyProps) { [translate, category], ); + const updateMapping = useCallback((option: {value: string}) => { + if (option.value !== category?.value) { + Connections.updatePolicyConnectionConfig(policyID, CONST.POLICY.CONNECTIONS.NAME.XERO, CONST.XERO_CONFIG.MAPPINGS, { + ...(policy?.connections?.xero?.config?.mappings ?? {}), + ...(category?.id ? {[`${CONST.XERO_CONFIG.TRACKING_CATEGORY_PREFIX}${category.id}`]: option.value} : {}), + }); + } + Navigation.goBack(ROUTES.POLICY_ACCOUNTING_XERO_TRACKING_CATEGORIES.getRoute(policyID)); + }, [category, policyID,policy?.connections?.xero?.config?.mappings]); + return ( { - Connections.updatePolicyConnectionConfig(policyID, CONST.POLICY.CONNECTIONS.NAME.XERO, CONST.XERO_CONFIG.MAPPINGS, { - ...(policy?.connections?.xero?.config?.mappings ?? {}), - ...(category?.id ? {[`${CONST.XERO_CONFIG.TRACKING_CATEGORY_PREFIX}${category.id}`]: option.value} : {}), - }); - Navigation.goBack(ROUTES.POLICY_ACCOUNTING_XERO_TRACKING_CATEGORIES.getRoute(policyID)); - }} + onSelectRow={updateMapping} /> ); From cf0adbe001e51db229865954f3eb4945af052b46 Mon Sep 17 00:00:00 2001 From: Manan Jadhav Date: Sun, 5 May 2024 18:42:43 +0530 Subject: [PATCH 21/29] refactor: prettier fix --- .../XeroMapCostCentersToConfigurationPage.tsx | 24 ++++++++++--------- .../XeroMapRegionsToConfigurationPage.tsx | 21 +++++++++------- 2 files changed, 25 insertions(+), 20 deletions(-) diff --git a/src/pages/workspace/accounting/xero/XeroMapCostCentersToConfigurationPage.tsx b/src/pages/workspace/accounting/xero/XeroMapCostCentersToConfigurationPage.tsx index 4635c712580e..0d7e74d3b3e9 100644 --- a/src/pages/workspace/accounting/xero/XeroMapCostCentersToConfigurationPage.tsx +++ b/src/pages/workspace/accounting/xero/XeroMapCostCentersToConfigurationPage.tsx @@ -1,4 +1,4 @@ -import React, {useMemo, useCallback} from 'react'; +import React, {useCallback, useMemo} from 'react'; import ConnectionLayout from '@components/ConnectionLayout'; import SelectionList from '@components/SelectionList'; import RadioListItem from '@components/SelectionList/RadioListItem'; @@ -29,16 +29,18 @@ function XeroMapCostCentersToConfigurationPage({policy}: WithPolicyProps) { [translate, category], ); - const updateMapping = useCallback((option: {value: string}) => { - if (option.value !== category?.value) { - Connections.updatePolicyConnectionConfig(policyID, CONST.POLICY.CONNECTIONS.NAME.XERO, CONST.XERO_CONFIG.MAPPINGS, { - ...(policy?.connections?.xero?.config?.mappings ?? {}), - ...(category?.id ? {[`${CONST.XERO_CONFIG.TRACKING_CATEGORY_PREFIX}${category.id}`]: option.value} : {}), - }); - } - Navigation.goBack(ROUTES.POLICY_ACCOUNTING_XERO_TRACKING_CATEGORIES.getRoute(policyID)); - }, [category, policyID,policy?.connections?.xero?.config?.mappings]); - + const updateMapping = useCallback( + (option: {value: string}) => { + if (option.value !== category?.value) { + Connections.updatePolicyConnectionConfig(policyID, CONST.POLICY.CONNECTIONS.NAME.XERO, CONST.XERO_CONFIG.MAPPINGS, { + ...(policy?.connections?.xero?.config?.mappings ?? {}), + ...(category?.id ? {[`${CONST.XERO_CONFIG.TRACKING_CATEGORY_PREFIX}${category.id}`]: option.value} : {}), + }); + } + Navigation.goBack(ROUTES.POLICY_ACCOUNTING_XERO_TRACKING_CATEGORIES.getRoute(policyID)); + }, + [category, policyID, policy?.connections?.xero?.config?.mappings], + ); return ( { - if (option.value !== category?.value) { - Connections.updatePolicyConnectionConfig(policyID, CONST.POLICY.CONNECTIONS.NAME.XERO, CONST.XERO_CONFIG.MAPPINGS, { - ...(policy?.connections?.xero?.config?.mappings ?? {}), - ...(category?.id ? {[`${CONST.XERO_CONFIG.TRACKING_CATEGORY_PREFIX}${category.id}`]: option.value} : {}), - }); - } - Navigation.goBack(ROUTES.POLICY_ACCOUNTING_XERO_TRACKING_CATEGORIES.getRoute(policyID)); - }, [category, policyID,policy?.connections?.xero?.config?.mappings]); + const updateMapping = useCallback( + (option: {value: string}) => { + if (option.value !== category?.value) { + Connections.updatePolicyConnectionConfig(policyID, CONST.POLICY.CONNECTIONS.NAME.XERO, CONST.XERO_CONFIG.MAPPINGS, { + ...(policy?.connections?.xero?.config?.mappings ?? {}), + ...(category?.id ? {[`${CONST.XERO_CONFIG.TRACKING_CATEGORY_PREFIX}${category.id}`]: option.value} : {}), + }); + } + Navigation.goBack(ROUTES.POLICY_ACCOUNTING_XERO_TRACKING_CATEGORIES.getRoute(policyID)); + }, + [category, policyID, policy?.connections?.xero?.config?.mappings], + ); return ( Date: Sun, 5 May 2024 18:49:25 +0530 Subject: [PATCH 22/29] docs: added comments --- src/libs/actions/connections/ConnectToXero.ts | 12 ++++++++++-- src/types/onyx/Policy.ts | 1 + 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/src/libs/actions/connections/ConnectToXero.ts b/src/libs/actions/connections/ConnectToXero.ts index fde22855a618..43972e540d58 100644 --- a/src/libs/actions/connections/ConnectToXero.ts +++ b/src/libs/actions/connections/ConnectToXero.ts @@ -4,6 +4,7 @@ import {READ_COMMANDS} from '@libs/API/types'; import {getCommandURL} from '@libs/ApiUtils'; import CONST from '@src/CONST'; import type * as OnyxTypes from '@src/types/onyx'; +import type {XeroTrackingCategory} from '@src/types/onyx/Policy'; const getXeroSetupLink = (policyID: string) => { const params: ConnectPolicyToAccountingIntegrationParams = {policyID}; @@ -11,11 +12,18 @@ const getXeroSetupLink = (policyID: string) => { return commandURL + new URLSearchParams(params).toString(); }; -const getTrackingCategory = (policy: OnyxEntry, key: string) => { +/** + * Fetches the category object from the xero.data.trackingCategories based on the category name. + * This is required to get Xero category object with current value stored in the xero.config.mappings + * @param policy + * @param key + * @returns Filtered category matching the category name or undefined. + */ +const getTrackingCategory = (policy: OnyxEntry, categoryName: string): (XeroTrackingCategory & {value: string}) | undefined => { const {trackingCategories} = policy?.connections?.xero?.data ?? {}; const {mappings} = policy?.connections?.xero?.config ?? {}; - const category = trackingCategories?.find((currentCategory) => currentCategory.name.toLowerCase() === key.toLowerCase()); + const category = trackingCategories?.find((currentCategory) => currentCategory.name.toLowerCase() === categoryName.toLowerCase()); if (!category) { return undefined; } diff --git a/src/types/onyx/Policy.ts b/src/types/onyx/Policy.ts index 002e8820504a..e23935ba6857 100644 --- a/src/types/onyx/Policy.ts +++ b/src/types/onyx/Policy.ts @@ -570,4 +570,5 @@ export type { QBONonReimbursableExportAccountType, QBOReimbursableExportAccountType, QBOConnectionConfig, + XeroTrackingCategory, }; From dd38d835f79d4551646698f6c5a0f503b5b1a99c Mon Sep 17 00:00:00 2001 From: Manan Jadhav Date: Mon, 6 May 2024 09:39:14 +0530 Subject: [PATCH 23/29] refactor: connection layout alignment --- .../accounting/xero/XeroMapCostCentersToConfigurationPage.tsx | 4 ++++ .../accounting/xero/XeroMapRegionsToConfigurationPage.tsx | 4 ++++ .../accounting/xero/XeroTrackingCategoryConfigurationPage.tsx | 1 + 3 files changed, 9 insertions(+) diff --git a/src/pages/workspace/accounting/xero/XeroMapCostCentersToConfigurationPage.tsx b/src/pages/workspace/accounting/xero/XeroMapCostCentersToConfigurationPage.tsx index 0d7e74d3b3e9..4280bcedbf3e 100644 --- a/src/pages/workspace/accounting/xero/XeroMapCostCentersToConfigurationPage.tsx +++ b/src/pages/workspace/accounting/xero/XeroMapCostCentersToConfigurationPage.tsx @@ -3,6 +3,7 @@ import ConnectionLayout from '@components/ConnectionLayout'; import SelectionList from '@components/SelectionList'; import RadioListItem from '@components/SelectionList/RadioListItem'; import useLocalize from '@hooks/useLocalize'; +import useThemeStyles from '@hooks/useThemeStyles'; import * as Connections from '@libs/actions/connections'; import {getTrackingCategory} from '@libs/actions/connections/ConnectToXero'; import Navigation from '@libs/Navigation/Navigation'; @@ -14,6 +15,8 @@ import ROUTES from '@src/ROUTES'; function XeroMapCostCentersToConfigurationPage({policy}: WithPolicyProps) { const {translate} = useLocalize(); + const styles = useThemeStyles(); + const policyID = policy?.id ?? ''; const category = getTrackingCategory(policy, CONST.XERO_CONFIG.TRACKING_CATEGORY_FIELDS.COST_CENTERS); @@ -50,6 +53,7 @@ function XeroMapCostCentersToConfigurationPage({policy}: WithPolicyProps) { accessVariants={[CONST.POLICY.ACCESS_VARIANTS.ADMIN]} policyID={policyID && category?.id ? policyID : ''} featureName={CONST.POLICY.MORE_FEATURES.ARE_CONNECTIONS_ENABLED} + titleStyle={[styles.pb2, styles.ph5]} > From 2df2388052f72fe7c00bde36b1c486067466b6f0 Mon Sep 17 00:00:00 2001 From: Manan Jadhav Date: Mon, 6 May 2024 11:28:12 +0530 Subject: [PATCH 24/29] style: lint fix --- .../accounting/xero/XeroMapRegionsToConfigurationPage.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pages/workspace/accounting/xero/XeroMapRegionsToConfigurationPage.tsx b/src/pages/workspace/accounting/xero/XeroMapRegionsToConfigurationPage.tsx index 17d8f5a9575a..b02a8aa7fd5d 100644 --- a/src/pages/workspace/accounting/xero/XeroMapRegionsToConfigurationPage.tsx +++ b/src/pages/workspace/accounting/xero/XeroMapRegionsToConfigurationPage.tsx @@ -16,7 +16,7 @@ import ROUTES from '@src/ROUTES'; function XeroMapRegionsToConfigurationPage({policy}: WithPolicyProps) { const {translate} = useLocalize(); const styles = useThemeStyles(); - + const policyID = policy?.id ?? ''; const category = getTrackingCategory(policy, CONST.XERO_CONFIG.TRACKING_CATEGORY_FIELDS.REGION); From 67630b47d7a80e9ac4b3cddf6bedea254fe0ceff Mon Sep 17 00:00:00 2001 From: Manan Jadhav Date: Mon, 6 May 2024 12:05:51 +0530 Subject: [PATCH 25/29] refactor: remove unnecessary code --- .../xero/XeroTrackingCategoryConfigurationPage.tsx | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/pages/workspace/accounting/xero/XeroTrackingCategoryConfigurationPage.tsx b/src/pages/workspace/accounting/xero/XeroTrackingCategoryConfigurationPage.tsx index 781fae4ff8a6..246e10611bcb 100644 --- a/src/pages/workspace/accounting/xero/XeroTrackingCategoryConfigurationPage.tsx +++ b/src/pages/workspace/accounting/xero/XeroTrackingCategoryConfigurationPage.tsx @@ -23,7 +23,6 @@ function XeroTrackingCategoryConfigurationPage({policy}: WithPolicyProps) { const styles = useThemeStyles(); const policyID = policy?.id ?? ''; const {importTrackingCategories, pendingFields} = policy?.connections?.xero?.config ?? {}; - const {trackingCategories} = policy?.connections?.xero?.data ?? {}; const menuItems: MenuItemProps[] = useMemo(() => { const availableCategories = []; @@ -38,7 +37,7 @@ function XeroTrackingCategoryConfigurationPage({policy}: WithPolicyProps) { }); } - if (trackingCategories?.find((category) => category.name.toLowerCase() === CONST.XERO_CONFIG.TRACKING_CATEGORY_FIELDS.REGION)) { + if (regionCategoryValue) { availableCategories.push({ description: translate('workspace.xero.mapXeroRegionsTo'), onPress: () => Navigation.navigate(ROUTES.POLICY_ACCOUNTING_XERO_TRACKING_CATEGORIES_MAP_REGION.getRoute(policyID)), @@ -46,7 +45,7 @@ function XeroTrackingCategoryConfigurationPage({policy}: WithPolicyProps) { }); } return availableCategories; - }, [translate, policy, policyID, trackingCategories]); + }, [translate, policy, policyID]); return ( Date: Mon, 6 May 2024 23:50:12 +0530 Subject: [PATCH 26/29] fix: added flex1 to container --- .../accounting/xero/XeroMapCostCentersToConfigurationPage.tsx | 1 + .../accounting/xero/XeroMapRegionsToConfigurationPage.tsx | 1 + 2 files changed, 2 insertions(+) diff --git a/src/pages/workspace/accounting/xero/XeroMapCostCentersToConfigurationPage.tsx b/src/pages/workspace/accounting/xero/XeroMapCostCentersToConfigurationPage.tsx index 4280bcedbf3e..160f8f5554a6 100644 --- a/src/pages/workspace/accounting/xero/XeroMapCostCentersToConfigurationPage.tsx +++ b/src/pages/workspace/accounting/xero/XeroMapCostCentersToConfigurationPage.tsx @@ -54,6 +54,7 @@ function XeroMapCostCentersToConfigurationPage({policy}: WithPolicyProps) { policyID={policyID && category?.id ? policyID : ''} featureName={CONST.POLICY.MORE_FEATURES.ARE_CONNECTIONS_ENABLED} titleStyle={[styles.pb2, styles.ph5]} + contentContainerStyle={[styles.flex1]} > Date: Tue, 7 May 2024 12:48:13 +0530 Subject: [PATCH 27/29] fix: use view for map field --- .../accounting/xero/XeroMapCostCentersToConfigurationPage.tsx | 1 + .../accounting/xero/XeroMapRegionsToConfigurationPage.tsx | 1 + 2 files changed, 2 insertions(+) diff --git a/src/pages/workspace/accounting/xero/XeroMapCostCentersToConfigurationPage.tsx b/src/pages/workspace/accounting/xero/XeroMapCostCentersToConfigurationPage.tsx index 160f8f5554a6..b4f0fe04f6ce 100644 --- a/src/pages/workspace/accounting/xero/XeroMapCostCentersToConfigurationPage.tsx +++ b/src/pages/workspace/accounting/xero/XeroMapCostCentersToConfigurationPage.tsx @@ -55,6 +55,7 @@ function XeroMapCostCentersToConfigurationPage({policy}: WithPolicyProps) { featureName={CONST.POLICY.MORE_FEATURES.ARE_CONNECTIONS_ENABLED} titleStyle={[styles.pb2, styles.ph5]} contentContainerStyle={[styles.flex1]} + shouldUseScrollView={false} > Date: Tue, 7 May 2024 21:42:47 +0530 Subject: [PATCH 28/29] fix: added isValidOption --- .../xero/XeroTrackingCategoryConfigurationPage.tsx | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/pages/workspace/accounting/xero/XeroTrackingCategoryConfigurationPage.tsx b/src/pages/workspace/accounting/xero/XeroTrackingCategoryConfigurationPage.tsx index 246e10611bcb..4043beb8b3ad 100644 --- a/src/pages/workspace/accounting/xero/XeroTrackingCategoryConfigurationPage.tsx +++ b/src/pages/workspace/accounting/xero/XeroTrackingCategoryConfigurationPage.tsx @@ -30,18 +30,20 @@ function XeroTrackingCategoryConfigurationPage({policy}: WithPolicyProps) { const costCenterCategoryValue = getTrackingCategory(policy, CONST.XERO_CONFIG.TRACKING_CATEGORY_FIELDS.COST_CENTERS)?.value ?? ''; const regionCategoryValue = getTrackingCategory(policy, CONST.XERO_CONFIG.TRACKING_CATEGORY_FIELDS.REGION)?.value ?? ''; if (costCenterCategoryValue) { + const isValidOption = Object.values(CONST.XERO_CONFIG.TRACKING_CATEGORY_OPTIONS).findIndex((option) => option.toLowerCase() === costCenterCategoryValue.toLowerCase()) > -1; availableCategories.push({ description: translate('workspace.xero.mapXeroCostCentersTo'), onPress: () => Navigation.navigate(ROUTES.POLICY_ACCOUNTING_XERO_TRACKING_CATEGORIES_MAP_COST_CENTERS.getRoute(policyID)), - title: translate(`workspace.xero.trackingCategoriesOptions.${costCenterCategoryValue.toLowerCase()}` as TranslationPaths), + title: isValidOption ? translate(`workspace.xero.trackingCategoriesOptions.${costCenterCategoryValue.toLowerCase()}` as TranslationPaths): '', }); } if (regionCategoryValue) { + const isValidOption = Object.values(CONST.XERO_CONFIG.TRACKING_CATEGORY_OPTIONS).findIndex((option) => option.toLowerCase() === regionCategoryValue.toLowerCase()) > -1; availableCategories.push({ description: translate('workspace.xero.mapXeroRegionsTo'), onPress: () => Navigation.navigate(ROUTES.POLICY_ACCOUNTING_XERO_TRACKING_CATEGORIES_MAP_REGION.getRoute(policyID)), - title: translate(`workspace.xero.trackingCategoriesOptions.${regionCategoryValue.toLowerCase()}` as TranslationPaths), + title: isValidOption ? translate(`workspace.xero.trackingCategoriesOptions.${regionCategoryValue.toLowerCase()}` as TranslationPaths): '', }); } return availableCategories; From 3dc105dfd6ba2fe0c722445e4b365d102f02246f Mon Sep 17 00:00:00 2001 From: Manan Jadhav Date: Tue, 7 May 2024 21:49:06 +0530 Subject: [PATCH 29/29] refactor: prettier fix --- .../accounting/xero/XeroTrackingCategoryConfigurationPage.tsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/pages/workspace/accounting/xero/XeroTrackingCategoryConfigurationPage.tsx b/src/pages/workspace/accounting/xero/XeroTrackingCategoryConfigurationPage.tsx index 4043beb8b3ad..195b93d3d73c 100644 --- a/src/pages/workspace/accounting/xero/XeroTrackingCategoryConfigurationPage.tsx +++ b/src/pages/workspace/accounting/xero/XeroTrackingCategoryConfigurationPage.tsx @@ -34,7 +34,7 @@ function XeroTrackingCategoryConfigurationPage({policy}: WithPolicyProps) { availableCategories.push({ description: translate('workspace.xero.mapXeroCostCentersTo'), onPress: () => Navigation.navigate(ROUTES.POLICY_ACCOUNTING_XERO_TRACKING_CATEGORIES_MAP_COST_CENTERS.getRoute(policyID)), - title: isValidOption ? translate(`workspace.xero.trackingCategoriesOptions.${costCenterCategoryValue.toLowerCase()}` as TranslationPaths): '', + title: isValidOption ? translate(`workspace.xero.trackingCategoriesOptions.${costCenterCategoryValue.toLowerCase()}` as TranslationPaths) : '', }); } @@ -43,7 +43,7 @@ function XeroTrackingCategoryConfigurationPage({policy}: WithPolicyProps) { availableCategories.push({ description: translate('workspace.xero.mapXeroRegionsTo'), onPress: () => Navigation.navigate(ROUTES.POLICY_ACCOUNTING_XERO_TRACKING_CATEGORIES_MAP_REGION.getRoute(policyID)), - title: isValidOption ? translate(`workspace.xero.trackingCategoriesOptions.${regionCategoryValue.toLowerCase()}` as TranslationPaths): '', + title: isValidOption ? translate(`workspace.xero.trackingCategoriesOptions.${regionCategoryValue.toLowerCase()}` as TranslationPaths) : '', }); } return availableCategories;