From 10cad3e8a1776cb92d935799378747d16d298303 Mon Sep 17 00:00:00 2001 From: Manan Jadhav Date: Sun, 30 Jun 2024 15:47:07 +0530 Subject: [PATCH 01/47] feat: route setup --- src/ROUTES.ts | 4 ++++ src/SCREENS.ts | 1 + .../AppNavigator/ModalStackNavigators/index.tsx | 1 + .../linkingConfig/FULL_SCREEN_TO_RHP_MAPPING.ts | 1 + src/libs/Navigation/linkingConfig/config.ts | 1 + src/libs/Navigation/types.ts | 4 ++++ .../netsuite/import/NetSuiteImportMappingPage.tsx | 13 +++++++++++++ .../netsuite/import/NetSuiteImportPage.tsx | 4 +++- 8 files changed, 28 insertions(+), 1 deletion(-) create mode 100644 src/pages/workspace/accounting/netsuite/import/NetSuiteImportMappingPage.tsx diff --git a/src/ROUTES.ts b/src/ROUTES.ts index 010a8c611cfc..b3d85ee8cebb 100644 --- a/src/ROUTES.ts +++ b/src/ROUTES.ts @@ -940,6 +940,10 @@ const ROUTES = { route: 'settings/workspaces/:policyID/accounting/netsuite/import', getRoute: (policyID: string) => `settings/workspaces/${policyID}/accounting/netsuite/import` as const, }, + POLICY_ACCOUNTING_NETSUITE_IMPORT_MAPPING: { + route: 'settings/workspaces/:policyID/accounting/netsuite/import/mapping/:importField', + getRoute: (policyID: string, importField: string) => `settings/workspaces/${policyID}/accounting/netsuite/import/mapping/${importField}` as const, + }, RESTRICTED_ACTION: { route: 'restricted-action/workspace/:policyID', getRoute: (policyID: string) => `restricted-action/workspace/${policyID}` as const, diff --git a/src/SCREENS.ts b/src/SCREENS.ts index d4b631f6d0fa..8a431b9f6008 100644 --- a/src/SCREENS.ts +++ b/src/SCREENS.ts @@ -274,6 +274,7 @@ const SCREENS = { XERO_EXPORT_BANK_ACCOUNT_SELECT: 'Policy_Accounting_Xero_Export_Bank_Account_Select', NETSUITE_SUBSIDIARY_SELECTOR: 'Policy_Accounting_Net_Suite_Subsidiary_Selector', NETSUITE_IMPORT: 'Policy_Accounting_Net_Suite_Import', + NETSUITE_IMPORT_MAPPING: 'Policy_Accounting_Net_Suite_Import_Mapping', SAGE_INTACCT_PREREQUISITES: 'Policy_Accounting_Sage_Intacct_Prerequisites', ENTER_SAGE_INTACCT_CREDENTIALS: 'Policy_Enter_Sage_Intacct_Credentials', EXISTING_SAGE_INTACCT_CONNECTIONS: 'Policy_Existing_Sage_Intacct_Connections', diff --git a/src/libs/Navigation/AppNavigator/ModalStackNavigators/index.tsx b/src/libs/Navigation/AppNavigator/ModalStackNavigators/index.tsx index bb08255780b5..6f5edc323a71 100644 --- a/src/libs/Navigation/AppNavigator/ModalStackNavigators/index.tsx +++ b/src/libs/Navigation/AppNavigator/ModalStackNavigators/index.tsx @@ -320,6 +320,7 @@ const SettingsModalStackNavigator = createModalStackNavigator('../../../../pages/workspace/accounting/xero/advanced/XeroBillPaymentAccountSelectorPage').default, [SCREENS.WORKSPACE.ACCOUNTING.NETSUITE_SUBSIDIARY_SELECTOR]: () => require('../../../../pages/workspace/accounting/netsuite/NetSuiteSubsidiarySelector').default, [SCREENS.WORKSPACE.ACCOUNTING.NETSUITE_IMPORT]: () => require('../../../../pages/workspace/accounting/netsuite/import/NetSuiteImportPage').default, + [SCREENS.WORKSPACE.ACCOUNTING.NETSUITE_IMPORT_MAPPING]: () => require('../../../../pages/workspace/accounting/netsuite/import/NetSuiteImportMappingPage').default, [SCREENS.WORKSPACE.ACCOUNTING.SAGE_INTACCT_PREREQUISITES]: () => require('../../../../pages/workspace/accounting/intacct/IntacctPrerequisitesPage').default, [SCREENS.WORKSPACE.ACCOUNTING.ENTER_SAGE_INTACCT_CREDENTIALS]: () => require('../../../../pages/workspace/accounting/intacct/EnterSageIntacctCredentialsPage').default, diff --git a/src/libs/Navigation/linkingConfig/FULL_SCREEN_TO_RHP_MAPPING.ts b/src/libs/Navigation/linkingConfig/FULL_SCREEN_TO_RHP_MAPPING.ts index 622aa61fb699..1534d88f6d4a 100755 --- a/src/libs/Navigation/linkingConfig/FULL_SCREEN_TO_RHP_MAPPING.ts +++ b/src/libs/Navigation/linkingConfig/FULL_SCREEN_TO_RHP_MAPPING.ts @@ -57,6 +57,7 @@ const FULL_SCREEN_TO_RHP_MAPPING: Partial> = { SCREENS.WORKSPACE.ACCOUNTING.XERO_EXPORT_BANK_ACCOUNT_SELECT, SCREENS.WORKSPACE.ACCOUNTING.NETSUITE_SUBSIDIARY_SELECTOR, SCREENS.WORKSPACE.ACCOUNTING.NETSUITE_IMPORT, + SCREENS.WORKSPACE.ACCOUNTING.NETSUITE_IMPORT_MAPPING, SCREENS.WORKSPACE.ACCOUNTING.SAGE_INTACCT_PREREQUISITES, SCREENS.WORKSPACE.ACCOUNTING.ENTER_SAGE_INTACCT_CREDENTIALS, SCREENS.WORKSPACE.ACCOUNTING.EXISTING_SAGE_INTACCT_CONNECTIONS, diff --git a/src/libs/Navigation/linkingConfig/config.ts b/src/libs/Navigation/linkingConfig/config.ts index b89f106edb1b..efeb70a96ba6 100644 --- a/src/libs/Navigation/linkingConfig/config.ts +++ b/src/libs/Navigation/linkingConfig/config.ts @@ -355,6 +355,7 @@ const config: LinkingOptions['config'] = { [SCREENS.WORKSPACE.ACCOUNTING.XERO_BILL_PAYMENT_ACCOUNT_SELECTOR]: {path: ROUTES.POLICY_ACCOUNTING_XERO_BILL_PAYMENT_ACCOUNT_SELECTOR.route}, [SCREENS.WORKSPACE.ACCOUNTING.NETSUITE_SUBSIDIARY_SELECTOR]: {path: ROUTES.POLICY_ACCOUNTING_NETSUITE_SUBSIDIARY_SELECTOR.route}, [SCREENS.WORKSPACE.ACCOUNTING.NETSUITE_IMPORT]: {path: ROUTES.POLICY_ACCOUNTING_NETSUITE_IMPORT.route}, + [SCREENS.WORKSPACE.ACCOUNTING.NETSUITE_IMPORT_MAPPING]: {path: ROUTES.POLICY_ACCOUNTING_NETSUITE_IMPORT_MAPPING.route}, [SCREENS.WORKSPACE.ACCOUNTING.SAGE_INTACCT_PREREQUISITES]: {path: ROUTES.POLICY_ACCOUNTING_SAGE_INTACCT_PREREQUISITES.route}, [SCREENS.WORKSPACE.ACCOUNTING.ENTER_SAGE_INTACCT_CREDENTIALS]: {path: ROUTES.POLICY_ACCOUNTING_SAGE_INTACCT_ENTER_CREDENTIALS.route}, [SCREENS.WORKSPACE.ACCOUNTING.EXISTING_SAGE_INTACCT_CONNECTIONS]: {path: ROUTES.POLICY_ACCOUNTING_SAGE_INTACCT_EXISTING_CONNECTIONS.route}, diff --git a/src/libs/Navigation/types.ts b/src/libs/Navigation/types.ts index 79e05b0ebc7d..db0be574468c 100644 --- a/src/libs/Navigation/types.ts +++ b/src/libs/Navigation/types.ts @@ -402,6 +402,10 @@ type SettingsNavigatorParamList = { [SCREENS.WORKSPACE.ACCOUNTING.NETSUITE_IMPORT]: { policyID: string; }; + [SCREENS.WORKSPACE.ACCOUNTING.NETSUITE_IMPORT_MAPPING]: { + policyID: string; + importField: string; + }; [SCREENS.GET_ASSISTANCE]: { backTo: Routes; }; diff --git a/src/pages/workspace/accounting/netsuite/import/NetSuiteImportMappingPage.tsx b/src/pages/workspace/accounting/netsuite/import/NetSuiteImportMappingPage.tsx new file mode 100644 index 000000000000..929c4f1a6432 --- /dev/null +++ b/src/pages/workspace/accounting/netsuite/import/NetSuiteImportMappingPage.tsx @@ -0,0 +1,13 @@ +import React from 'react'; +import withPolicyConnections from '@pages/workspace/withPolicyConnections'; +import type {WithPolicyConnectionsProps} from '@pages/workspace/withPolicyConnections'; + + +function NetSuiteImportMappingPage({policy, importField}: WithPolicyConnectionsProps & { importField: string}) { + const policyID = policy?.id ?? '-1'; + return <>Import Mapping Page {policyID} {importField} +} + +NetSuiteImportMappingPage.displayName = 'NetSuiteImportMappingPage'; + +export default withPolicyConnections(NetSuiteImportMappingPage); \ No newline at end of file diff --git a/src/pages/workspace/accounting/netsuite/import/NetSuiteImportPage.tsx b/src/pages/workspace/accounting/netsuite/import/NetSuiteImportPage.tsx index b7dff0a73fea..3b72dea20bda 100644 --- a/src/pages/workspace/accounting/netsuite/import/NetSuiteImportPage.tsx +++ b/src/pages/workspace/accounting/netsuite/import/NetSuiteImportPage.tsx @@ -12,6 +12,8 @@ import type {WithPolicyConnectionsProps} from '@pages/workspace/withPolicyConnec import ToggleSettingOptionRow from '@pages/workspace/workflows/ToggleSettingsOptionRow'; import * as Policy from '@userActions/Policy/Policy'; import CONST from '@src/CONST'; +import Navigation from '@libs/Navigation/Navigation'; +import ROUTES from '@src/ROUTES'; function NetSuiteImportPage({policy}: WithPolicyConnectionsProps) { const {translate} = useLocalize(); @@ -58,7 +60,7 @@ function NetSuiteImportPage({policy}: WithPolicyConnectionsProps) { title={translate(`workspace.accounting.importTypes.${config?.syncOptions?.mapping?.[importField] ?? CONST.INTEGRATION_ENTITY_MAP_TYPES.NETSUITE_DEFAULT}`)} shouldShowRightIcon onPress={() => { - // TODO: Navigation will be handled in future PRs + Navigation.navigate(ROUTES.POLICY_ACCOUNTING_NETSUITE_IMPORT_MAPPING.getRoute(policyID, importField)); }} brickRoadIndicator={config?.errorFields?.[importField] ? CONST.BRICK_ROAD_INDICATOR_STATUS.ERROR : undefined} /> From 9f82a3b289d6d9a0a037f0d50c803271a7faed85 Mon Sep 17 00:00:00 2001 From: Manan Jadhav Date: Sun, 30 Jun 2024 15:55:24 +0530 Subject: [PATCH 02/47] fix: import field param --- .../netsuite/import/NetSuiteImportMappingPage.tsx | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/pages/workspace/accounting/netsuite/import/NetSuiteImportMappingPage.tsx b/src/pages/workspace/accounting/netsuite/import/NetSuiteImportMappingPage.tsx index 929c4f1a6432..10f3d8f8b0d1 100644 --- a/src/pages/workspace/accounting/netsuite/import/NetSuiteImportMappingPage.tsx +++ b/src/pages/workspace/accounting/netsuite/import/NetSuiteImportMappingPage.tsx @@ -1,9 +1,17 @@ import React from 'react'; import withPolicyConnections from '@pages/workspace/withPolicyConnections'; import type {WithPolicyConnectionsProps} from '@pages/workspace/withPolicyConnections'; +import type {StackScreenProps} from '@react-navigation/stack'; +import type SCREENS from '@src/SCREENS'; +import type { SettingsNavigatorParamList } from '@libs/Navigation/types'; +type NetSuiteImportMappingPageProps = WithPolicyConnectionsProps & StackScreenProps; -function NetSuiteImportMappingPage({policy, importField}: WithPolicyConnectionsProps & { importField: string}) { +function NetSuiteImportMappingPage({policy, route: { + params: { + importField + } +}}: NetSuiteImportMappingPageProps) { const policyID = policy?.id ?? '-1'; return <>Import Mapping Page {policyID} {importField} } From ede7cc06965005366a2a211b9dd4e420618fea0d Mon Sep 17 00:00:00 2001 From: Manan Jadhav Date: Sun, 30 Jun 2024 16:08:57 +0530 Subject: [PATCH 03/47] feat: page header with selection list --- .../import/NetSuiteImportMappingPage.tsx | 55 +++++++++++++++++-- 1 file changed, 49 insertions(+), 6 deletions(-) diff --git a/src/pages/workspace/accounting/netsuite/import/NetSuiteImportMappingPage.tsx b/src/pages/workspace/accounting/netsuite/import/NetSuiteImportMappingPage.tsx index 10f3d8f8b0d1..634ac15517de 100644 --- a/src/pages/workspace/accounting/netsuite/import/NetSuiteImportMappingPage.tsx +++ b/src/pages/workspace/accounting/netsuite/import/NetSuiteImportMappingPage.tsx @@ -1,19 +1,62 @@ -import React from 'react'; +import React, { useMemo } from 'react'; import withPolicyConnections from '@pages/workspace/withPolicyConnections'; import type {WithPolicyConnectionsProps} from '@pages/workspace/withPolicyConnections'; -import type {StackScreenProps} from '@react-navigation/stack'; -import type SCREENS from '@src/SCREENS'; -import type { SettingsNavigatorParamList } from '@libs/Navigation/types'; +import SelectionScreen from '@components/SelectionScreen'; +import CONST from '@src/CONST'; +import RadioListItem from '@components/SelectionList/RadioListItem'; +import Text from '@components/Text'; +import { View } from 'react-native'; +import useThemeStyles from '@hooks/useThemeStyles'; +import useLocalize from '@hooks/useLocalize'; +import Navigation from '@libs/Navigation/Navigation'; +import type { TranslationPaths } from '@src/languages/types'; -type NetSuiteImportMappingPageProps = WithPolicyConnectionsProps & StackScreenProps; +type NetSuiteImportMappingPageProps = WithPolicyConnectionsProps & { + route: { + params: { + importField: string + } + } +}; function NetSuiteImportMappingPage({policy, route: { params: { importField } }}: NetSuiteImportMappingPageProps) { + const policyID = policy?.id ?? '-1'; - return <>Import Mapping Page {policyID} {importField} + const styles = useThemeStyles(); + const {translate} = useLocalize(); + + const listHeaderComponent = useMemo( + () => ( + + 'Description hre' + + ), + [styles.ph5, styles.mt2, styles.pb5, styles.mb4, translate, policyID], +); + +const titleKey = `workspace.netsuite.import.importFields.${importField}` as TranslationPaths; + + return ( + 0 ? [{data: subsidiaryListSections}] : []} + listItem={RadioListItem} + connectionName={CONST.POLICY.CONNECTIONS.NAME.NETSUITE} + onSelectRow={() => {}} + // initiallyFocusedOptionKey={netsuiteConfig?.subsidiaryID ?? subsidiaryListSections?.[0]?.keyForList} + headerContent={listHeaderComponent} + onBackButtonPress={() => Navigation.goBack()} + title={titleKey} + /> +); } NetSuiteImportMappingPage.displayName = 'NetSuiteImportMappingPage'; From 6d43b7f10773954b858d4c2898bec928d2867b19 Mon Sep 17 00:00:00 2001 From: Manan Jadhav Date: Mon, 1 Jul 2024 19:29:24 +0530 Subject: [PATCH 04/47] feat: populate the list with the options --- src/languages/en.ts | 39 +++++- .../import/NetSuiteImportMappingPage.tsx | 119 ++++++++++-------- .../netsuite/import/NetSuiteImportPage.tsx | 4 +- 3 files changed, 105 insertions(+), 57 deletions(-) diff --git a/src/languages/en.ts b/src/languages/en.ts index 299faadbd64e..3b92dce3f937 100755 --- a/src/languages/en.ts +++ b/src/languages/en.ts @@ -2208,17 +2208,46 @@ export default { expenseCategories: `Expense categories`, expenseCategoriesDescription: `NetSuite expense categories import into Expensify as categories.`, importFields: { - departments: 'Departments', - classes: 'Classes', - locations: 'Locations', - customers: 'Customers', - jobs: 'Projects (jobs)', + departments: { + title: 'Departments', + subtitle: 'Choose how to handle the NetSuite *departments* in Expensify.', + }, + classes: { + title: 'Classes', + subtitle: 'Choose how to handle *classes* in Expensify.', + }, + locations: { + title: 'Locations', + subtitle: 'Choose how to handle *locations* in Expensify.', + }, + customers: { + title: 'Customers', + subtitle: "Import *customers* into Expensify and choose how they'll be displayed.", + }, + jobs: { + title: 'Projects (jobs)', + subtitle: "Import *projects (jobs)* into Expensify and choose how they'll be displayed.", + }, }, importTaxDescription: 'Import tax groups from NetSuite', importCustomFields: { customSegments: 'Custom segments/records', customLists: 'Custom lists', }, + importTypes: { + [CONST.INTEGRATION_ENTITY_MAP_TYPES.TAG]: { + label: 'Tags', + description: 'Line-item level', + }, + [CONST.INTEGRATION_ENTITY_MAP_TYPES.REPORT_FIELD]: { + label: 'Report fields', + description: 'Report level', + }, + [CONST.INTEGRATION_ENTITY_MAP_TYPES.NETSUITE_DEFAULT]: { + label: 'NetSuite employee default', + description: 'Not imported into Expensify, applied on export', + }, + }, }, }, intacct: { diff --git a/src/pages/workspace/accounting/netsuite/import/NetSuiteImportMappingPage.tsx b/src/pages/workspace/accounting/netsuite/import/NetSuiteImportMappingPage.tsx index 634ac15517de..b3cccea1ade6 100644 --- a/src/pages/workspace/accounting/netsuite/import/NetSuiteImportMappingPage.tsx +++ b/src/pages/workspace/accounting/netsuite/import/NetSuiteImportMappingPage.tsx @@ -1,64 +1,83 @@ -import React, { useMemo } from 'react'; -import withPolicyConnections from '@pages/workspace/withPolicyConnections'; -import type {WithPolicyConnectionsProps} from '@pages/workspace/withPolicyConnections'; -import SelectionScreen from '@components/SelectionScreen'; -import CONST from '@src/CONST'; +import {ExpensiMark} from 'expensify-common'; +import React, {useMemo} from 'react'; +import {View} from 'react-native'; +import RenderHTML from '@components/RenderHTML'; import RadioListItem from '@components/SelectionList/RadioListItem'; -import Text from '@components/Text'; -import { View } from 'react-native'; -import useThemeStyles from '@hooks/useThemeStyles'; +import SelectionScreen from '@components/SelectionScreen'; import useLocalize from '@hooks/useLocalize'; +import useThemeStyles from '@hooks/useThemeStyles'; import Navigation from '@libs/Navigation/Navigation'; -import type { TranslationPaths } from '@src/languages/types'; +import withPolicyConnections from '@pages/workspace/withPolicyConnections'; +import type {WithPolicyConnectionsProps} from '@pages/workspace/withPolicyConnections'; +import CONST from '@src/CONST'; +import type {TranslationPaths} from '@src/languages/types'; + +const parser = new ExpensiMark(); type NetSuiteImportMappingPageProps = WithPolicyConnectionsProps & { - route: { - params: { - importField: string - } - } + route: { + params: { + importField: string; + }; + }; }; -function NetSuiteImportMappingPage({policy, route: { - params: { - importField - } -}}: NetSuiteImportMappingPageProps) { - - const policyID = policy?.id ?? '-1'; - const styles = useThemeStyles(); - const {translate} = useLocalize(); +function NetSuiteImportMappingPage({ + policy, + route: { + params: {importField}, + }, +}: NetSuiteImportMappingPageProps) { + const policyID = policy?.id ?? '-1'; + const styles = useThemeStyles(); + const {translate} = useLocalize(); + + const importMappings = policy?.connections?.netsuite?.options?.config?.syncOptions?.mapping; + + const importValue = importMappings?.[importField as keyof typeof importMappings] ?? CONST.INTEGRATION_ENTITY_MAP_TYPES.NETSUITE_DEFAULT; + + const listHeaderComponent = useMemo( + () => ( + + ${parser.replace(translate(`workspace.netsuite.import.importFields.${importField}.subtitle` as TranslationPaths))}`} + /> + + ), + [styles.ph5, styles.mt2, styles.mb4, translate, importField], + ); + + const inputOptions = [CONST.INTEGRATION_ENTITY_MAP_TYPES.NETSUITE_DEFAULT, CONST.INTEGRATION_ENTITY_MAP_TYPES.TAG, CONST.INTEGRATION_ENTITY_MAP_TYPES.REPORT_FIELD]; - const listHeaderComponent = useMemo( - () => ( - - 'Description hre' - - ), - [styles.ph5, styles.mt2, styles.pb5, styles.mb4, translate, policyID], -); + const inputSectionData = + inputOptions.map((inputOption) => ({ + text: translate(`workspace.netsuite.import.importTypes.${inputOption}.label`), + keyForList: inputOption, + isSelected: importValue === inputOption, + value: importValue, + alternateText: translate(`workspace.netsuite.import.importTypes.${inputOption}.description`), + })) ?? []; -const titleKey = `workspace.netsuite.import.importFields.${importField}` as TranslationPaths; + const titleKey = `workspace.netsuite.import.importFields.${importField}.title` as TranslationPaths; - return ( - 0 ? [{data: subsidiaryListSections}] : []} - listItem={RadioListItem} - connectionName={CONST.POLICY.CONNECTIONS.NAME.NETSUITE} - onSelectRow={() => {}} - // initiallyFocusedOptionKey={netsuiteConfig?.subsidiaryID ?? subsidiaryListSections?.[0]?.keyForList} - headerContent={listHeaderComponent} - onBackButtonPress={() => Navigation.goBack()} - title={titleKey} - /> -); + return ( + 0 ? [{data: inputSectionData}] : []} + listItem={RadioListItem} + connectionName={CONST.POLICY.CONNECTIONS.NAME.NETSUITE} + onSelectRow={() => {}} + initiallyFocusedOptionKey={inputSectionData.find((inputOption) => inputOption.isSelected)?.keyForList} + headerContent={listHeaderComponent} + onBackButtonPress={() => Navigation.goBack()} + title={titleKey} + /> + ); } NetSuiteImportMappingPage.displayName = 'NetSuiteImportMappingPage'; -export default withPolicyConnections(NetSuiteImportMappingPage); \ No newline at end of file +export default withPolicyConnections(NetSuiteImportMappingPage); diff --git a/src/pages/workspace/accounting/netsuite/import/NetSuiteImportPage.tsx b/src/pages/workspace/accounting/netsuite/import/NetSuiteImportPage.tsx index 3b72dea20bda..3f8db1ac87b2 100644 --- a/src/pages/workspace/accounting/netsuite/import/NetSuiteImportPage.tsx +++ b/src/pages/workspace/accounting/netsuite/import/NetSuiteImportPage.tsx @@ -7,12 +7,12 @@ import useLocalize from '@hooks/useLocalize'; import useThemeStyles from '@hooks/useThemeStyles'; import {updateNetSuiteSyncTaxConfiguration} from '@libs/actions/connections/NetSuiteCommands'; import * as ErrorUtils from '@libs/ErrorUtils'; +import Navigation from '@libs/Navigation/Navigation'; import withPolicyConnections from '@pages/workspace/withPolicyConnections'; import type {WithPolicyConnectionsProps} from '@pages/workspace/withPolicyConnections'; import ToggleSettingOptionRow from '@pages/workspace/workflows/ToggleSettingsOptionRow'; import * as Policy from '@userActions/Policy/Policy'; import CONST from '@src/CONST'; -import Navigation from '@libs/Navigation/Navigation'; import ROUTES from '@src/ROUTES'; function NetSuiteImportPage({policy}: WithPolicyConnectionsProps) { @@ -56,7 +56,7 @@ function NetSuiteImportPage({policy}: WithPolicyConnectionsProps) { onClose={() => Policy.clearNetSuiteErrorField(policyID, importField)} > { From 2c3923edfaabf20901778dfc678cc8cd116afb2f Mon Sep 17 00:00:00 2001 From: Manan Jadhav Date: Mon, 1 Jul 2024 20:01:50 +0530 Subject: [PATCH 05/47] feat: added the footer content --- src/components/SelectionScreen.tsx | 5 +++++ src/languages/en.ts | 13 ++++++++----- src/languages/es.ts | 1 - .../netsuite/import/NetSuiteImportMappingPage.tsx | 10 ++++++++++ .../netsuite/import/NetSuiteImportPage.tsx | 2 +- 5 files changed, 24 insertions(+), 7 deletions(-) diff --git a/src/components/SelectionScreen.tsx b/src/components/SelectionScreen.tsx index 3b5265685050..a3791b648df4 100644 --- a/src/components/SelectionScreen.tsx +++ b/src/components/SelectionScreen.tsx @@ -60,6 +60,9 @@ type SelectionScreenProps = { /** Name of the current connection */ connectionName: ConnectionName; + + /** Custom content to display in the footer of list component. */ + listFooterContent?: React.JSX.Element | null; }; function SelectionScreen({ @@ -77,6 +80,7 @@ function SelectionScreen({ featureName, shouldBeBlocked, connectionName, + listFooterContent }: SelectionScreenProps) { const {translate} = useLocalize(); @@ -107,6 +111,7 @@ function SelectionScreen({ shouldShowTooltips={false} initiallyFocusedOptionKey={initiallyFocusedOptionKey} listEmptyContent={listEmptyContent} + listFooterContent={listFooterContent} /> diff --git a/src/languages/en.ts b/src/languages/en.ts index 3b92dce3f937..4893c0fc1213 100755 --- a/src/languages/en.ts +++ b/src/languages/en.ts @@ -1,4 +1,5 @@ import {CONST as COMMON_CONST, Str} from 'expensify-common'; +import { startCase } from 'lodash'; import CONST from '@src/CONST'; import type {Country} from '@src/CONST'; import type {ConnectionName, PolicyConnectionSyncStage} from '@src/types/onyx/Policy'; @@ -2235,17 +2236,20 @@ export default { customLists: 'Custom lists', }, importTypes: { + [CONST.INTEGRATION_ENTITY_MAP_TYPES.NETSUITE_DEFAULT]: { + label: 'NetSuite employee default', + description: 'Not imported into Expensify, applied on export', + footerContent: (importField: string) => `If you use ${importField} in NetSuite, we'll apply the default set on the employee record upon export to Expense Report or Journal Entry.`, + }, [CONST.INTEGRATION_ENTITY_MAP_TYPES.TAG]: { label: 'Tags', description: 'Line-item level', + footerContent: (importField: string) => `${startCase(importField)} will be selectable for each individual expense on an employee's report.`, }, [CONST.INTEGRATION_ENTITY_MAP_TYPES.REPORT_FIELD]: { label: 'Report fields', description: 'Report level', - }, - [CONST.INTEGRATION_ENTITY_MAP_TYPES.NETSUITE_DEFAULT]: { - label: 'NetSuite employee default', - description: 'Not imported into Expensify, applied on export', + footerContent: (importField: string) => `${startCase(importField)} selection will apply to all expense on an employee's report.`, }, }, }, @@ -2560,7 +2564,6 @@ export default { [CONST.INTEGRATION_ENTITY_MAP_TYPES.NOT_IMPORTED]: 'Not imported', [CONST.INTEGRATION_ENTITY_MAP_TYPES.NONE]: 'Not imported', [CONST.INTEGRATION_ENTITY_MAP_TYPES.REPORT_FIELD]: 'Imported as report fields', - [CONST.INTEGRATION_ENTITY_MAP_TYPES.NETSUITE_DEFAULT]: 'NetSuite employee default', }, disconnectPrompt: (currentIntegration?: ConnectionName): string => { const integrationName = diff --git a/src/languages/es.ts b/src/languages/es.ts index e761089fe179..60fd4b52a45f 100644 --- a/src/languages/es.ts +++ b/src/languages/es.ts @@ -2503,7 +2503,6 @@ export default { [CONST.INTEGRATION_ENTITY_MAP_TYPES.NOT_IMPORTED]: 'No importado', [CONST.INTEGRATION_ENTITY_MAP_TYPES.NONE]: 'No importado', [CONST.INTEGRATION_ENTITY_MAP_TYPES.REPORT_FIELD]: 'Importado como campos de informe', - [CONST.INTEGRATION_ENTITY_MAP_TYPES.NETSUITE_DEFAULT]: 'NetSuite employee default', }, disconnectPrompt: (currentIntegration?: ConnectionName): string => { const integrationName = diff --git a/src/pages/workspace/accounting/netsuite/import/NetSuiteImportMappingPage.tsx b/src/pages/workspace/accounting/netsuite/import/NetSuiteImportMappingPage.tsx index b3cccea1ade6..358b3f5831f8 100644 --- a/src/pages/workspace/accounting/netsuite/import/NetSuiteImportMappingPage.tsx +++ b/src/pages/workspace/accounting/netsuite/import/NetSuiteImportMappingPage.tsx @@ -11,6 +11,7 @@ import withPolicyConnections from '@pages/workspace/withPolicyConnections'; import type {WithPolicyConnectionsProps} from '@pages/workspace/withPolicyConnections'; import CONST from '@src/CONST'; import type {TranslationPaths} from '@src/languages/types'; +import Text from '@components/Text'; const parser = new ExpensiMark(); @@ -36,6 +37,14 @@ function NetSuiteImportMappingPage({ const importValue = importMappings?.[importField as keyof typeof importMappings] ?? CONST.INTEGRATION_ENTITY_MAP_TYPES.NETSUITE_DEFAULT; + const listFooterContent = useMemo(() => ( + + + {translate(`workspace.netsuite.import.importTypes.${importValue}.footerContent` as TranslationPaths, importField)} + + + ), [importField, importValue, styles.mb4, styles.mt2, styles.ph5, translate]); + const listHeaderComponent = useMemo( () => ( @@ -74,6 +83,7 @@ function NetSuiteImportMappingPage({ headerContent={listHeaderComponent} onBackButtonPress={() => Navigation.goBack()} title={titleKey} + listFooterContent={listFooterContent} /> ); } diff --git a/src/pages/workspace/accounting/netsuite/import/NetSuiteImportPage.tsx b/src/pages/workspace/accounting/netsuite/import/NetSuiteImportPage.tsx index 3f8db1ac87b2..4d380e24351e 100644 --- a/src/pages/workspace/accounting/netsuite/import/NetSuiteImportPage.tsx +++ b/src/pages/workspace/accounting/netsuite/import/NetSuiteImportPage.tsx @@ -57,7 +57,7 @@ function NetSuiteImportPage({policy}: WithPolicyConnectionsProps) { > { Navigation.navigate(ROUTES.POLICY_ACCOUNTING_NETSUITE_IMPORT_MAPPING.getRoute(policyID, importField)); From c14773620c4a9e3c4d025e1a6a330b161e166184 Mon Sep 17 00:00:00 2001 From: Manan Jadhav Date: Tue, 2 Jul 2024 02:49:15 +0530 Subject: [PATCH 06/47] fix: remove duplicate props --- src/components/SelectionScreen.tsx | 4 ---- 1 file changed, 4 deletions(-) diff --git a/src/components/SelectionScreen.tsx b/src/components/SelectionScreen.tsx index c0b9eac8e7da..af1cdfd171ea 100644 --- a/src/components/SelectionScreen.tsx +++ b/src/components/SelectionScreen.tsx @@ -63,9 +63,6 @@ type SelectionScreenProps = { /** Name of the current connection */ connectionName: ConnectionName; - - /** Custom content to display in the footer of list component. */ - listFooterContent?: React.JSX.Element | null; }; function SelectionScreen({ @@ -84,7 +81,6 @@ function SelectionScreen({ featureName, shouldBeBlocked, connectionName, - listFooterContent }: SelectionScreenProps) { const {translate} = useLocalize(); From b332bfaef84f762c5bdba75b1449d95de63d8c4c Mon Sep 17 00:00:00 2001 From: Manan Jadhav Date: Tue, 2 Jul 2024 07:04:01 +0530 Subject: [PATCH 07/47] feat: added spanish translations --- src/languages/es.ts | 42 +++++++++++++++++++++++++++++++++++++----- 1 file changed, 37 insertions(+), 5 deletions(-) diff --git a/src/languages/es.ts b/src/languages/es.ts index 82940404458e..e1c74e3a320b 100644 --- a/src/languages/es.ts +++ b/src/languages/es.ts @@ -2328,17 +2328,49 @@ export default { expenseCategories: 'Categorías de gastos', expenseCategoriesDescription: 'Las categorías de gastos de NetSuite se importan a Expensify como categorías.', importFields: { - departments: 'Departamentos', - classes: 'Clases', - locations: 'Ubicaciones', - customers: 'Clientes', - jobs: 'Proyectos (trabajos)', + departments: { + title: 'Departamentos', + subtitle: 'Elige cómo manejar los *departamentos* de NetSuite en Expensify.', + }, + classes: { + title: 'Clases', + subtitle: 'Elige cómo manejar las *clases* en Expensify.', + }, + locations: { + title: 'Ubicaciones', + subtitle: 'Elija cómo manejar *ubicaciones* en Expensify.', + }, + customers: { + title: 'Clientes', + subtitle: "Importa *clientes* a Expensify y elige cómo se mostrarán.", + }, + jobs: { + title: 'Proyectos (trabajos)', + subtitle: "Importa *proyectos (trabajos)* a Expensify y elige cómo se mostrarán.", + }, }, importTaxDescription: 'Importar grupos de impuestos desde NetSuite', importCustomFields: { customSegments: 'Segmentos/registros personalizado', customLists: 'Listas personalizado', }, + importTypes: { + [CONST.INTEGRATION_ENTITY_MAP_TYPES.NETSUITE_DEFAULT]: { + label: 'Predeterminado del empleado NetSuite', + description: 'No importado a Expensify, aplicado en exportación', + footerContent: (importField: string) => `Si usa ${importField} en NetSuite, aplicaremos el conjunto predeterminado en el registro del empleado al exportarlo a Informe de gastos o Entrada de diario.`, + }, + [CONST.INTEGRATION_ENTITY_MAP_TYPES.TAG]: { + label: 'Etiquetas', + description: 'Nivel de línea de pedido', + footerContent: (importField: string) => `Se podrán seleccionar ${importField} para cada gasto individual en el informe de un empleado.`, + }, + [CONST.INTEGRATION_ENTITY_MAP_TYPES.REPORT_FIELD]: { + label: 'Campos de informe', + description: 'Nivel de informe', + footerContent: (importField: string) => `La selección de ${importField} se aplicará a todos los gastos en el informe de un empleado.`, + }, + }, }, }, intacct: { From e15f141cc5a9e814f4155b8d3fbff23be8605686 Mon Sep 17 00:00:00 2001 From: Manan Jadhav Date: Tue, 2 Jul 2024 14:39:24 +0530 Subject: [PATCH 08/47] fix: added api commands --- src/libs/API/types.ts | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/libs/API/types.ts b/src/libs/API/types.ts index 0acfc2319e69..2aef5d8a0f02 100644 --- a/src/libs/API/types.ts +++ b/src/libs/API/types.ts @@ -231,6 +231,11 @@ const WRITE_COMMANDS = { UPDATE_SUBSCRIPTION_SIZE: 'UpdateSubscriptionSize', UPDATE_NETSUITE_SUBSIDIARY: 'UpdateNetSuiteSubsidiary', UPDATE_NETSUITE_SYNC_TAX_CONFIGURATION: 'UpdateNetSuiteSyncTaxConfiguration', + UPDATE_NETSUITE_DEPARTMENTS_MAPPING: 'UpdateNetSuiteDepartmentsMapping', + UPDATE_NETSUITE_CLASSES_MAPPING: 'UpdateNetSuiteClassesMapping', + UPDATE_NETSUITE_LOCATIONS_MAPPING: 'UpdateNetSuiteLocationsMapping', + UPDATE_NETSUITE_CUSTOMERS_MAPPING: 'UpdateNetSuiteCustomersMapping', + UPDATE_NETSUITE_JOBS_MAPPING: 'UpdateNetSuiteJobsMapping', UPDATE_NETSUITE_EXPORTER: 'UpdateNetSuiteExporter', UPDATE_NETSUITE_EXPORT_DATE: 'UpdateNetSuiteExportDate', UPDATE_NETSUITE_REIMBURSABLE_EXPENSES_EXPORT_DESTINATION: 'UpdateNetSuiteReimbursableExpensesExportDestination', @@ -481,6 +486,11 @@ type WriteCommandParameters = { // Netsuite parameters [WRITE_COMMANDS.UPDATE_NETSUITE_SUBSIDIARY]: Parameters.UpdateNetSuiteSubsidiaryParams; [WRITE_COMMANDS.UPDATE_NETSUITE_SYNC_TAX_CONFIGURATION]: Parameters.UpdateNetSuiteGenericTypeParams<'enabled', boolean>; + [WRITE_COMMANDS.UPDATE_NETSUITE_DEPARTMENTS_MAPPING]: Parameters.UpdateNetSuiteGenericTypeParams<'mapping', ValueOf>; + [WRITE_COMMANDS.UPDATE_NETSUITE_CLASSES_MAPPING]: Parameters.UpdateNetSuiteGenericTypeParams<'mapping', ValueOf>; + [WRITE_COMMANDS.UPDATE_NETSUITE_LOCATIONS_MAPPING]: Parameters.UpdateNetSuiteGenericTypeParams<'mapping', ValueOf>; + [WRITE_COMMANDS.UPDATE_NETSUITE_CUSTOMERS_MAPPING]: Parameters.UpdateNetSuiteGenericTypeParams<'mapping', ValueOf>; + [WRITE_COMMANDS.UPDATE_NETSUITE_JOBS_MAPPING]: Parameters.UpdateNetSuiteGenericTypeParams<'mapping', ValueOf>; [WRITE_COMMANDS.UPDATE_NETSUITE_EXPORTER]: Parameters.UpdateNetSuiteGenericTypeParams<'email', string>; [WRITE_COMMANDS.UPDATE_NETSUITE_EXPORT_DATE]: Parameters.UpdateNetSuiteGenericTypeParams<'value', ValueOf>; [WRITE_COMMANDS.UPDATE_NETSUITE_REIMBURSABLE_EXPENSES_EXPORT_DESTINATION]: Parameters.UpdateNetSuiteGenericTypeParams<'value', ValueOf>; From bb8bcbadb86310fa0a5e9d6b39611f6aad729746 Mon Sep 17 00:00:00 2001 From: Manan Jadhav Date: Tue, 2 Jul 2024 15:48:35 +0530 Subject: [PATCH 09/47] feat: added api call and fix footer content --- src/languages/en.ts | 5 +- src/languages/es.ts | 7 +- src/libs/Navigation/types.ts | 2 +- .../actions/connections/NetSuiteCommands.ts | 102 ++++++++++++++++++ .../import/NetSuiteImportMappingPage.tsx | 13 +-- .../netsuite/import/NetSuiteImportPage.tsx | 4 +- 6 files changed, 120 insertions(+), 13 deletions(-) diff --git a/src/languages/en.ts b/src/languages/en.ts index 9aa8f6f0f273..b695a3f48705 100755 --- a/src/languages/en.ts +++ b/src/languages/en.ts @@ -1,5 +1,5 @@ import {CONST as COMMON_CONST, Str} from 'expensify-common'; -import { startCase } from 'lodash'; +import {startCase} from 'lodash'; import CONST from '@src/CONST'; import type {Country} from '@src/CONST'; import type {ConnectionName, PolicyConnectionSyncStage} from '@src/types/onyx/Policy'; @@ -2326,7 +2326,8 @@ export default { [CONST.INTEGRATION_ENTITY_MAP_TYPES.NETSUITE_DEFAULT]: { label: 'NetSuite employee default', description: 'Not imported into Expensify, applied on export', - footerContent: (importField: string) => `If you use ${importField} in NetSuite, we'll apply the default set on the employee record upon export to Expense Report or Journal Entry.`, + footerContent: (importField: string) => + `If you use ${importField} in NetSuite, we'll apply the default set on the employee record upon export to Expense Report or Journal Entry.`, }, [CONST.INTEGRATION_ENTITY_MAP_TYPES.TAG]: { label: 'Tags', diff --git a/src/languages/es.ts b/src/languages/es.ts index e1c74e3a320b..fa58631db912 100644 --- a/src/languages/es.ts +++ b/src/languages/es.ts @@ -2342,11 +2342,11 @@ export default { }, customers: { title: 'Clientes', - subtitle: "Importa *clientes* a Expensify y elige cómo se mostrarán.", + subtitle: 'Importa *clientes* a Expensify y elige cómo se mostrarán.', }, jobs: { title: 'Proyectos (trabajos)', - subtitle: "Importa *proyectos (trabajos)* a Expensify y elige cómo se mostrarán.", + subtitle: 'Importa *proyectos (trabajos)* a Expensify y elige cómo se mostrarán.', }, }, importTaxDescription: 'Importar grupos de impuestos desde NetSuite', @@ -2358,7 +2358,8 @@ export default { [CONST.INTEGRATION_ENTITY_MAP_TYPES.NETSUITE_DEFAULT]: { label: 'Predeterminado del empleado NetSuite', description: 'No importado a Expensify, aplicado en exportación', - footerContent: (importField: string) => `Si usa ${importField} en NetSuite, aplicaremos el conjunto predeterminado en el registro del empleado al exportarlo a Informe de gastos o Entrada de diario.`, + footerContent: (importField: string) => + `Si usa ${importField} en NetSuite, aplicaremos el conjunto predeterminado en el registro del empleado al exportarlo a Informe de gastos o Entrada de diario.`, }, [CONST.INTEGRATION_ENTITY_MAP_TYPES.TAG]: { label: 'Etiquetas', diff --git a/src/libs/Navigation/types.ts b/src/libs/Navigation/types.ts index 2d2251cf9cdf..4057ce33e80e 100644 --- a/src/libs/Navigation/types.ts +++ b/src/libs/Navigation/types.ts @@ -405,7 +405,7 @@ type SettingsNavigatorParamList = { [SCREENS.WORKSPACE.ACCOUNTING.NETSUITE_IMPORT_MAPPING]: { policyID: string; importField: string; - }, + }; [SCREENS.WORKSPACE.ACCOUNTING.NETSUITE_EXPORT]: { policyID: string; }; diff --git a/src/libs/actions/connections/NetSuiteCommands.ts b/src/libs/actions/connections/NetSuiteCommands.ts index 1f35d19a313e..cc47986f0623 100644 --- a/src/libs/actions/connections/NetSuiteCommands.ts +++ b/src/libs/actions/connections/NetSuiteCommands.ts @@ -177,6 +177,107 @@ function updateNetSuiteSubsidiary(policyID: string, newSubsidiary: SubsidiaryPar API.write(WRITE_COMMANDS.UPDATE_NETSUITE_SUBSIDIARY, params, onyxData); } +function updateNetSuiteImportMapping( + policyID: string, + mappingName: TMappingName, + mappingValue: ValueOf, + oldMappingValue: ValueOf, +) { + const onyxData: OnyxData = { + optimisticData: [ + { + onyxMethod: Onyx.METHOD.MERGE, + key: `${ONYXKEYS.COLLECTION.POLICY}${policyID}`, + value: { + connections: { + netsuite: { + options: { + config: { + syncOptions: { + mapping: { + [mappingName]: mappingValue, + }, + }, + }, + }, + }, + }, + }, + }, + ], + successData: [ + { + onyxMethod: Onyx.METHOD.MERGE, + key: `${ONYXKEYS.COLLECTION.POLICY}${policyID}`, + value: { + connections: { + netsuite: { + options: { + config: { + syncOptions: { + mapping: { + [mappingName]: mappingValue, + }, + }, + }, + }, + }, + }, + }, + }, + ], + failureData: [ + { + onyxMethod: Onyx.METHOD.MERGE, + key: `${ONYXKEYS.COLLECTION.POLICY}${policyID}`, + value: { + connections: { + netsuite: { + options: { + config: { + syncOptions: { + mapping: { + [mappingName]: oldMappingValue, + }, + }, + }, + }, + }, + }, + }, + }, + ], + }; + + const params = { + policyID, + mapping: mappingValue, + }; + + let commandName; + switch (mappingName) { + case 'departments': + commandName = WRITE_COMMANDS.UPDATE_NETSUITE_DEPARTMENTS_MAPPING; + break; + case 'classes': + commandName = WRITE_COMMANDS.UPDATE_NETSUITE_CLASSES_MAPPING; + break; + case 'locations': + commandName = WRITE_COMMANDS.UPDATE_NETSUITE_LOCATIONS_MAPPING; + break; + case 'customers': + commandName = WRITE_COMMANDS.UPDATE_NETSUITE_CUSTOMERS_MAPPING; + break; + case 'jobs': + commandName = WRITE_COMMANDS.UPDATE_NETSUITE_JOBS_MAPPING; + break; + default: + return; + } + + API.write(commandName, params, onyxData); +} + function updateNetSuiteSyncTaxConfiguration(policyID: string, isSyncTaxEnabled: boolean) { const onyxData: OnyxData = { optimisticData: [ @@ -447,4 +548,5 @@ export { updateNetSuiteProvincialTaxPostingAccount, updateNetSuiteAllowForeignCurrency, updateNetSuiteExportToNextOpenPeriod, + updateNetSuiteImportMapping, }; diff --git a/src/pages/workspace/accounting/netsuite/import/NetSuiteImportMappingPage.tsx b/src/pages/workspace/accounting/netsuite/import/NetSuiteImportMappingPage.tsx index 358b3f5831f8..f28c443c9701 100644 --- a/src/pages/workspace/accounting/netsuite/import/NetSuiteImportMappingPage.tsx +++ b/src/pages/workspace/accounting/netsuite/import/NetSuiteImportMappingPage.tsx @@ -4,6 +4,7 @@ import {View} from 'react-native'; import RenderHTML from '@components/RenderHTML'; import RadioListItem from '@components/SelectionList/RadioListItem'; import SelectionScreen from '@components/SelectionScreen'; +import Text from '@components/Text'; import useLocalize from '@hooks/useLocalize'; import useThemeStyles from '@hooks/useThemeStyles'; import Navigation from '@libs/Navigation/Navigation'; @@ -11,7 +12,6 @@ import withPolicyConnections from '@pages/workspace/withPolicyConnections'; import type {WithPolicyConnectionsProps} from '@pages/workspace/withPolicyConnections'; import CONST from '@src/CONST'; import type {TranslationPaths} from '@src/languages/types'; -import Text from '@components/Text'; const parser = new ExpensiMark(); @@ -37,13 +37,14 @@ function NetSuiteImportMappingPage({ const importValue = importMappings?.[importField as keyof typeof importMappings] ?? CONST.INTEGRATION_ENTITY_MAP_TYPES.NETSUITE_DEFAULT; - const listFooterContent = useMemo(() => ( + const listFooterContent = useMemo( + () => ( - - {translate(`workspace.netsuite.import.importTypes.${importValue}.footerContent` as TranslationPaths, importField)} - + {translate(`workspace.netsuite.import.importTypes.${importValue}.footerContent` as TranslationPaths, importField)} - ), [importField, importValue, styles.mb4, styles.mt2, styles.ph5, translate]); + ), + [importField, importValue, styles.mb4, styles.mt2, styles.ph5, translate], + ); const listHeaderComponent = useMemo( () => ( diff --git a/src/pages/workspace/accounting/netsuite/import/NetSuiteImportPage.tsx b/src/pages/workspace/accounting/netsuite/import/NetSuiteImportPage.tsx index 07c46d7918e4..b2c39face4eb 100644 --- a/src/pages/workspace/accounting/netsuite/import/NetSuiteImportPage.tsx +++ b/src/pages/workspace/accounting/netsuite/import/NetSuiteImportPage.tsx @@ -59,7 +59,9 @@ function NetSuiteImportPage({policy}: WithPolicyConnectionsProps) { > { Navigation.navigate(ROUTES.POLICY_ACCOUNTING_NETSUITE_IMPORT_MAPPING.getRoute(policyID, importField)); From c82dcb06ecdc2610a42c74c64355855550c466f5 Mon Sep 17 00:00:00 2001 From: Manan Jadhav Date: Tue, 2 Jul 2024 17:00:26 +0530 Subject: [PATCH 10/47] feat: added api call --- .../import/NetSuiteImportMappingPage.tsx | 20 +++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/src/pages/workspace/accounting/netsuite/import/NetSuiteImportMappingPage.tsx b/src/pages/workspace/accounting/netsuite/import/NetSuiteImportMappingPage.tsx index f28c443c9701..1d24e4d3f2a5 100644 --- a/src/pages/workspace/accounting/netsuite/import/NetSuiteImportMappingPage.tsx +++ b/src/pages/workspace/accounting/netsuite/import/NetSuiteImportMappingPage.tsx @@ -3,7 +3,9 @@ import React, {useMemo} from 'react'; import {View} from 'react-native'; import RenderHTML from '@components/RenderHTML'; import RadioListItem from '@components/SelectionList/RadioListItem'; +import type { SelectorType } from '@components/SelectionScreen'; import SelectionScreen from '@components/SelectionScreen'; +import {updateNetSuiteImportMapping} from '@libs/actions/connections/NetSuiteCommands'; import Text from '@components/Text'; import useLocalize from '@hooks/useLocalize'; import useThemeStyles from '@hooks/useThemeStyles'; @@ -40,7 +42,7 @@ function NetSuiteImportMappingPage({ const listFooterContent = useMemo( () => ( - {translate(`workspace.netsuite.import.importTypes.${importValue}.footerContent` as TranslationPaths, importField)} + {translate(`workspace.netsuite.import.importTypes.${importValue}.footerContent`, importField)} ), [importField, importValue, styles.mb4, styles.mt2, styles.ph5, translate], @@ -70,6 +72,20 @@ function NetSuiteImportMappingPage({ const titleKey = `workspace.netsuite.import.importFields.${importField}.title` as TranslationPaths; + const updateImportMapping = ({keyForList}: SelectorType) => { + if (!keyForList || keyForList === importValue) { + return; + } + + updateNetSuiteImportMapping( + policyID, + importField as keyof typeof importMappings, + keyForList, + importValue + ); + Navigation.goBack(); + }; + return ( 0 ? [{data: inputSectionData}] : []} listItem={RadioListItem} connectionName={CONST.POLICY.CONNECTIONS.NAME.NETSUITE} - onSelectRow={() => {}} + onSelectRow={updateImportMapping} initiallyFocusedOptionKey={inputSectionData.find((inputOption) => inputOption.isSelected)?.keyForList} headerContent={listHeaderComponent} onBackButtonPress={() => Navigation.goBack()} From 6d60f4dd1714f494aa5763aa2c13526254a59d32 Mon Sep 17 00:00:00 2001 From: Manan Jadhav Date: Tue, 2 Jul 2024 17:10:25 +0530 Subject: [PATCH 11/47] refactor: fix types --- .../import/NetSuiteImportMappingPage.tsx | 21 ++++++++++++------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/src/pages/workspace/accounting/netsuite/import/NetSuiteImportMappingPage.tsx b/src/pages/workspace/accounting/netsuite/import/NetSuiteImportMappingPage.tsx index 1d24e4d3f2a5..d945b8ed78bf 100644 --- a/src/pages/workspace/accounting/netsuite/import/NetSuiteImportMappingPage.tsx +++ b/src/pages/workspace/accounting/netsuite/import/NetSuiteImportMappingPage.tsx @@ -1,5 +1,5 @@ import {ExpensiMark} from 'expensify-common'; -import React, {useMemo} from 'react'; +import React, {useCallback, useMemo} from 'react'; import {View} from 'react-native'; import RenderHTML from '@components/RenderHTML'; import RadioListItem from '@components/SelectionList/RadioListItem'; @@ -14,6 +14,7 @@ import withPolicyConnections from '@pages/workspace/withPolicyConnections'; import type {WithPolicyConnectionsProps} from '@pages/workspace/withPolicyConnections'; import CONST from '@src/CONST'; import type {TranslationPaths} from '@src/languages/types'; +import type {ValueOf} from 'type-fest'; const parser = new ExpensiMark(); @@ -25,6 +26,10 @@ type NetSuiteImportMappingPageProps = WithPolicyConnectionsProps & { }; }; +type ImportListItem = SelectorType & { + value: ValueOf; +} + function NetSuiteImportMappingPage({ policy, route: { @@ -61,30 +66,30 @@ function NetSuiteImportMappingPage({ const inputOptions = [CONST.INTEGRATION_ENTITY_MAP_TYPES.NETSUITE_DEFAULT, CONST.INTEGRATION_ENTITY_MAP_TYPES.TAG, CONST.INTEGRATION_ENTITY_MAP_TYPES.REPORT_FIELD]; - const inputSectionData = + const inputSectionData: ImportListItem[] = inputOptions.map((inputOption) => ({ text: translate(`workspace.netsuite.import.importTypes.${inputOption}.label`), keyForList: inputOption, isSelected: importValue === inputOption, - value: importValue, + value: inputOption, alternateText: translate(`workspace.netsuite.import.importTypes.${inputOption}.description`), })) ?? []; const titleKey = `workspace.netsuite.import.importFields.${importField}.title` as TranslationPaths; - const updateImportMapping = ({keyForList}: SelectorType) => { - if (!keyForList || keyForList === importValue) { + const updateImportMapping = useCallback(({value}: ImportListItem) => { + if (!value || value === importValue) { return; } updateNetSuiteImportMapping( policyID, importField as keyof typeof importMappings, - keyForList, + value, importValue ); Navigation.goBack(); - }; + },[importField, importValue, policyID]); return ( 0 ? [{data: inputSectionData}] : []} listItem={RadioListItem} connectionName={CONST.POLICY.CONNECTIONS.NAME.NETSUITE} - onSelectRow={updateImportMapping} + onSelectRow={(selection: SelectorType) => updateImportMapping(selection as ImportListItem)} initiallyFocusedOptionKey={inputSectionData.find((inputOption) => inputOption.isSelected)?.keyForList} headerContent={listHeaderComponent} onBackButtonPress={() => Navigation.goBack()} From 7222bac526737910730bbdc953b6b692d4ee5f33 Mon Sep 17 00:00:00 2001 From: Manan Jadhav Date: Tue, 2 Jul 2024 17:26:26 +0530 Subject: [PATCH 12/47] refactor: adjusted offline types --- .../actions/connections/NetSuiteCommands.ts | 18 ++++++++++++++++++ src/types/onyx/Policy.ts | 6 +++--- 2 files changed, 21 insertions(+), 3 deletions(-) diff --git a/src/libs/actions/connections/NetSuiteCommands.ts b/src/libs/actions/connections/NetSuiteCommands.ts index cc47986f0623..2704becdf79f 100644 --- a/src/libs/actions/connections/NetSuiteCommands.ts +++ b/src/libs/actions/connections/NetSuiteCommands.ts @@ -197,6 +197,12 @@ function updateNetSuiteImportMapping; /** Whther to automatically create employees and vendors upon export in NetSuite if they don't exist */ autoCreateEntities: boolean; From 2cf060a53f85ba38c143e10f42a25eab7ed5418e Mon Sep 17 00:00:00 2001 From: Manan Jadhav Date: Tue, 2 Jul 2024 17:28:35 +0530 Subject: [PATCH 13/47] fix: offline types for syncTax --- .../actions/connections/NetSuiteCommands.ts | 30 ++++++++++--------- 1 file changed, 16 insertions(+), 14 deletions(-) diff --git a/src/libs/actions/connections/NetSuiteCommands.ts b/src/libs/actions/connections/NetSuiteCommands.ts index 2704becdf79f..c13092133c40 100644 --- a/src/libs/actions/connections/NetSuiteCommands.ts +++ b/src/libs/actions/connections/NetSuiteCommands.ts @@ -309,10 +309,10 @@ function updateNetSuiteSyncTaxConfiguration(policyID: string, isSyncTaxEnabled: config: { syncOptions: { syncTax: isSyncTaxEnabled, + pendingFields: { + syncTax: CONST.RED_BRICK_ROAD_PENDING_ACTION.UPDATE, + }, }, - // pendingFields: { - // syncTax: CONST.RED_BRICK_ROAD_PENDING_ACTION.UPDATE, - // }, errorFields: { syncTax: null, }, @@ -334,10 +334,10 @@ function updateNetSuiteSyncTaxConfiguration(policyID: string, isSyncTaxEnabled: config: { syncOptions: { syncTax: isSyncTaxEnabled, + pendingFields: { + syncTax: null, + }, }, - // pendingFields: { - // syncTax: null - // }, errorFields: { syncTax: null, }, @@ -357,14 +357,16 @@ function updateNetSuiteSyncTaxConfiguration(policyID: string, isSyncTaxEnabled: netsuite: { options: { config: { - syncOptions: { - syncTax: !isSyncTaxEnabled, - }, - // pendingFields: { - // syncTax: null, - // }, - errorFields: { - syncTax: ErrorUtils.getMicroSecondOnyxErrorWithTranslationKey('common.genericErrorMessage'), + config: { + syncOptions: { + syncTax: !isSyncTaxEnabled, + pendingFields: { + syncTax: null, + }, + }, + errorFields: { + syncTax: ErrorUtils.getMicroSecondOnyxErrorWithTranslationKey('common.genericErrorMessage'), + }, }, }, }, From 023b21d2515dee0670b73b44aa593deee1f10697 Mon Sep 17 00:00:00 2001 From: Manan Jadhav Date: Tue, 2 Jul 2024 17:30:36 +0530 Subject: [PATCH 14/47] refactor: run prettier --- .../actions/connections/NetSuiteCommands.ts | 22 ++++++------- .../import/NetSuiteImportMappingPage.tsx | 32 +++++++++---------- src/types/onyx/Policy.ts | 2 +- 3 files changed, 26 insertions(+), 30 deletions(-) diff --git a/src/libs/actions/connections/NetSuiteCommands.ts b/src/libs/actions/connections/NetSuiteCommands.ts index c13092133c40..b8d10ee843c5 100644 --- a/src/libs/actions/connections/NetSuiteCommands.ts +++ b/src/libs/actions/connections/NetSuiteCommands.ts @@ -202,7 +202,7 @@ function updateNetSuiteImportMapping; -} +}; function NetSuiteImportMappingPage({ policy, @@ -77,19 +77,17 @@ function NetSuiteImportMappingPage({ const titleKey = `workspace.netsuite.import.importFields.${importField}.title` as TranslationPaths; - const updateImportMapping = useCallback(({value}: ImportListItem) => { - if (!value || value === importValue) { - return; - } - - updateNetSuiteImportMapping( - policyID, - importField as keyof typeof importMappings, - value, - importValue - ); - Navigation.goBack(); - },[importField, importValue, policyID]); + const updateImportMapping = useCallback( + ({value}: ImportListItem) => { + if (!value || value === importValue) { + return; + } + + updateNetSuiteImportMapping(policyID, importField as keyof typeof importMappings, value, importValue); + Navigation.goBack(); + }, + [importField, importValue, policyID], + ); return ( Date: Tue, 2 Jul 2024 17:40:37 +0530 Subject: [PATCH 15/47] refactor: add pendingFields --- .../actions/connections/NetSuiteCommands.ts | 18 +++++++++--------- .../netsuite/import/NetSuiteImportPage.tsx | 2 ++ src/types/onyx/Policy.ts | 4 ++-- 3 files changed, 13 insertions(+), 11 deletions(-) diff --git a/src/libs/actions/connections/NetSuiteCommands.ts b/src/libs/actions/connections/NetSuiteCommands.ts index b8d10ee843c5..c7a0935d93e0 100644 --- a/src/libs/actions/connections/NetSuiteCommands.ts +++ b/src/libs/actions/connections/NetSuiteCommands.ts @@ -196,9 +196,9 @@ function updateNetSuiteImportMapping Policy.clearNetSuiteErrorField(policyID, importField)} > { updateNetSuiteSyncTaxConfiguration(policyID, isEnabled); }} + pendingAction={config?.syncOptions?.pendingFields?.syncTax} errors={ErrorUtils.getLatestErrorField(config ?? {}, CONST.NETSUITE_CONFIG.SYNC_TAX)} onCloseError={() => Policy.clearNetSuiteErrorField(policyID, CONST.NETSUITE_CONFIG.SYNC_TAX)} /> diff --git a/src/types/onyx/Policy.ts b/src/types/onyx/Policy.ts index 95c689520c91..2c4efc5091dd 100644 --- a/src/types/onyx/Policy.ts +++ b/src/types/onyx/Policy.ts @@ -744,7 +744,7 @@ type NetSuiteConnectionConfig = OnyxCommon.OnyxValueWithOfflineFeedback<{ /** Configuration options pertaining to sync. This subset of configurations is a legacy object. New configurations should just go directly under the config */ syncOptions: OnyxCommon.OnyxValueWithOfflineFeedback<{ /** Different NetSuite records that can be mapped to either Report Fields or Tags in Expensify */ - mapping: { + mapping: OnyxCommon.OnyxValueWithOfflineFeedback<{ /** A general type of classification category in NetSuite */ classes: NetSuiteMappingValues; @@ -759,7 +759,7 @@ type NetSuiteConnectionConfig = OnyxCommon.OnyxValueWithOfflineFeedback<{ /** A type of classification category in NetSuite linked to departments within the company */ departments: NetSuiteMappingValues; - }; + }>; /** Whether we want to import customers into NetSuite from across all subsidiaries */ crossSubsidiaryCustomers: boolean; From dc648fbf669448414efa1eb0d6b870ff8f490d2c Mon Sep 17 00:00:00 2001 From: Manan Jadhav Date: Tue, 2 Jul 2024 18:00:15 +0530 Subject: [PATCH 16/47] fix: rollback menu item key --- src/languages/en.ts | 1 + src/languages/es.ts | 1 + .../workspace/accounting/netsuite/import/NetSuiteImportPage.tsx | 2 +- 3 files changed, 3 insertions(+), 1 deletion(-) diff --git a/src/languages/en.ts b/src/languages/en.ts index b695a3f48705..f16ab9ef67a4 100755 --- a/src/languages/en.ts +++ b/src/languages/en.ts @@ -2659,6 +2659,7 @@ export default { [CONST.INTEGRATION_ENTITY_MAP_TYPES.NOT_IMPORTED]: 'Not imported', [CONST.INTEGRATION_ENTITY_MAP_TYPES.NONE]: 'Not imported', [CONST.INTEGRATION_ENTITY_MAP_TYPES.REPORT_FIELD]: 'Imported as report fields', + [CONST.INTEGRATION_ENTITY_MAP_TYPES.NETSUITE_DEFAULT]: 'NetSuite employee default', }, disconnectPrompt: (currentIntegration?: ConnectionName): string => { const integrationName = diff --git a/src/languages/es.ts b/src/languages/es.ts index fa58631db912..1d06add4a932 100644 --- a/src/languages/es.ts +++ b/src/languages/es.ts @@ -2630,6 +2630,7 @@ export default { [CONST.INTEGRATION_ENTITY_MAP_TYPES.NOT_IMPORTED]: 'No importado', [CONST.INTEGRATION_ENTITY_MAP_TYPES.NONE]: 'No importado', [CONST.INTEGRATION_ENTITY_MAP_TYPES.REPORT_FIELD]: 'Importado como campos de informe', + [CONST.INTEGRATION_ENTITY_MAP_TYPES.NETSUITE_DEFAULT]: 'Predeterminado del empleado NetSuite', }, disconnectPrompt: (currentIntegration?: ConnectionName): string => { const integrationName = diff --git a/src/pages/workspace/accounting/netsuite/import/NetSuiteImportPage.tsx b/src/pages/workspace/accounting/netsuite/import/NetSuiteImportPage.tsx index 4d738e77d4db..5bf63c1d5510 100644 --- a/src/pages/workspace/accounting/netsuite/import/NetSuiteImportPage.tsx +++ b/src/pages/workspace/accounting/netsuite/import/NetSuiteImportPage.tsx @@ -61,7 +61,7 @@ function NetSuiteImportPage({policy}: WithPolicyConnectionsProps) { { From ab2359e0049611fdd28c083179ca40748016d416 Mon Sep 17 00:00:00 2001 From: Manan Jadhav Date: Tue, 2 Jul 2024 20:39:53 +0530 Subject: [PATCH 17/47] refactor: run prettier --- .../accounting/netsuite/import/NetSuiteImportPage.tsx | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/pages/workspace/accounting/netsuite/import/NetSuiteImportPage.tsx b/src/pages/workspace/accounting/netsuite/import/NetSuiteImportPage.tsx index cfb97d6e7044..66adf731e362 100644 --- a/src/pages/workspace/accounting/netsuite/import/NetSuiteImportPage.tsx +++ b/src/pages/workspace/accounting/netsuite/import/NetSuiteImportPage.tsx @@ -60,9 +60,7 @@ function NetSuiteImportPage({policy}: WithPolicyConnectionsProps) { > { Navigation.navigate(ROUTES.POLICY_ACCOUNTING_NETSUITE_IMPORT_MAPPING.getRoute(policyID, importField)); From 6c877b378dd4454c2bbe626a8fff94cd3e6dc2da Mon Sep 17 00:00:00 2001 From: Manan Jadhav Date: Tue, 2 Jul 2024 23:34:15 +0530 Subject: [PATCH 18/47] refactor: run prettier --- .../import/NetSuiteImportMappingPage.tsx | 36 +++++++++++++++++-- 1 file changed, 33 insertions(+), 3 deletions(-) diff --git a/src/pages/workspace/accounting/netsuite/import/NetSuiteImportMappingPage.tsx b/src/pages/workspace/accounting/netsuite/import/NetSuiteImportMappingPage.tsx index cd5cfb52c676..647e23b03298 100644 --- a/src/pages/workspace/accounting/netsuite/import/NetSuiteImportMappingPage.tsx +++ b/src/pages/workspace/accounting/netsuite/import/NetSuiteImportMappingPage.tsx @@ -7,12 +7,14 @@ import RadioListItem from '@components/SelectionList/RadioListItem'; import type {SelectorType} from '@components/SelectionScreen'; import SelectionScreen from '@components/SelectionScreen'; import Text from '@components/Text'; +import * as ErrorUtils from '@libs/ErrorUtils'; import useLocalize from '@hooks/useLocalize'; import useThemeStyles from '@hooks/useThemeStyles'; import {updateNetSuiteImportMapping} from '@libs/actions/connections/NetSuiteCommands'; import Navigation from '@libs/Navigation/Navigation'; import withPolicyConnections from '@pages/workspace/withPolicyConnections'; import type {WithPolicyConnectionsProps} from '@pages/workspace/withPolicyConnections'; +import ToggleSettingOptionRow from '@pages/workspace/workflows/ToggleSettingsOptionRow'; import CONST from '@src/CONST'; import type {TranslationPaths} from '@src/languages/types'; @@ -40,7 +42,8 @@ function NetSuiteImportMappingPage({ const styles = useThemeStyles(); const {translate} = useLocalize(); - const importMappings = policy?.connections?.netsuite?.options?.config?.syncOptions?.mapping; + const netsuiteConfig = policy?.connections?.netsuite?.options?.config; + const importMappings = netsuiteConfig?.syncOptions?.mapping; const importValue = importMappings?.[importField as keyof typeof importMappings] ?? CONST.INTEGRATION_ENTITY_MAP_TYPES.NETSUITE_DEFAULT; @@ -56,15 +59,42 @@ function NetSuiteImportMappingPage({ const listHeaderComponent = useMemo( () => ( + + {importField === 'jobs' && ( + + { + updateNetSuiteSyncTaxConfiguration(policyID, isEnabled); + }} + pendingAction={netsuiteConfig?.syncOptions?.pendingFields?.syncTax} + errors={ErrorUtils.getLatestErrorField(netsuiteConfig ?? {}, CONST.NETSUITE_CONFIG.SYNC_OPTIONS.SYNC_TAX)} + onCloseError={() => Policy.clearNetSuiteErrorField(policyID, CONST.NETSUITE_CONFIG.SYNC_OPTIONS.SYNC_TAX)} + /> + + )} + ${parser.replace(translate(`workspace.netsuite.import.importFields.${importField}.subtitle` as TranslationPaths))}`} /> ), - [styles.ph5, styles.mt2, styles.mb4, translate, importField], + [styles.ph5, styles.mt2, styles.mb4, styles.flex1, importField, netsuiteConfig, translate, policyID], ); - const inputOptions = [CONST.INTEGRATION_ENTITY_MAP_TYPES.NETSUITE_DEFAULT, CONST.INTEGRATION_ENTITY_MAP_TYPES.TAG, CONST.INTEGRATION_ENTITY_MAP_TYPES.REPORT_FIELD]; + const inputOptions = useMemo(() => { + switch (importField) { + case 'departments': + case 'classes': + case 'locations': + return [CONST.INTEGRATION_ENTITY_MAP_TYPES.NETSUITE_DEFAULT, CONST.INTEGRATION_ENTITY_MAP_TYPES.TAG, CONST.INTEGRATION_ENTITY_MAP_TYPES.REPORT_FIELD]; + + default: + return [CONST.INTEGRATION_ENTITY_MAP_TYPES.TAG, CONST.INTEGRATION_ENTITY_MAP_TYPES.REPORT_FIELD]; + } + }, [importField]); const inputSectionData: ImportListItem[] = inputOptions.map((inputOption) => ({ From c93a37147fdcde9c7e299fff23e5725bbc895353 Mon Sep 17 00:00:00 2001 From: Manan Jadhav Date: Tue, 2 Jul 2024 23:42:33 +0530 Subject: [PATCH 19/47] feat: added translations --- src/languages/en.ts | 1 + src/languages/es.ts | 1 + .../accounting/netsuite/import/NetSuiteImportMappingPage.tsx | 3 ++- 3 files changed, 4 insertions(+), 1 deletion(-) diff --git a/src/languages/en.ts b/src/languages/en.ts index f16ab9ef67a4..16637e67c931 100755 --- a/src/languages/en.ts +++ b/src/languages/en.ts @@ -2295,6 +2295,7 @@ export default { import: { expenseCategories: `Expense categories`, expenseCategoriesDescription: `NetSuite expense categories import into Expensify as categories.`, + crossSubsidiaryCustomers: 'Cross-subsidiary customer/projects', importFields: { departments: { title: 'Departments', diff --git a/src/languages/es.ts b/src/languages/es.ts index 1d06add4a932..9f2bc787a9d0 100644 --- a/src/languages/es.ts +++ b/src/languages/es.ts @@ -2327,6 +2327,7 @@ export default { import: { expenseCategories: 'Categorías de gastos', expenseCategoriesDescription: 'Las categorías de gastos de NetSuite se importan a Expensify como categorías.', + crossSubsidiaryCustomers: 'Clientes/proyectos entre subsidiaria', importFields: { departments: { title: 'Departamentos', diff --git a/src/pages/workspace/accounting/netsuite/import/NetSuiteImportMappingPage.tsx b/src/pages/workspace/accounting/netsuite/import/NetSuiteImportMappingPage.tsx index 647e23b03298..8fedda9a8c2b 100644 --- a/src/pages/workspace/accounting/netsuite/import/NetSuiteImportMappingPage.tsx +++ b/src/pages/workspace/accounting/netsuite/import/NetSuiteImportMappingPage.tsx @@ -16,6 +16,7 @@ import withPolicyConnections from '@pages/workspace/withPolicyConnections'; import type {WithPolicyConnectionsProps} from '@pages/workspace/withPolicyConnections'; import ToggleSettingOptionRow from '@pages/workspace/workflows/ToggleSettingsOptionRow'; import CONST from '@src/CONST'; +import * as Policy from '@userActions/Policy/Policy'; import type {TranslationPaths} from '@src/languages/types'; const parser = new ExpensiMark(); @@ -63,7 +64,7 @@ function NetSuiteImportMappingPage({ {importField === 'jobs' && ( { From fd265ee030500591c1216a0100623e132c1c07a5 Mon Sep 17 00:00:00 2001 From: Manan Jadhav Date: Tue, 2 Jul 2024 23:56:43 +0530 Subject: [PATCH 20/47] refactor: update types --- .../actions/connections/NetSuiteCommands.ts | 18 +++++++++--------- .../import/NetSuiteImportMappingPage.tsx | 2 +- .../netsuite/import/NetSuiteImportPage.tsx | 2 +- src/types/onyx/Policy.ts | 4 ++-- 4 files changed, 13 insertions(+), 13 deletions(-) diff --git a/src/libs/actions/connections/NetSuiteCommands.ts b/src/libs/actions/connections/NetSuiteCommands.ts index c7a0935d93e0..b8d10ee843c5 100644 --- a/src/libs/actions/connections/NetSuiteCommands.ts +++ b/src/libs/actions/connections/NetSuiteCommands.ts @@ -196,9 +196,9 @@ function updateNetSuiteImportMapping { - updateNetSuiteSyncTaxConfiguration(policyID, isEnabled); + // updateNetSuiteSyncTaxConfiguration(policyID, isEnabled); }} pendingAction={netsuiteConfig?.syncOptions?.pendingFields?.syncTax} errors={ErrorUtils.getLatestErrorField(netsuiteConfig ?? {}, CONST.NETSUITE_CONFIG.SYNC_OPTIONS.SYNC_TAX)} diff --git a/src/pages/workspace/accounting/netsuite/import/NetSuiteImportPage.tsx b/src/pages/workspace/accounting/netsuite/import/NetSuiteImportPage.tsx index 66adf731e362..74a2b61a2079 100644 --- a/src/pages/workspace/accounting/netsuite/import/NetSuiteImportPage.tsx +++ b/src/pages/workspace/accounting/netsuite/import/NetSuiteImportPage.tsx @@ -55,7 +55,7 @@ function NetSuiteImportPage({policy}: WithPolicyConnectionsProps) { key={importField} errors={ErrorUtils.getLatestErrorField(config ?? {}, importField)} errorRowStyles={[styles.ph5, styles.mt2, styles.mb4]} - pendingAction={config?.syncOptions?.mapping?.pendingFields?.[importField]} + pendingAction={config?.syncOptions?.pendingFields?.[importField]} onClose={() => Policy.clearNetSuiteErrorField(policyID, importField)} > ; + }; /** Whether we want to import customers into NetSuite from across all subsidiaries */ crossSubsidiaryCustomers: boolean; From 5c003084a79a23d727b6ddd99e35c53045914154 Mon Sep 17 00:00:00 2001 From: Manan Jadhav Date: Wed, 3 Jul 2024 00:13:33 +0530 Subject: [PATCH 21/47] feat: update api calls for cross subsidiary --- src/CONST.ts | 1 + src/libs/API/types.ts | 2 + .../actions/connections/NetSuiteCommands.ts | 175 ++++++++++-------- .../import/NetSuiteImportMappingPage.tsx | 12 +- 4 files changed, 107 insertions(+), 83 deletions(-) diff --git a/src/CONST.ts b/src/CONST.ts index 63e9dd791f2c..397da20ba3de 100755 --- a/src/CONST.ts +++ b/src/CONST.ts @@ -1372,6 +1372,7 @@ const CONST = { IMPORT_CUSTOM_FIELDS: ['customSegments', 'customLists'], SYNC_OPTIONS: { SYNC_TAX: 'syncTax', + CROSS_SUBSIDIARY_CUSTOMERS: 'crossSubsidiaryCustomers' }, }, diff --git a/src/libs/API/types.ts b/src/libs/API/types.ts index 2aef5d8a0f02..24902174f5d2 100644 --- a/src/libs/API/types.ts +++ b/src/libs/API/types.ts @@ -231,6 +231,7 @@ const WRITE_COMMANDS = { UPDATE_SUBSCRIPTION_SIZE: 'UpdateSubscriptionSize', UPDATE_NETSUITE_SUBSIDIARY: 'UpdateNetSuiteSubsidiary', UPDATE_NETSUITE_SYNC_TAX_CONFIGURATION: 'UpdateNetSuiteSyncTaxConfiguration', + UPDATE_NETSUITE_CROSS_SUBSIDIARY_CUSTOMER_CONFIGURATION: 'UpdateNetSuiteCrossSubsidiaryCustomerConfiguration', UPDATE_NETSUITE_DEPARTMENTS_MAPPING: 'UpdateNetSuiteDepartmentsMapping', UPDATE_NETSUITE_CLASSES_MAPPING: 'UpdateNetSuiteClassesMapping', UPDATE_NETSUITE_LOCATIONS_MAPPING: 'UpdateNetSuiteLocationsMapping', @@ -486,6 +487,7 @@ type WriteCommandParameters = { // Netsuite parameters [WRITE_COMMANDS.UPDATE_NETSUITE_SUBSIDIARY]: Parameters.UpdateNetSuiteSubsidiaryParams; [WRITE_COMMANDS.UPDATE_NETSUITE_SYNC_TAX_CONFIGURATION]: Parameters.UpdateNetSuiteGenericTypeParams<'enabled', boolean>; + [WRITE_COMMANDS.UPDATE_NETSUITE_CROSS_SUBSIDIARY_CUSTOMER_CONFIGURATION]: Parameters.UpdateNetSuiteGenericTypeParams<'enabled', boolean>; [WRITE_COMMANDS.UPDATE_NETSUITE_DEPARTMENTS_MAPPING]: Parameters.UpdateNetSuiteGenericTypeParams<'mapping', ValueOf>; [WRITE_COMMANDS.UPDATE_NETSUITE_CLASSES_MAPPING]: Parameters.UpdateNetSuiteGenericTypeParams<'mapping', ValueOf>; [WRITE_COMMANDS.UPDATE_NETSUITE_LOCATIONS_MAPPING]: Parameters.UpdateNetSuiteGenericTypeParams<'mapping', ValueOf>; diff --git a/src/libs/actions/connections/NetSuiteCommands.ts b/src/libs/actions/connections/NetSuiteCommands.ts index b8d10ee843c5..d4e9979a169b 100644 --- a/src/libs/actions/connections/NetSuiteCommands.ts +++ b/src/libs/actions/connections/NetSuiteCommands.ts @@ -94,6 +94,92 @@ function updateNetSuiteOnyxData( + policyID: string, + settingName: TSettingName, + settingValue: Partial, + oldSettingValue: Partial, +) { + const optimisticData: OnyxUpdate[] = [ + { + onyxMethod: Onyx.METHOD.MERGE, + key: `${ONYXKEYS.COLLECTION.POLICY}${policyID}`, + value: { + connections: { + netsuite: { + options: { + config: { + syncOptions: { + [settingName]: settingValue ?? null, + pendingFields: { + [settingName]: CONST.RED_BRICK_ROAD_PENDING_ACTION.UPDATE, + }, + }, + errorFields: { + [settingName]: null, + }, + }, + }, + }, + }, + }, + }, + ]; + + const failureData: OnyxUpdate[] = [ + { + onyxMethod: Onyx.METHOD.MERGE, + key: `${ONYXKEYS.COLLECTION.POLICY}${policyID}`, + value: { + connections: { + netsuite: { + options: { + config: { + syncOptions: { + [settingName]: oldSettingValue ?? null, + pendingFields: { + [settingName]: null, + }, + }, + errorFields: { + [settingName]: ErrorUtils.getMicroSecondOnyxErrorWithTranslationKey('common.genericErrorMessage'), + }, + }, + }, + }, + }, + }, + }, + ]; + + const successData: OnyxUpdate[] = [ + { + onyxMethod: Onyx.METHOD.MERGE, + key: `${ONYXKEYS.COLLECTION.POLICY}${policyID}`, + value: { + connections: { + netsuite: { + options: { + config: { + syncOptions: { + [settingName]: settingValue ?? null, + pendingFields: { + [settingName]: null, + }, + }, + errorFields: { + [settingName]: null, + }, + }, + }, + }, + }, + }, + }, + ]; + return {optimisticData, failureData, successData}; +} + function updateNetSuiteSubsidiary(policyID: string, newSubsidiary: SubsidiaryParam, oldSubsidiary: SubsidiaryParam) { const onyxData: OnyxData = { optimisticData: [ @@ -297,83 +383,7 @@ function updateNetSuiteImportMapping { - // updateNetSuiteSyncTaxConfiguration(policyID, isEnabled); + updateNetSuiteCrossSubsidiaryCustomersConfiguration(policyID, isEnabled); }} - pendingAction={netsuiteConfig?.syncOptions?.pendingFields?.syncTax} - errors={ErrorUtils.getLatestErrorField(netsuiteConfig ?? {}, CONST.NETSUITE_CONFIG.SYNC_OPTIONS.SYNC_TAX)} - onCloseError={() => Policy.clearNetSuiteErrorField(policyID, CONST.NETSUITE_CONFIG.SYNC_OPTIONS.SYNC_TAX)} + pendingAction={netsuiteConfig?.syncOptions?.pendingFields?.crossSubsidiaryCustomers} + errors={ErrorUtils.getLatestErrorField(netsuiteConfig ?? {}, CONST.NETSUITE_CONFIG.SYNC_OPTIONS.CROSS_SUBSIDIARY_CUSTOMERS)} + onCloseError={() => Policy.clearNetSuiteErrorField(policyID, CONST.NETSUITE_CONFIG.SYNC_OPTIONS.CROSS_SUBSIDIARY_CUSTOMERS)} /> )} From 5fa854d318eafb218323faea77e7bfb9645f533e Mon Sep 17 00:00:00 2001 From: Manan Jadhav Date: Wed, 3 Jul 2024 00:15:49 +0530 Subject: [PATCH 22/47] fix: styling overlap --- .../accounting/netsuite/import/NetSuiteImportMappingPage.tsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/pages/workspace/accounting/netsuite/import/NetSuiteImportMappingPage.tsx b/src/pages/workspace/accounting/netsuite/import/NetSuiteImportMappingPage.tsx index b88e9c096ea5..a8da2d4a4552 100644 --- a/src/pages/workspace/accounting/netsuite/import/NetSuiteImportMappingPage.tsx +++ b/src/pages/workspace/accounting/netsuite/import/NetSuiteImportMappingPage.tsx @@ -62,7 +62,7 @@ function NetSuiteImportMappingPage({ {importField === 'jobs' && ( - + ), - [styles.ph5, styles.mt2, styles.mb4, styles.flex1, importField, netsuiteConfig, translate, policyID], + [styles.ph5, styles.mt2, styles.mb4, styles.flex1, styles.mb8, importField, translate, netsuiteConfig, policyID], ); const inputOptions = useMemo(() => { From ddcfb4602c85565c2977ea8cee9229b56c7f73e8 Mon Sep 17 00:00:00 2001 From: Manan Jadhav Date: Wed, 3 Jul 2024 01:18:36 +0530 Subject: [PATCH 23/47] refactor: run prettier --- src/CONST.ts | 2 +- src/libs/actions/connections/NetSuiteCommands.ts | 9 +++++++-- .../netsuite/import/NetSuiteImportMappingPage.tsx | 15 +++++++-------- src/types/onyx/Policy.ts | 2 +- 4 files changed, 16 insertions(+), 12 deletions(-) diff --git a/src/CONST.ts b/src/CONST.ts index f05ae6bb3bad..d2c880fc33d2 100755 --- a/src/CONST.ts +++ b/src/CONST.ts @@ -1372,7 +1372,7 @@ const CONST = { IMPORT_CUSTOM_FIELDS: ['customSegments', 'customLists'], SYNC_OPTIONS: { SYNC_TAX: 'syncTax', - CROSS_SUBSIDIARY_CUSTOMERS: 'crossSubsidiaryCustomers' + CROSS_SUBSIDIARY_CUSTOMERS: 'crossSubsidiaryCustomers', }, }, diff --git a/src/libs/actions/connections/NetSuiteCommands.ts b/src/libs/actions/connections/NetSuiteCommands.ts index d4e9979a169b..9a655cceadbd 100644 --- a/src/libs/actions/connections/NetSuiteCommands.ts +++ b/src/libs/actions/connections/NetSuiteCommands.ts @@ -393,7 +393,12 @@ function updateNetSuiteSyncTaxConfiguration(policyID: string, isSyncTaxEnabled: } function updateNetSuiteCrossSubsidiaryCustomersConfiguration(policyID: string, isCrossSubsidiaryCustomersEnabled: boolean) { - const onyxData = updateNetSuiteSyncOptionsOnyxData(policyID, CONST.NETSUITE_CONFIG.SYNC_OPTIONS.CROSS_SUBSIDIARY_CUSTOMERS, isCrossSubsidiaryCustomersEnabled, !isCrossSubsidiaryCustomersEnabled); + const onyxData = updateNetSuiteSyncOptionsOnyxData( + policyID, + CONST.NETSUITE_CONFIG.SYNC_OPTIONS.CROSS_SUBSIDIARY_CUSTOMERS, + isCrossSubsidiaryCustomersEnabled, + !isCrossSubsidiaryCustomersEnabled, + ); const params = { policyID, @@ -587,5 +592,5 @@ export { updateNetSuiteAllowForeignCurrency, updateNetSuiteExportToNextOpenPeriod, updateNetSuiteImportMapping, - updateNetSuiteCrossSubsidiaryCustomersConfiguration + updateNetSuiteCrossSubsidiaryCustomersConfiguration, }; diff --git a/src/pages/workspace/accounting/netsuite/import/NetSuiteImportMappingPage.tsx b/src/pages/workspace/accounting/netsuite/import/NetSuiteImportMappingPage.tsx index a8da2d4a4552..61e1770f86a5 100644 --- a/src/pages/workspace/accounting/netsuite/import/NetSuiteImportMappingPage.tsx +++ b/src/pages/workspace/accounting/netsuite/import/NetSuiteImportMappingPage.tsx @@ -7,16 +7,16 @@ import RadioListItem from '@components/SelectionList/RadioListItem'; import type {SelectorType} from '@components/SelectionScreen'; import SelectionScreen from '@components/SelectionScreen'; import Text from '@components/Text'; -import * as ErrorUtils from '@libs/ErrorUtils'; import useLocalize from '@hooks/useLocalize'; import useThemeStyles from '@hooks/useThemeStyles'; -import {updateNetSuiteImportMapping, updateNetSuiteCrossSubsidiaryCustomersConfiguration} from '@libs/actions/connections/NetSuiteCommands'; +import {updateNetSuiteCrossSubsidiaryCustomersConfiguration, updateNetSuiteImportMapping} from '@libs/actions/connections/NetSuiteCommands'; +import * as ErrorUtils from '@libs/ErrorUtils'; import Navigation from '@libs/Navigation/Navigation'; import withPolicyConnections from '@pages/workspace/withPolicyConnections'; import type {WithPolicyConnectionsProps} from '@pages/workspace/withPolicyConnections'; import ToggleSettingOptionRow from '@pages/workspace/workflows/ToggleSettingsOptionRow'; -import CONST from '@src/CONST'; import * as Policy from '@userActions/Policy/Policy'; +import CONST from '@src/CONST'; import type {TranslationPaths} from '@src/languages/types'; const parser = new ExpensiMark(); @@ -60,7 +60,6 @@ function NetSuiteImportMappingPage({ const listHeaderComponent = useMemo( () => ( - {importField === 'jobs' && ( { switch (importField) { - case 'departments': - case 'classes': - case 'locations': + case 'departments': + case 'classes': + case 'locations': return [CONST.INTEGRATION_ENTITY_MAP_TYPES.NETSUITE_DEFAULT, CONST.INTEGRATION_ENTITY_MAP_TYPES.TAG, CONST.INTEGRATION_ENTITY_MAP_TYPES.REPORT_FIELD]; - + default: return [CONST.INTEGRATION_ENTITY_MAP_TYPES.TAG, CONST.INTEGRATION_ENTITY_MAP_TYPES.REPORT_FIELD]; } diff --git a/src/types/onyx/Policy.ts b/src/types/onyx/Policy.ts index 1818cad6c0be..95c689520c91 100644 --- a/src/types/onyx/Policy.ts +++ b/src/types/onyx/Policy.ts @@ -744,7 +744,7 @@ type NetSuiteConnectionConfig = OnyxCommon.OnyxValueWithOfflineFeedback<{ /** Configuration options pertaining to sync. This subset of configurations is a legacy object. New configurations should just go directly under the config */ syncOptions: OnyxCommon.OnyxValueWithOfflineFeedback<{ /** Different NetSuite records that can be mapped to either Report Fields or Tags in Expensify */ - mapping:{ + mapping: { /** A general type of classification category in NetSuite */ classes: NetSuiteMappingValues; From 03e452672aacd95eff7c891fdffa1ef2b19eb06d Mon Sep 17 00:00:00 2001 From: Manan Jadhav Date: Wed, 3 Jul 2024 01:34:02 +0530 Subject: [PATCH 24/47] refactor: fix type errors --- src/ROUTES.ts | 5 +++-- src/libs/Navigation/types.ts | 4 ++-- .../actions/connections/NetSuiteCommands.ts | 18 +++++++++--------- .../import/NetSuiteImportMappingPage.tsx | 8 +++++--- .../netsuite/import/NetSuiteImportPage.tsx | 2 +- src/types/onyx/Policy.ts | 4 ++-- 6 files changed, 22 insertions(+), 19 deletions(-) diff --git a/src/ROUTES.ts b/src/ROUTES.ts index 6d26fbe75ce6..37eda77cd18c 100644 --- a/src/ROUTES.ts +++ b/src/ROUTES.ts @@ -1,4 +1,4 @@ -import type {ValueOf} from 'type-fest'; +import type {TupleToUnion, ValueOf} from 'type-fest'; import type CONST from './CONST'; import type {IOUAction, IOUType} from './CONST'; import type {IOURequestType} from './libs/actions/IOU'; @@ -946,7 +946,8 @@ const ROUTES = { }, POLICY_ACCOUNTING_NETSUITE_IMPORT_MAPPING: { route: 'settings/workspaces/:policyID/accounting/netsuite/import/mapping/:importField', - getRoute: (policyID: string, importField: string) => `settings/workspaces/${policyID}/accounting/netsuite/import/mapping/${importField}` as const, + getRoute: (policyID: string, importField: TupleToUnion) => + `settings/workspaces/${policyID}/accounting/netsuite/import/mapping/${importField}` as const, }, POLICY_ACCOUNTING_NETSUITE_EXPORT: { route: 'settings/workspaces/:policyID/connections/netsuite/export/', diff --git a/src/libs/Navigation/types.ts b/src/libs/Navigation/types.ts index 12629dc3be39..782230ff093e 100644 --- a/src/libs/Navigation/types.ts +++ b/src/libs/Navigation/types.ts @@ -10,7 +10,7 @@ import type { PartialState, Route, } from '@react-navigation/native'; -import type {ValueOf} from 'type-fest'; +import type {TupleToUnion, ValueOf} from 'type-fest'; import type {IOURequestType} from '@libs/actions/IOU'; import type {SearchColumnType, SortOrder} from '@libs/SearchUtils'; import type CONST from '@src/CONST'; @@ -404,7 +404,7 @@ type SettingsNavigatorParamList = { }; [SCREENS.WORKSPACE.ACCOUNTING.NETSUITE_IMPORT_MAPPING]: { policyID: string; - importField: string; + importField: TupleToUnion; }; [SCREENS.WORKSPACE.ACCOUNTING.NETSUITE_EXPORT]: { policyID: string; diff --git a/src/libs/actions/connections/NetSuiteCommands.ts b/src/libs/actions/connections/NetSuiteCommands.ts index 9a655cceadbd..433fd57bd357 100644 --- a/src/libs/actions/connections/NetSuiteCommands.ts +++ b/src/libs/actions/connections/NetSuiteCommands.ts @@ -282,9 +282,9 @@ function updateNetSuiteImportMapping; + type NetSuiteImportMappingPageProps = WithPolicyConnectionsProps & { route: { params: { - importField: string; + importField: ImportFieldsKeys; }; }; }; @@ -46,7 +48,7 @@ function NetSuiteImportMappingPage({ const netsuiteConfig = policy?.connections?.netsuite?.options?.config; const importMappings = netsuiteConfig?.syncOptions?.mapping; - const importValue = importMappings?.[importField as keyof typeof importMappings] ?? CONST.INTEGRATION_ENTITY_MAP_TYPES.NETSUITE_DEFAULT; + const importValue = importMappings?.[importField] ?? CONST.INTEGRATION_ENTITY_MAP_TYPES.NETSUITE_DEFAULT; const listFooterContent = useMemo( () => ( diff --git a/src/pages/workspace/accounting/netsuite/import/NetSuiteImportPage.tsx b/src/pages/workspace/accounting/netsuite/import/NetSuiteImportPage.tsx index 783d352d36aa..fe7afe7779c1 100644 --- a/src/pages/workspace/accounting/netsuite/import/NetSuiteImportPage.tsx +++ b/src/pages/workspace/accounting/netsuite/import/NetSuiteImportPage.tsx @@ -57,7 +57,7 @@ function NetSuiteImportPage({policy}: WithPolicyConnectionsProps) { key={importField} errors={ErrorUtils.getLatestErrorField(config ?? {}, importField)} errorRowStyles={[styles.ph5, styles.mt2, styles.mb4]} - pendingAction={config?.syncOptions?.pendingFields?.[importField]} + pendingAction={config?.syncOptions?.mapping?.pendingFields?.[importField]} onClose={() => Policy.clearNetSuiteErrorField(policyID, importField)} > ; /** Whether we want to import customers into NetSuite from across all subsidiaries */ crossSubsidiaryCustomers: boolean; From 6d79e8d0df775e520a8ee8b53f2270b67dd5797f Mon Sep 17 00:00:00 2001 From: Manan Jadhav Date: Wed, 3 Jul 2024 02:43:49 +0530 Subject: [PATCH 25/47] fix: styling issue --- .../netsuite/import/NetSuiteImportMappingPage.tsx | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/pages/workspace/accounting/netsuite/import/NetSuiteImportMappingPage.tsx b/src/pages/workspace/accounting/netsuite/import/NetSuiteImportMappingPage.tsx index 50111ba1824b..4d9a5e55e3fb 100644 --- a/src/pages/workspace/accounting/netsuite/import/NetSuiteImportMappingPage.tsx +++ b/src/pages/workspace/accounting/netsuite/import/NetSuiteImportMappingPage.tsx @@ -63,7 +63,7 @@ function NetSuiteImportMappingPage({ () => ( {importField === 'jobs' && ( - + )} - + ${parser.replace(translate(`workspace.netsuite.import.importFields.${importField}.subtitle` as TranslationPaths))}`} /> + + ), - [styles.ph5, styles.mt2, styles.mb4, styles.flex1, styles.mb8, importField, translate, netsuiteConfig, policyID], + [styles.ph5, styles.mt2, styles.mb4, styles.flexRow, importField, translate, netsuiteConfig, policyID], ); const inputOptions = useMemo(() => { From 7be1c0344a67624265c32742c64c9355844808ed Mon Sep 17 00:00:00 2001 From: Manan Jadhav Date: Wed, 3 Jul 2024 02:49:20 +0530 Subject: [PATCH 26/47] fix: redirect if same value --- .../accounting/netsuite/import/NetSuiteImportMappingPage.tsx | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/pages/workspace/accounting/netsuite/import/NetSuiteImportMappingPage.tsx b/src/pages/workspace/accounting/netsuite/import/NetSuiteImportMappingPage.tsx index 4d9a5e55e3fb..53110b1ffe5f 100644 --- a/src/pages/workspace/accounting/netsuite/import/NetSuiteImportMappingPage.tsx +++ b/src/pages/workspace/accounting/netsuite/import/NetSuiteImportMappingPage.tsx @@ -114,11 +114,10 @@ function NetSuiteImportMappingPage({ const updateImportMapping = useCallback( ({value}: ImportListItem) => { - if (!value || value === importValue) { - return; + if (value !== importValue) { + updateNetSuiteImportMapping(policyID, importField as keyof typeof importMappings, value, importValue); } - updateNetSuiteImportMapping(policyID, importField as keyof typeof importMappings, value, importValue); Navigation.goBack(); }, [importField, importValue, policyID], From 2dbcffb39c9de5d24dea1601593ea97cdb12ca4e Mon Sep 17 00:00:00 2001 From: Manan Jadhav Date: Wed, 3 Jul 2024 02:54:36 +0530 Subject: [PATCH 27/47] refactor: run prettier --- .../netsuite/import/NetSuiteImportMappingPage.tsx | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/pages/workspace/accounting/netsuite/import/NetSuiteImportMappingPage.tsx b/src/pages/workspace/accounting/netsuite/import/NetSuiteImportMappingPage.tsx index 53110b1ffe5f..f618c33e92d7 100644 --- a/src/pages/workspace/accounting/netsuite/import/NetSuiteImportMappingPage.tsx +++ b/src/pages/workspace/accounting/netsuite/import/NetSuiteImportMappingPage.tsx @@ -80,10 +80,11 @@ function NetSuiteImportMappingPage({ ${parser.replace(translate(`workspace.netsuite.import.importFields.${importField}.subtitle` as TranslationPaths))}`} - /> + html={`${parser.replace( + translate(`workspace.netsuite.import.importFields.${importField}.subtitle` as TranslationPaths), + )}`} + /> - ), [styles.ph5, styles.mt2, styles.mb4, styles.flexRow, importField, translate, netsuiteConfig, policyID], From 253dca91ca6dfce240e4703c28048e54050db2c2 Mon Sep 17 00:00:00 2001 From: Manan Jadhav Date: Thu, 4 Jul 2024 01:23:01 +0530 Subject: [PATCH 28/47] feat: split the customers as a new route --- src/CONST.ts | 6 +- src/ROUTES.ts | 5 + src/SCREENS.ts | 1 + src/languages/en.ts | 11 +- src/languages/es.ts | 11 +- .../ModalStackNavigators/index.tsx | 1 + .../FULL_SCREEN_TO_RHP_MAPPING.ts | 1 + src/libs/Navigation/linkingConfig/config.ts | 1 + src/libs/Navigation/types.ts | 3 + .../import/NetSuiteImportJobsPage.tsx | 126 ++++++++++++++++++ .../import/NetSuiteImportMappingPage.tsx | 36 +---- .../netsuite/import/NetSuiteImportPage.tsx | 20 +++ 12 files changed, 173 insertions(+), 49 deletions(-) create mode 100644 src/pages/workspace/accounting/netsuite/import/NetSuiteImportJobsPage.tsx diff --git a/src/CONST.ts b/src/CONST.ts index adb23bf4f21d..6b3b85f61d4e 100755 --- a/src/CONST.ts +++ b/src/CONST.ts @@ -1372,11 +1372,15 @@ const CONST = { PROVINCIAL_TAX_POSTING_ACCOUNT: 'provincialTaxPostingAccount', ALLOW_FOREIGN_CURRENCY: 'allowForeignCurrency', EXPORT_TO_NEXT_OPEN_PERIOD: 'exportToNextOpenPeriod', - IMPORT_FIELDS: ['departments', 'classes', 'locations', 'customers', 'jobs'], + IMPORT_FIELDS: ['departments', 'classes', 'locations'], IMPORT_CUSTOM_FIELDS: ['customSegments', 'customLists'], SYNC_OPTIONS: { SYNC_TAX: 'syncTax', CROSS_SUBSIDIARY_CUSTOMERS: 'crossSubsidiaryCustomers', + MAPPING: { + CUSTOMERS: 'customers', + JOBS: 'jobs' + } }, }, diff --git a/src/ROUTES.ts b/src/ROUTES.ts index 870984750d3e..fb49c0b54382 100644 --- a/src/ROUTES.ts +++ b/src/ROUTES.ts @@ -969,6 +969,11 @@ const ROUTES = { getRoute: (policyID: string, importField: TupleToUnion) => `settings/workspaces/${policyID}/accounting/netsuite/import/mapping/${importField}` as const, }, + POLICY_ACCOUNTING_NETSUITE_IMPORT_JOBS: { + route: 'settings/workspaces/:policyID/accounting/netsuite/import/jobs/', + getRoute: (policyID: string) => + `settings/workspaces/${policyID}/accounting/netsuite/import/jobs` as const, + }, POLICY_ACCOUNTING_NETSUITE_EXPORT: { route: 'settings/workspaces/:policyID/connections/netsuite/export/', getRoute: (policyID: string) => `settings/workspaces/${policyID}/connections/netsuite/export/` as const, diff --git a/src/SCREENS.ts b/src/SCREENS.ts index a0c21bbac607..09cff0c0696c 100644 --- a/src/SCREENS.ts +++ b/src/SCREENS.ts @@ -273,6 +273,7 @@ const SCREENS = { XERO_BILL_PAYMENT_ACCOUNT_SELECTOR: 'Policy_Accounting_Xero_Bill_Payment_Account_Selector', XERO_EXPORT_BANK_ACCOUNT_SELECT: 'Policy_Accounting_Xero_Export_Bank_Account_Select', NETSUITE_IMPORT_MAPPING: 'Policy_Accounting_NetSuite_Import_Mapping', + NETSUITE_IMPORT_JOBS: 'Policy_Accounting_NetSuite_Import_Jobs', NETSUITE_SUBSIDIARY_SELECTOR: 'Policy_Accounting_NetSuite_Subsidiary_Selector', NETSUITE_IMPORT: 'Policy_Accounting_NetSuite_Import', NETSUITE_EXPORT: 'Policy_Accounting_NetSuite_Export', diff --git a/src/languages/en.ts b/src/languages/en.ts index d3b685e15769..6d58734b9222 100755 --- a/src/languages/en.ts +++ b/src/languages/en.ts @@ -2316,14 +2316,9 @@ export default { title: 'Locations', subtitle: 'Choose how to handle *locations* in Expensify.', }, - customers: { - title: 'Customers', - subtitle: "Import *customers* into Expensify and choose how they'll be displayed.", - }, - jobs: { - title: 'Projects (jobs)', - subtitle: "Import *projects (jobs)* into Expensify and choose how they'll be displayed.", - }, + }, + customersOrJobs: { + title: 'Customers / projects (jobs)', }, importTaxDescription: 'Import tax groups from NetSuite', importCustomFields: { diff --git a/src/languages/es.ts b/src/languages/es.ts index 01a9736c821a..f7fd4f430872 100644 --- a/src/languages/es.ts +++ b/src/languages/es.ts @@ -2348,14 +2348,9 @@ export default { title: 'Ubicaciones', subtitle: 'Elija cómo manejar *ubicaciones* en Expensify.', }, - customers: { - title: 'Clientes', - subtitle: 'Importa *clientes* a Expensify y elige cómo se mostrarán.', - }, - jobs: { - title: 'Proyectos (trabajos)', - subtitle: 'Importa *proyectos (trabajos)* a Expensify y elige cómo se mostrarán.', - }, + }, + customersOrJobs: { + title: 'Clientes / proyectos (trabajos)', }, importTaxDescription: 'Importar grupos de impuestos desde NetSuite', importCustomFields: { diff --git a/src/libs/Navigation/AppNavigator/ModalStackNavigators/index.tsx b/src/libs/Navigation/AppNavigator/ModalStackNavigators/index.tsx index 3c92ffef554c..79618d9f07d8 100644 --- a/src/libs/Navigation/AppNavigator/ModalStackNavigators/index.tsx +++ b/src/libs/Navigation/AppNavigator/ModalStackNavigators/index.tsx @@ -322,6 +322,7 @@ const SettingsModalStackNavigator = createModalStackNavigator require('../../../../pages/workspace/accounting/netsuite/NetSuiteSubsidiarySelector').default, [SCREENS.WORKSPACE.ACCOUNTING.NETSUITE_IMPORT]: () => require('../../../../pages/workspace/accounting/netsuite/import/NetSuiteImportPage').default, [SCREENS.WORKSPACE.ACCOUNTING.NETSUITE_IMPORT_MAPPING]: () => require('../../../../pages/workspace/accounting/netsuite/import/NetSuiteImportMappingPage').default, + [SCREENS.WORKSPACE.ACCOUNTING.NETSUITE_IMPORT_JOBS]: () => require('../../../../pages/workspace/accounting/netsuite/import/NetSuiteImportJobsPage').default, [SCREENS.WORKSPACE.ACCOUNTING.NETSUITE_EXPORT]: () => require('../../../../pages/workspace/accounting/netsuite/export/NetSuiteExportConfigurationPage').default, [SCREENS.WORKSPACE.ACCOUNTING.NETSUITE_PREFERRED_EXPORTER_SELECT]: () => require('../../../../pages/workspace/accounting/netsuite/export/NetSuitePreferredExporterSelectPage').default, diff --git a/src/libs/Navigation/linkingConfig/FULL_SCREEN_TO_RHP_MAPPING.ts b/src/libs/Navigation/linkingConfig/FULL_SCREEN_TO_RHP_MAPPING.ts index bb26e53dfa5e..359af8629975 100755 --- a/src/libs/Navigation/linkingConfig/FULL_SCREEN_TO_RHP_MAPPING.ts +++ b/src/libs/Navigation/linkingConfig/FULL_SCREEN_TO_RHP_MAPPING.ts @@ -58,6 +58,7 @@ const FULL_SCREEN_TO_RHP_MAPPING: Partial> = { SCREENS.WORKSPACE.ACCOUNTING.NETSUITE_SUBSIDIARY_SELECTOR, SCREENS.WORKSPACE.ACCOUNTING.NETSUITE_IMPORT, SCREENS.WORKSPACE.ACCOUNTING.NETSUITE_IMPORT_MAPPING, + SCREENS.WORKSPACE.ACCOUNTING.NETSUITE_IMPORT_JOBS, SCREENS.WORKSPACE.ACCOUNTING.NETSUITE_EXPORT, SCREENS.WORKSPACE.ACCOUNTING.NETSUITE_PREFERRED_EXPORTER_SELECT, SCREENS.WORKSPACE.ACCOUNTING.NETSUITE_DATE_SELECT, diff --git a/src/libs/Navigation/linkingConfig/config.ts b/src/libs/Navigation/linkingConfig/config.ts index c337a1a2565e..e5e640fd2ef4 100644 --- a/src/libs/Navigation/linkingConfig/config.ts +++ b/src/libs/Navigation/linkingConfig/config.ts @@ -356,6 +356,7 @@ const config: LinkingOptions['config'] = { [SCREENS.WORKSPACE.ACCOUNTING.NETSUITE_SUBSIDIARY_SELECTOR]: {path: ROUTES.POLICY_ACCOUNTING_NETSUITE_SUBSIDIARY_SELECTOR.route}, [SCREENS.WORKSPACE.ACCOUNTING.NETSUITE_IMPORT]: {path: ROUTES.POLICY_ACCOUNTING_NETSUITE_IMPORT.route}, [SCREENS.WORKSPACE.ACCOUNTING.NETSUITE_IMPORT_MAPPING]: {path: ROUTES.POLICY_ACCOUNTING_NETSUITE_IMPORT_MAPPING.route}, + [SCREENS.WORKSPACE.ACCOUNTING.NETSUITE_IMPORT_JOBS]: {path: ROUTES.POLICY_ACCOUNTING_NETSUITE_IMPORT_JOBS.route}, [SCREENS.WORKSPACE.ACCOUNTING.NETSUITE_EXPORT]: { path: ROUTES.POLICY_ACCOUNTING_NETSUITE_EXPORT.route, }, diff --git a/src/libs/Navigation/types.ts b/src/libs/Navigation/types.ts index 6f10a009799f..3ac5c6210798 100644 --- a/src/libs/Navigation/types.ts +++ b/src/libs/Navigation/types.ts @@ -419,6 +419,9 @@ type SettingsNavigatorParamList = { [SCREENS.WORKSPACE.ACCOUNTING.NETSUITE_IMPORT]: { policyID: string; }; + [SCREENS.WORKSPACE.ACCOUNTING.NETSUITE_IMPORT_JOBS]: { + policyID: string; + }; [SCREENS.WORKSPACE.ACCOUNTING.NETSUITE_IMPORT_MAPPING]: { policyID: string; importField: TupleToUnion; diff --git a/src/pages/workspace/accounting/netsuite/import/NetSuiteImportJobsPage.tsx b/src/pages/workspace/accounting/netsuite/import/NetSuiteImportJobsPage.tsx new file mode 100644 index 000000000000..c9c207ab0e2e --- /dev/null +++ b/src/pages/workspace/accounting/netsuite/import/NetSuiteImportJobsPage.tsx @@ -0,0 +1,126 @@ +import {ExpensiMark} from 'expensify-common'; +import React, {useCallback, useMemo} from 'react'; +import {View} from 'react-native'; +import type {ValueOf} from 'type-fest'; +import RenderHTML from '@components/RenderHTML'; +import RadioListItem from '@components/SelectionList/RadioListItem'; +import type {SelectorType} from '@components/SelectionScreen'; +import SelectionScreen from '@components/SelectionScreen'; +import Text from '@components/Text'; +import useLocalize from '@hooks/useLocalize'; +import useThemeStyles from '@hooks/useThemeStyles'; +import {updateNetSuiteCrossSubsidiaryCustomersConfiguration, updateNetSuiteImportMapping} from '@libs/actions/connections/NetSuiteCommands'; +import * as ErrorUtils from '@libs/ErrorUtils'; +import Navigation from '@libs/Navigation/Navigation'; +import withPolicyConnections from '@pages/workspace/withPolicyConnections'; +import type {WithPolicyConnectionsProps} from '@pages/workspace/withPolicyConnections'; +import ToggleSettingOptionRow from '@pages/workspace/workflows/ToggleSettingsOptionRow'; +import * as Policy from '@userActions/Policy/Policy'; +import CONST from '@src/CONST'; +import type {TranslationPaths} from '@src/languages/types'; + +const parser = new ExpensiMark(); + +type ImportListItem = SelectorType & { + value: ValueOf; +}; + +function NetSuiteImportJobsPage({ + policy +}: WithPolicyConnectionsProps) { + const policyID = policy?.id ?? '-1'; + const styles = useThemeStyles(); + const {translate} = useLocalize(); + const importField = 'locations'; + + const netsuiteConfig = policy?.connections?.netsuite?.options?.config; + const importMappings = netsuiteConfig?.syncOptions?.mapping; + + const importValue = importMappings?.[importField] ?? CONST.INTEGRATION_ENTITY_MAP_TYPES.NETSUITE_DEFAULT; + + const listFooterContent = useMemo( + () => ( + + {translate(`workspace.netsuite.import.importTypes.${importValue}.footerContent`, importField)} + + ), + [importField, importValue, styles.mb4, styles.mt2, styles.ph5, translate], + ); + + const listHeaderComponent = useMemo( + () => ( + + + + { + updateNetSuiteCrossSubsidiaryCustomersConfiguration(policyID, isEnabled); + }} + pendingAction={netsuiteConfig?.syncOptions?.pendingFields?.crossSubsidiaryCustomers} + errors={ErrorUtils.getLatestErrorField(netsuiteConfig ?? {}, CONST.NETSUITE_CONFIG.SYNC_OPTIONS.CROSS_SUBSIDIARY_CUSTOMERS)} + onCloseError={() => Policy.clearNetSuiteErrorField(policyID, CONST.NETSUITE_CONFIG.SYNC_OPTIONS.CROSS_SUBSIDIARY_CUSTOMERS)} + /> + + + + ${parser.replace( + translate(`workspace.netsuite.import.importFields.${importField}.subtitle` as TranslationPaths), + )}`} + /> + + + ), + [styles.ph5, styles.mt2, styles.mb4, styles.flexRow, importField, translate, netsuiteConfig, policyID], + ); + + const inputOptions = [CONST.INTEGRATION_ENTITY_MAP_TYPES.TAG, CONST.INTEGRATION_ENTITY_MAP_TYPES.REPORT_FIELD]; + + + const inputSectionData: ImportListItem[] = + inputOptions.map((inputOption) => ({ + text: translate(`workspace.netsuite.import.importTypes.${inputOption}.label`), + keyForList: inputOption, + isSelected: importValue === inputOption, + value: inputOption, + alternateText: translate(`workspace.netsuite.import.importTypes.${inputOption}.description`), + })) ?? []; + + const titleKey = `workspace.netsuite.import.importFields.${importField}.title` as TranslationPaths; + + const updateImportMapping = useCallback( + ({value}: ImportListItem) => { + if (value !== importValue) { + updateNetSuiteImportMapping(policyID, importField as keyof typeof importMappings, value, importValue); + } + + Navigation.goBack(); + }, + [importField, importValue, policyID], + ); + + return ( + 0 ? [{data: inputSectionData}] : []} + listItem={RadioListItem} + connectionName={CONST.POLICY.CONNECTIONS.NAME.NETSUITE} + onSelectRow={(selection: SelectorType) => updateImportMapping(selection as ImportListItem)} + initiallyFocusedOptionKey={inputSectionData.find((inputOption) => inputOption.isSelected)?.keyForList} + headerContent={listHeaderComponent} + onBackButtonPress={() => Navigation.goBack()} + title={titleKey} + listFooterContent={listFooterContent} + /> + ); +} + +NetSuiteImportJobsPage.displayName = 'NetSuiteImportJobsPage'; + +export default withPolicyConnections(NetSuiteImportJobsPage); diff --git a/src/pages/workspace/accounting/netsuite/import/NetSuiteImportMappingPage.tsx b/src/pages/workspace/accounting/netsuite/import/NetSuiteImportMappingPage.tsx index f618c33e92d7..b76bbeed18b2 100644 --- a/src/pages/workspace/accounting/netsuite/import/NetSuiteImportMappingPage.tsx +++ b/src/pages/workspace/accounting/netsuite/import/NetSuiteImportMappingPage.tsx @@ -9,13 +9,10 @@ import SelectionScreen from '@components/SelectionScreen'; import Text from '@components/Text'; import useLocalize from '@hooks/useLocalize'; import useThemeStyles from '@hooks/useThemeStyles'; -import {updateNetSuiteCrossSubsidiaryCustomersConfiguration, updateNetSuiteImportMapping} from '@libs/actions/connections/NetSuiteCommands'; -import * as ErrorUtils from '@libs/ErrorUtils'; +import {updateNetSuiteImportMapping} from '@libs/actions/connections/NetSuiteCommands'; import Navigation from '@libs/Navigation/Navigation'; import withPolicyConnections from '@pages/workspace/withPolicyConnections'; import type {WithPolicyConnectionsProps} from '@pages/workspace/withPolicyConnections'; -import ToggleSettingOptionRow from '@pages/workspace/workflows/ToggleSettingsOptionRow'; -import * as Policy from '@userActions/Policy/Policy'; import CONST from '@src/CONST'; import type {TranslationPaths} from '@src/languages/types'; @@ -62,22 +59,7 @@ function NetSuiteImportMappingPage({ const listHeaderComponent = useMemo( () => ( - {importField === 'jobs' && ( - - { - updateNetSuiteCrossSubsidiaryCustomersConfiguration(policyID, isEnabled); - }} - pendingAction={netsuiteConfig?.syncOptions?.pendingFields?.crossSubsidiaryCustomers} - errors={ErrorUtils.getLatestErrorField(netsuiteConfig ?? {}, CONST.NETSUITE_CONFIG.SYNC_OPTIONS.CROSS_SUBSIDIARY_CUSTOMERS)} - onCloseError={() => Policy.clearNetSuiteErrorField(policyID, CONST.NETSUITE_CONFIG.SYNC_OPTIONS.CROSS_SUBSIDIARY_CUSTOMERS)} - /> - - )} - + ${parser.replace( @@ -87,20 +69,10 @@ function NetSuiteImportMappingPage({ ), - [styles.ph5, styles.mt2, styles.mb4, styles.flexRow, importField, translate, netsuiteConfig, policyID], + [styles.ph5, styles.mt2, styles.mb4, styles.flexRow, importField, translate], ); - const inputOptions = useMemo(() => { - switch (importField) { - case 'departments': - case 'classes': - case 'locations': - return [CONST.INTEGRATION_ENTITY_MAP_TYPES.NETSUITE_DEFAULT, CONST.INTEGRATION_ENTITY_MAP_TYPES.TAG, CONST.INTEGRATION_ENTITY_MAP_TYPES.REPORT_FIELD]; - - default: - return [CONST.INTEGRATION_ENTITY_MAP_TYPES.TAG, CONST.INTEGRATION_ENTITY_MAP_TYPES.REPORT_FIELD]; - } - }, [importField]); + const inputOptions = [CONST.INTEGRATION_ENTITY_MAP_TYPES.NETSUITE_DEFAULT, CONST.INTEGRATION_ENTITY_MAP_TYPES.TAG, CONST.INTEGRATION_ENTITY_MAP_TYPES.REPORT_FIELD]; const inputSectionData: ImportListItem[] = inputOptions.map((inputOption) => ({ diff --git a/src/pages/workspace/accounting/netsuite/import/NetSuiteImportPage.tsx b/src/pages/workspace/accounting/netsuite/import/NetSuiteImportPage.tsx index fe7afe7779c1..87bc554a858a 100644 --- a/src/pages/workspace/accounting/netsuite/import/NetSuiteImportPage.tsx +++ b/src/pages/workspace/accounting/netsuite/import/NetSuiteImportPage.tsx @@ -71,6 +71,26 @@ function NetSuiteImportPage({policy}: WithPolicyConnectionsProps) { /> ))} + + { + Policy.clearNetSuiteErrorField(policyID, CONST.NETSUITE_CONFIG.SYNC_OPTIONS.MAPPING.CUSTOMERS); + Policy.clearNetSuiteErrorField(policyID, CONST.NETSUITE_CONFIG.SYNC_OPTIONS.MAPPING.JOBS); + }} + > + { + Navigation.navigate(ROUTES.POLICY_ACCOUNTING_NETSUITE_IMPORT_JOBS.getRoute(policyID)); + }} + brickRoadIndicator={!!config?.errorFields?.customers || !!config?.errorFields?.jobs ? CONST.BRICK_ROAD_INDICATOR_STATUS.ERROR : undefined} + /> + {canUseTaxNetSuite(canUseNetSuiteUSATax, selectedSubsidiary?.country) && ( From fb66be5f42fa662a029a0a671db6c8ab8367a639 Mon Sep 17 00:00:00 2001 From: Manan Jadhav Date: Thu, 4 Jul 2024 02:09:49 +0530 Subject: [PATCH 29/47] feat: added menu items --- src/CONST.ts | 4 +- src/ROUTES.ts | 3 +- src/languages/en.ts | 5 +- src/languages/es.ts | 5 +- src/libs/PolicyUtils.ts | 9 + .../import/NetSuiteImportJobsPage.tsx | 179 +++++++++--------- .../import/NetSuiteImportMappingPage.tsx | 1 - .../netsuite/import/NetSuiteImportPage.tsx | 40 ++-- 8 files changed, 128 insertions(+), 118 deletions(-) diff --git a/src/CONST.ts b/src/CONST.ts index 6b3b85f61d4e..481059def33e 100755 --- a/src/CONST.ts +++ b/src/CONST.ts @@ -1379,8 +1379,8 @@ const CONST = { CROSS_SUBSIDIARY_CUSTOMERS: 'crossSubsidiaryCustomers', MAPPING: { CUSTOMERS: 'customers', - JOBS: 'jobs' - } + JOBS: 'jobs', + }, }, }, diff --git a/src/ROUTES.ts b/src/ROUTES.ts index fb49c0b54382..b88d2c5e5f27 100644 --- a/src/ROUTES.ts +++ b/src/ROUTES.ts @@ -971,8 +971,7 @@ const ROUTES = { }, POLICY_ACCOUNTING_NETSUITE_IMPORT_JOBS: { route: 'settings/workspaces/:policyID/accounting/netsuite/import/jobs/', - getRoute: (policyID: string) => - `settings/workspaces/${policyID}/accounting/netsuite/import/jobs` as const, + getRoute: (policyID: string) => `settings/workspaces/${policyID}/accounting/netsuite/import/jobs` as const, }, POLICY_ACCOUNTING_NETSUITE_EXPORT: { route: 'settings/workspaces/:policyID/connections/netsuite/export/', diff --git a/src/languages/en.ts b/src/languages/en.ts index 6d58734b9222..52e9d22d61e4 100755 --- a/src/languages/en.ts +++ b/src/languages/en.ts @@ -2318,7 +2318,10 @@ export default { }, }, customersOrJobs: { - title: 'Customers / projects (jobs)', + title: 'Customers / projects', + subtitle: 'Choose how to handle NetSuite *customers* and *projects* in Expensify.', + importCustomers: 'Import customers', + importJobs: 'Import projects', }, importTaxDescription: 'Import tax groups from NetSuite', importCustomFields: { diff --git a/src/languages/es.ts b/src/languages/es.ts index f7fd4f430872..9f11ae9ca5f3 100644 --- a/src/languages/es.ts +++ b/src/languages/es.ts @@ -2350,7 +2350,10 @@ export default { }, }, customersOrJobs: { - title: 'Clientes / proyectos (trabajos)', + title: 'Clientes / proyectos', + subtitle: 'Elija cómo manejar los *clientes* y *proyectos* de NetSuite en Expensify.', + importCustomers: 'Importar clientes', + importJobs: 'Importar proyectos', }, importTaxDescription: 'Importar grupos de impuestos desde NetSuite', importCustomFields: { diff --git a/src/libs/PolicyUtils.ts b/src/libs/PolicyUtils.ts index 5bd496ab9d39..501311b12b42 100644 --- a/src/libs/PolicyUtils.ts +++ b/src/libs/PolicyUtils.ts @@ -536,6 +536,14 @@ function canUseProvincialTaxNetSuite(subsidiaryCountry?: string) { return subsidiaryCountry === '_canada'; } +function getCustomersOrJobsLabelNetSuite(policy: Policy | undefined): string | undefined { + const importMapping = policy?.connections?.netsuite?.options?.config?.syncOptions?.mapping; + if (!importMapping?.customers && !importMapping?.jobs) { + return undefined; + } + return 'Test'; +} + function getIntegrationLastSuccessfulDate(connection?: Connections[keyof Connections]) { if (!connection) { return undefined; @@ -652,6 +660,7 @@ export { navigateWhenEnableFeature, getIntegrationLastSuccessfulDate, getCurrentConnectionName, + getCustomersOrJobsLabelNetSuite, }; export type {MemberEmailsToAccountIDs}; diff --git a/src/pages/workspace/accounting/netsuite/import/NetSuiteImportJobsPage.tsx b/src/pages/workspace/accounting/netsuite/import/NetSuiteImportJobsPage.tsx index c9c207ab0e2e..ad07d526e5b8 100644 --- a/src/pages/workspace/accounting/netsuite/import/NetSuiteImportJobsPage.tsx +++ b/src/pages/workspace/accounting/netsuite/import/NetSuiteImportJobsPage.tsx @@ -1,15 +1,13 @@ import {ExpensiMark} from 'expensify-common'; -import React, {useCallback, useMemo} from 'react'; +import React from 'react'; import {View} from 'react-native'; -import type {ValueOf} from 'type-fest'; +import ConnectionLayout from '@components/ConnectionLayout'; +import MenuItemWithTopDescription from '@components/MenuItemWithTopDescription'; +import OfflineWithFeedback from '@components/OfflineWithFeedback'; import RenderHTML from '@components/RenderHTML'; -import RadioListItem from '@components/SelectionList/RadioListItem'; -import type {SelectorType} from '@components/SelectionScreen'; -import SelectionScreen from '@components/SelectionScreen'; -import Text from '@components/Text'; import useLocalize from '@hooks/useLocalize'; import useThemeStyles from '@hooks/useThemeStyles'; -import {updateNetSuiteCrossSubsidiaryCustomersConfiguration, updateNetSuiteImportMapping} from '@libs/actions/connections/NetSuiteCommands'; +import {updateNetSuiteCrossSubsidiaryCustomersConfiguration} from '@libs/actions/connections/NetSuiteCommands'; import * as ErrorUtils from '@libs/ErrorUtils'; import Navigation from '@libs/Navigation/Navigation'; import withPolicyConnections from '@pages/workspace/withPolicyConnections'; @@ -18,106 +16,101 @@ import ToggleSettingOptionRow from '@pages/workspace/workflows/ToggleSettingsOpt import * as Policy from '@userActions/Policy/Policy'; import CONST from '@src/CONST'; import type {TranslationPaths} from '@src/languages/types'; +import ROUTES from '@src/ROUTES'; const parser = new ExpensiMark(); -type ImportListItem = SelectorType & { - value: ValueOf; -}; - -function NetSuiteImportJobsPage({ - policy -}: WithPolicyConnectionsProps) { +function NetSuiteImportJobsPage({policy}: WithPolicyConnectionsProps) { const policyID = policy?.id ?? '-1'; const styles = useThemeStyles(); const {translate} = useLocalize(); - const importField = 'locations'; - const netsuiteConfig = policy?.connections?.netsuite?.options?.config; - const importMappings = netsuiteConfig?.syncOptions?.mapping; + const config = policy?.connections?.netsuite?.options?.config; + const importMappings = config?.syncOptions?.mapping; + const importedValue = importMappings?.customers ?? importMappings?.jobs ?? CONST.INTEGRATION_ENTITY_MAP_TYPES.NETSUITE_DEFAULT; - const importValue = importMappings?.[importField] ?? CONST.INTEGRATION_ENTITY_MAP_TYPES.NETSUITE_DEFAULT; + return ( + + + ${parser.replace(translate(`workspace.netsuite.import.customersOrJobs.subtitle` as TranslationPaths))}`} /> + - const listFooterContent = useMemo( - () => ( - - {translate(`workspace.netsuite.import.importTypes.${importValue}.footerContent`, importField)} + + { + updateNetSuiteCrossSubsidiaryCustomersConfiguration(policyID, isEnabled); + }} + pendingAction={config?.syncOptions?.pendingFields?.crossSubsidiaryCustomers} + errors={ErrorUtils.getLatestErrorField(config ?? {}, CONST.NETSUITE_CONFIG.SYNC_OPTIONS.CROSS_SUBSIDIARY_CUSTOMERS)} + onCloseError={() => Policy.clearNetSuiteErrorField(policyID, CONST.NETSUITE_CONFIG.SYNC_OPTIONS.CROSS_SUBSIDIARY_CUSTOMERS)} + /> - ), - [importField, importValue, styles.mb4, styles.mt2, styles.ph5, translate], - ); - const listHeaderComponent = useMemo( - () => ( - - - - { - updateNetSuiteCrossSubsidiaryCustomersConfiguration(policyID, isEnabled); - }} - pendingAction={netsuiteConfig?.syncOptions?.pendingFields?.crossSubsidiaryCustomers} - errors={ErrorUtils.getLatestErrorField(netsuiteConfig ?? {}, CONST.NETSUITE_CONFIG.SYNC_OPTIONS.CROSS_SUBSIDIARY_CUSTOMERS)} - onCloseError={() => Policy.clearNetSuiteErrorField(policyID, CONST.NETSUITE_CONFIG.SYNC_OPTIONS.CROSS_SUBSIDIARY_CUSTOMERS)} - /> - + + { + updateNetSuiteCrossSubsidiaryCustomersConfiguration(policyID, isEnabled); + }} + pendingAction={config?.syncOptions?.pendingFields?.crossSubsidiaryCustomers} + errors={ErrorUtils.getLatestErrorField(config ?? {}, CONST.NETSUITE_CONFIG.SYNC_OPTIONS.CROSS_SUBSIDIARY_CUSTOMERS)} + onCloseError={() => Policy.clearNetSuiteErrorField(policyID, CONST.NETSUITE_CONFIG.SYNC_OPTIONS.CROSS_SUBSIDIARY_CUSTOMERS)} + /> + + + { + updateNetSuiteCrossSubsidiaryCustomersConfiguration(policyID, isEnabled); + }} + pendingAction={config?.syncOptions?.pendingFields?.crossSubsidiaryCustomers} + errors={ErrorUtils.getLatestErrorField(config ?? {}, CONST.NETSUITE_CONFIG.SYNC_OPTIONS.CROSS_SUBSIDIARY_CUSTOMERS)} + onCloseError={() => Policy.clearNetSuiteErrorField(policyID, CONST.NETSUITE_CONFIG.SYNC_OPTIONS.CROSS_SUBSIDIARY_CUSTOMERS)} + /> + - - ${parser.replace( - translate(`workspace.netsuite.import.importFields.${importField}.subtitle` as TranslationPaths), - )}`} + + { + Policy.clearNetSuiteErrorField(policyID, CONST.NETSUITE_CONFIG.SYNC_OPTIONS.MAPPING.CUSTOMERS); + Policy.clearNetSuiteErrorField(policyID, CONST.NETSUITE_CONFIG.SYNC_OPTIONS.MAPPING.JOBS); + }} + > + { + Navigation.navigate(ROUTES.POLICY_ACCOUNTING_NETSUITE_IMPORT_JOBS.getRoute(policyID)); + }} + brickRoadIndicator={!!config?.errorFields?.customers || !!config?.errorFields?.jobs ? CONST.BRICK_ROAD_INDICATOR_STATUS.ERROR : undefined} /> - + - ), - [styles.ph5, styles.mt2, styles.mb4, styles.flexRow, importField, translate, netsuiteConfig, policyID], - ); - - const inputOptions = [CONST.INTEGRATION_ENTITY_MAP_TYPES.TAG, CONST.INTEGRATION_ENTITY_MAP_TYPES.REPORT_FIELD]; - - - const inputSectionData: ImportListItem[] = - inputOptions.map((inputOption) => ({ - text: translate(`workspace.netsuite.import.importTypes.${inputOption}.label`), - keyForList: inputOption, - isSelected: importValue === inputOption, - value: inputOption, - alternateText: translate(`workspace.netsuite.import.importTypes.${inputOption}.description`), - })) ?? []; - - const titleKey = `workspace.netsuite.import.importFields.${importField}.title` as TranslationPaths; - - const updateImportMapping = useCallback( - ({value}: ImportListItem) => { - if (value !== importValue) { - updateNetSuiteImportMapping(policyID, importField as keyof typeof importMappings, value, importValue); - } - - Navigation.goBack(); - }, - [importField, importValue, policyID], - ); - - return ( - 0 ? [{data: inputSectionData}] : []} - listItem={RadioListItem} - connectionName={CONST.POLICY.CONNECTIONS.NAME.NETSUITE} - onSelectRow={(selection: SelectorType) => updateImportMapping(selection as ImportListItem)} - initiallyFocusedOptionKey={inputSectionData.find((inputOption) => inputOption.isSelected)?.keyForList} - headerContent={listHeaderComponent} - onBackButtonPress={() => Navigation.goBack()} - title={titleKey} - listFooterContent={listFooterContent} - /> + ); } diff --git a/src/pages/workspace/accounting/netsuite/import/NetSuiteImportMappingPage.tsx b/src/pages/workspace/accounting/netsuite/import/NetSuiteImportMappingPage.tsx index b76bbeed18b2..49916dc9e08e 100644 --- a/src/pages/workspace/accounting/netsuite/import/NetSuiteImportMappingPage.tsx +++ b/src/pages/workspace/accounting/netsuite/import/NetSuiteImportMappingPage.tsx @@ -59,7 +59,6 @@ function NetSuiteImportMappingPage({ const listHeaderComponent = useMemo( () => ( - ${parser.replace( diff --git a/src/pages/workspace/accounting/netsuite/import/NetSuiteImportPage.tsx b/src/pages/workspace/accounting/netsuite/import/NetSuiteImportPage.tsx index 87bc554a858a..456f53cab041 100644 --- a/src/pages/workspace/accounting/netsuite/import/NetSuiteImportPage.tsx +++ b/src/pages/workspace/accounting/netsuite/import/NetSuiteImportPage.tsx @@ -9,6 +9,7 @@ import useThemeStyles from '@hooks/useThemeStyles'; import {updateNetSuiteSyncTaxConfiguration} from '@libs/actions/connections/NetSuiteCommands'; import * as ErrorUtils from '@libs/ErrorUtils'; import Navigation from '@libs/Navigation/Navigation'; +import * as PolicyUtils from '@libs/PolicyUtils'; import {canUseTaxNetSuite} from '@libs/PolicyUtils'; import withPolicyConnections from '@pages/workspace/withPolicyConnections'; import type {WithPolicyConnectionsProps} from '@pages/workspace/withPolicyConnections'; @@ -72,25 +73,28 @@ function NetSuiteImportPage({policy}: WithPolicyConnectionsProps) { ))} - { - Policy.clearNetSuiteErrorField(policyID, CONST.NETSUITE_CONFIG.SYNC_OPTIONS.MAPPING.CUSTOMERS); - Policy.clearNetSuiteErrorField(policyID, CONST.NETSUITE_CONFIG.SYNC_OPTIONS.MAPPING.JOBS); + { + Policy.clearNetSuiteErrorField(policyID, CONST.NETSUITE_CONFIG.SYNC_OPTIONS.MAPPING.CUSTOMERS); + Policy.clearNetSuiteErrorField(policyID, CONST.NETSUITE_CONFIG.SYNC_OPTIONS.MAPPING.JOBS); + }} + > + { + Navigation.navigate(ROUTES.POLICY_ACCOUNTING_NETSUITE_IMPORT_JOBS.getRoute(policyID)); }} - > - { - Navigation.navigate(ROUTES.POLICY_ACCOUNTING_NETSUITE_IMPORT_JOBS.getRoute(policyID)); - }} - brickRoadIndicator={!!config?.errorFields?.customers || !!config?.errorFields?.jobs ? CONST.BRICK_ROAD_INDICATOR_STATUS.ERROR : undefined} - /> - + brickRoadIndicator={!!config?.errorFields?.customers || !!config?.errorFields?.jobs ? CONST.BRICK_ROAD_INDICATOR_STATUS.ERROR : undefined} + /> + {canUseTaxNetSuite(canUseNetSuiteUSATax, selectedSubsidiary?.country) && ( From bf06c5a2e389d339c45fafe7054971e22332c181 Mon Sep 17 00:00:00 2001 From: Manan Jadhav Date: Thu, 4 Jul 2024 02:16:36 +0530 Subject: [PATCH 30/47] refactor: code cleanup --- .../netsuite/import/NetSuiteImportJobsPage.tsx | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/pages/workspace/accounting/netsuite/import/NetSuiteImportJobsPage.tsx b/src/pages/workspace/accounting/netsuite/import/NetSuiteImportJobsPage.tsx index ad07d526e5b8..5a81330426ce 100644 --- a/src/pages/workspace/accounting/netsuite/import/NetSuiteImportJobsPage.tsx +++ b/src/pages/workspace/accounting/netsuite/import/NetSuiteImportJobsPage.tsx @@ -48,28 +48,28 @@ function NetSuiteImportJobsPage({policy}: WithPolicyConnectionsProps) { { updateNetSuiteCrossSubsidiaryCustomersConfiguration(policyID, isEnabled); }} - pendingAction={config?.syncOptions?.pendingFields?.crossSubsidiaryCustomers} - errors={ErrorUtils.getLatestErrorField(config ?? {}, CONST.NETSUITE_CONFIG.SYNC_OPTIONS.CROSS_SUBSIDIARY_CUSTOMERS)} - onCloseError={() => Policy.clearNetSuiteErrorField(policyID, CONST.NETSUITE_CONFIG.SYNC_OPTIONS.CROSS_SUBSIDIARY_CUSTOMERS)} + pendingAction={config?.syncOptions?.mapping?.pendingFields?.customers} + errors={ErrorUtils.getLatestErrorField(config ?? {}, CONST.NETSUITE_CONFIG.SYNC_OPTIONS.MAPPING.CUSTOMERS)} + onCloseError={() => Policy.clearNetSuiteErrorField(policyID, CONST.NETSUITE_CONFIG.SYNC_OPTIONS.MAPPING.CUSTOMERS)} /> { updateNetSuiteCrossSubsidiaryCustomersConfiguration(policyID, isEnabled); }} - pendingAction={config?.syncOptions?.pendingFields?.crossSubsidiaryCustomers} - errors={ErrorUtils.getLatestErrorField(config ?? {}, CONST.NETSUITE_CONFIG.SYNC_OPTIONS.CROSS_SUBSIDIARY_CUSTOMERS)} - onCloseError={() => Policy.clearNetSuiteErrorField(policyID, CONST.NETSUITE_CONFIG.SYNC_OPTIONS.CROSS_SUBSIDIARY_CUSTOMERS)} + pendingAction={config?.syncOptions?.mapping?.pendingFields?.jobs} + errors={ErrorUtils.getLatestErrorField(config ?? {}, CONST.NETSUITE_CONFIG.SYNC_OPTIONS.MAPPING.JOBS)} + onCloseError={() => Policy.clearNetSuiteErrorField(policyID, CONST.NETSUITE_CONFIG.SYNC_OPTIONS.MAPPING.JOBS)} /> From 92aa8aaca665a8e80fee311042ca9b50dd2e78ee Mon Sep 17 00:00:00 2001 From: Manan Jadhav Date: Thu, 4 Jul 2024 02:51:20 +0530 Subject: [PATCH 31/47] feat: update toggle api calls --- .../actions/connections/NetSuiteCommands.ts | 2 +- .../import/NetSuiteImportJobsPage.tsx | 37 ++++++++++++++++--- .../import/NetSuiteImportMappingPage.tsx | 10 ++--- 3 files changed, 36 insertions(+), 13 deletions(-) diff --git a/src/libs/actions/connections/NetSuiteCommands.ts b/src/libs/actions/connections/NetSuiteCommands.ts index 433fd57bd357..c442dab847ef 100644 --- a/src/libs/actions/connections/NetSuiteCommands.ts +++ b/src/libs/actions/connections/NetSuiteCommands.ts @@ -267,7 +267,7 @@ function updateNetSuiteImportMapping, - oldMappingValue: ValueOf, + oldMappingValue?: ValueOf, ) { const onyxData: OnyxData = { optimisticData: [ diff --git a/src/pages/workspace/accounting/netsuite/import/NetSuiteImportJobsPage.tsx b/src/pages/workspace/accounting/netsuite/import/NetSuiteImportJobsPage.tsx index 5a81330426ce..cd1ed3d3f4ab 100644 --- a/src/pages/workspace/accounting/netsuite/import/NetSuiteImportJobsPage.tsx +++ b/src/pages/workspace/accounting/netsuite/import/NetSuiteImportJobsPage.tsx @@ -1,5 +1,5 @@ import {ExpensiMark} from 'expensify-common'; -import React from 'react'; +import React, {useCallback} from 'react'; import {View} from 'react-native'; import ConnectionLayout from '@components/ConnectionLayout'; import MenuItemWithTopDescription from '@components/MenuItemWithTopDescription'; @@ -7,7 +7,7 @@ import OfflineWithFeedback from '@components/OfflineWithFeedback'; import RenderHTML from '@components/RenderHTML'; import useLocalize from '@hooks/useLocalize'; import useThemeStyles from '@hooks/useThemeStyles'; -import {updateNetSuiteCrossSubsidiaryCustomersConfiguration} from '@libs/actions/connections/NetSuiteCommands'; +import {updateNetSuiteCrossSubsidiaryCustomersConfiguration, updateNetSuiteImportMapping} from '@libs/actions/connections/NetSuiteCommands'; import * as ErrorUtils from '@libs/ErrorUtils'; import Navigation from '@libs/Navigation/Navigation'; import withPolicyConnections from '@pages/workspace/withPolicyConnections'; @@ -20,6 +20,8 @@ import ROUTES from '@src/ROUTES'; const parser = new ExpensiMark(); +type ImportField = 'jobs' | 'customers'; + function NetSuiteImportJobsPage({policy}: WithPolicyConnectionsProps) { const policyID = policy?.id ?? '-1'; const styles = useThemeStyles(); @@ -27,7 +29,32 @@ function NetSuiteImportJobsPage({policy}: WithPolicyConnectionsProps) { const config = policy?.connections?.netsuite?.options?.config; const importMappings = config?.syncOptions?.mapping; - const importedValue = importMappings?.customers ?? importMappings?.jobs ?? CONST.INTEGRATION_ENTITY_MAP_TYPES.NETSUITE_DEFAULT; + const importCustomer = importMappings?.customers ?? CONST.INTEGRATION_ENTITY_MAP_TYPES.NETSUITE_DEFAULT; + const importJobs = importMappings?.jobs ?? CONST.INTEGRATION_ENTITY_MAP_TYPES.NETSUITE_DEFAULT; + const importedValue = importMappings?.customers !== CONST.INTEGRATION_ENTITY_MAP_TYPES.NETSUITE_DEFAULT ? importCustomer : importJobs; + + const updateMapping = useCallback( + (importField: ImportField, isEnabled: boolean) => { + let newValue; + if (!isEnabled) { + // if the import is off, then we send default as the value for mapping + newValue = CONST.INTEGRATION_ENTITY_MAP_TYPES.NETSUITE_DEFAULT; + } else { + // when we enable any field, and if the other one already has a value set, we should set that, + const otherFieldValue = importField === 'jobs' ? config?.syncOptions?.mapping?.customers : config?.syncOptions?.mapping?.jobs; + if (otherFieldValue === CONST.INTEGRATION_ENTITY_MAP_TYPES.NETSUITE_DEFAULT) { + newValue = CONST.INTEGRATION_ENTITY_MAP_TYPES.TAG; + } else { + // else fallback to Tag + newValue = otherFieldValue; + } + } + if (newValue) { + updateNetSuiteImportMapping(policyID, importField, newValue, config?.syncOptions?.mapping?.[importField]); + } + }, + [config?.syncOptions?.mapping, policyID], + ); return ( { - updateNetSuiteCrossSubsidiaryCustomersConfiguration(policyID, isEnabled); + updateMapping('customers', isEnabled); }} pendingAction={config?.syncOptions?.mapping?.pendingFields?.customers} errors={ErrorUtils.getLatestErrorField(config ?? {}, CONST.NETSUITE_CONFIG.SYNC_OPTIONS.MAPPING.CUSTOMERS)} @@ -65,7 +92,7 @@ function NetSuiteImportJobsPage({policy}: WithPolicyConnectionsProps) { isActive={(config?.syncOptions?.mapping?.jobs ?? CONST.INTEGRATION_ENTITY_MAP_TYPES.NETSUITE_DEFAULT) !== CONST.INTEGRATION_ENTITY_MAP_TYPES.NETSUITE_DEFAULT} switchAccessibilityLabel={translate('workspace.netsuite.import.customersOrJobs.importJobs')} onToggle={(isEnabled: boolean) => { - updateNetSuiteCrossSubsidiaryCustomersConfiguration(policyID, isEnabled); + updateMapping('jobs', isEnabled); }} pendingAction={config?.syncOptions?.mapping?.pendingFields?.jobs} errors={ErrorUtils.getLatestErrorField(config ?? {}, CONST.NETSUITE_CONFIG.SYNC_OPTIONS.MAPPING.JOBS)} diff --git a/src/pages/workspace/accounting/netsuite/import/NetSuiteImportMappingPage.tsx b/src/pages/workspace/accounting/netsuite/import/NetSuiteImportMappingPage.tsx index 49916dc9e08e..4d868e98b8ae 100644 --- a/src/pages/workspace/accounting/netsuite/import/NetSuiteImportMappingPage.tsx +++ b/src/pages/workspace/accounting/netsuite/import/NetSuiteImportMappingPage.tsx @@ -58,17 +58,13 @@ function NetSuiteImportMappingPage({ const listHeaderComponent = useMemo( () => ( - + - ${parser.replace( - translate(`workspace.netsuite.import.importFields.${importField}.subtitle` as TranslationPaths), - )}`} - /> + ${parser.replace(translate(`workspace.netsuite.import.importFields.${importField}.subtitle` as TranslationPaths))}`} /> ), - [styles.ph5, styles.mt2, styles.mb4, styles.flexRow, importField, translate], + [styles.ph5, styles.mt2, styles.mb8, styles.flexRow, translate, importField], ); const inputOptions = [CONST.INTEGRATION_ENTITY_MAP_TYPES.NETSUITE_DEFAULT, CONST.INTEGRATION_ENTITY_MAP_TYPES.TAG, CONST.INTEGRATION_ENTITY_MAP_TYPES.REPORT_FIELD]; From 441ab6f2cea5f6ad485bf17d974ea5232111b3a1 Mon Sep 17 00:00:00 2001 From: Manan Jadhav Date: Thu, 4 Jul 2024 02:54:06 +0530 Subject: [PATCH 32/47] feat: hide displayed as conditionally --- .../import/NetSuiteImportJobsPage.tsx | 48 ++++++++++--------- 1 file changed, 25 insertions(+), 23 deletions(-) diff --git a/src/pages/workspace/accounting/netsuite/import/NetSuiteImportJobsPage.tsx b/src/pages/workspace/accounting/netsuite/import/NetSuiteImportJobsPage.tsx index cd1ed3d3f4ab..f838389a33c3 100644 --- a/src/pages/workspace/accounting/netsuite/import/NetSuiteImportJobsPage.tsx +++ b/src/pages/workspace/accounting/netsuite/import/NetSuiteImportJobsPage.tsx @@ -113,30 +113,32 @@ function NetSuiteImportJobsPage({policy}: WithPolicyConnectionsProps) { /> - - { - Policy.clearNetSuiteErrorField(policyID, CONST.NETSUITE_CONFIG.SYNC_OPTIONS.MAPPING.CUSTOMERS); - Policy.clearNetSuiteErrorField(policyID, CONST.NETSUITE_CONFIG.SYNC_OPTIONS.MAPPING.JOBS); - }} - > - { - Navigation.navigate(ROUTES.POLICY_ACCOUNTING_NETSUITE_IMPORT_JOBS.getRoute(policyID)); + {importedValue !== CONST.INTEGRATION_ENTITY_MAP_TYPES.NETSUITE_DEFAULT && ( + + { + Policy.clearNetSuiteErrorField(policyID, CONST.NETSUITE_CONFIG.SYNC_OPTIONS.MAPPING.CUSTOMERS); + Policy.clearNetSuiteErrorField(policyID, CONST.NETSUITE_CONFIG.SYNC_OPTIONS.MAPPING.JOBS); }} - brickRoadIndicator={!!config?.errorFields?.customers || !!config?.errorFields?.jobs ? CONST.BRICK_ROAD_INDICATOR_STATUS.ERROR : undefined} - /> - - + > + { + Navigation.navigate(ROUTES.POLICY_ACCOUNTING_NETSUITE_IMPORT_JOBS.getRoute(policyID)); + }} + brickRoadIndicator={!!config?.errorFields?.customers || !!config?.errorFields?.jobs ? CONST.BRICK_ROAD_INDICATOR_STATUS.ERROR : undefined} + /> + + + )} ); } From 29d8a83097419e28f58c82bfeae7b747548750ec Mon Sep 17 00:00:00 2001 From: Manan Jadhav Date: Thu, 4 Jul 2024 02:57:06 +0530 Subject: [PATCH 33/47] refactor: rename file --- .../AppNavigator/ModalStackNavigators/index.tsx | 2 +- ...Page.tsx => NetSuiteImportCustomersOrProjectsPage.tsx} | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) rename src/pages/workspace/accounting/netsuite/import/{NetSuiteImportJobsPage.tsx => NetSuiteImportCustomersOrProjectsPage.tsx} (96%) diff --git a/src/libs/Navigation/AppNavigator/ModalStackNavigators/index.tsx b/src/libs/Navigation/AppNavigator/ModalStackNavigators/index.tsx index 79618d9f07d8..5af0d8c218d9 100644 --- a/src/libs/Navigation/AppNavigator/ModalStackNavigators/index.tsx +++ b/src/libs/Navigation/AppNavigator/ModalStackNavigators/index.tsx @@ -322,7 +322,7 @@ const SettingsModalStackNavigator = createModalStackNavigator require('../../../../pages/workspace/accounting/netsuite/NetSuiteSubsidiarySelector').default, [SCREENS.WORKSPACE.ACCOUNTING.NETSUITE_IMPORT]: () => require('../../../../pages/workspace/accounting/netsuite/import/NetSuiteImportPage').default, [SCREENS.WORKSPACE.ACCOUNTING.NETSUITE_IMPORT_MAPPING]: () => require('../../../../pages/workspace/accounting/netsuite/import/NetSuiteImportMappingPage').default, - [SCREENS.WORKSPACE.ACCOUNTING.NETSUITE_IMPORT_JOBS]: () => require('../../../../pages/workspace/accounting/netsuite/import/NetSuiteImportJobsPage').default, + [SCREENS.WORKSPACE.ACCOUNTING.NETSUITE_IMPORT_JOBS]: () => require('../../../../pages/workspace/accounting/netsuite/import/NetSuiteImportCustomersOrProjectsPage').default, [SCREENS.WORKSPACE.ACCOUNTING.NETSUITE_EXPORT]: () => require('../../../../pages/workspace/accounting/netsuite/export/NetSuiteExportConfigurationPage').default, [SCREENS.WORKSPACE.ACCOUNTING.NETSUITE_PREFERRED_EXPORTER_SELECT]: () => require('../../../../pages/workspace/accounting/netsuite/export/NetSuitePreferredExporterSelectPage').default, diff --git a/src/pages/workspace/accounting/netsuite/import/NetSuiteImportJobsPage.tsx b/src/pages/workspace/accounting/netsuite/import/NetSuiteImportCustomersOrProjectsPage.tsx similarity index 96% rename from src/pages/workspace/accounting/netsuite/import/NetSuiteImportJobsPage.tsx rename to src/pages/workspace/accounting/netsuite/import/NetSuiteImportCustomersOrProjectsPage.tsx index f838389a33c3..b469c4f92987 100644 --- a/src/pages/workspace/accounting/netsuite/import/NetSuiteImportJobsPage.tsx +++ b/src/pages/workspace/accounting/netsuite/import/NetSuiteImportCustomersOrProjectsPage.tsx @@ -22,7 +22,7 @@ const parser = new ExpensiMark(); type ImportField = 'jobs' | 'customers'; -function NetSuiteImportJobsPage({policy}: WithPolicyConnectionsProps) { +function NetSuiteImportCustomersOrProjectsPage({policy}: WithPolicyConnectionsProps) { const policyID = policy?.id ?? '-1'; const styles = useThemeStyles(); const {translate} = useLocalize(); @@ -58,7 +58,7 @@ function NetSuiteImportJobsPage({policy}: WithPolicyConnectionsProps) { return ( Date: Thu, 4 Jul 2024 03:00:19 +0530 Subject: [PATCH 34/47] refactor: rename routes --- src/ROUTES.ts | 6 +++--- src/SCREENS.ts | 2 +- .../Navigation/linkingConfig/FULL_SCREEN_TO_RHP_MAPPING.ts | 2 +- src/libs/Navigation/linkingConfig/config.ts | 2 +- src/libs/Navigation/types.ts | 2 +- .../import/NetSuiteImportCustomersOrProjectsPage.tsx | 2 +- .../accounting/netsuite/import/NetSuiteImportPage.tsx | 2 +- 7 files changed, 9 insertions(+), 9 deletions(-) diff --git a/src/ROUTES.ts b/src/ROUTES.ts index b88d2c5e5f27..bb98a8e655fb 100644 --- a/src/ROUTES.ts +++ b/src/ROUTES.ts @@ -969,9 +969,9 @@ const ROUTES = { getRoute: (policyID: string, importField: TupleToUnion) => `settings/workspaces/${policyID}/accounting/netsuite/import/mapping/${importField}` as const, }, - POLICY_ACCOUNTING_NETSUITE_IMPORT_JOBS: { - route: 'settings/workspaces/:policyID/accounting/netsuite/import/jobs/', - getRoute: (policyID: string) => `settings/workspaces/${policyID}/accounting/netsuite/import/jobs` as const, + POLICY_ACCOUNTING_NETSUITE_IMPORT_CUSTOMERS_OR_PROJECTS: { + route: 'settings/workspaces/:policyID/accounting/netsuite/import/customer-projects', + getRoute: (policyID: string) => `settings/workspaces/${policyID}/accounting/netsuite/import/customer-projects` as const, }, POLICY_ACCOUNTING_NETSUITE_EXPORT: { route: 'settings/workspaces/:policyID/connections/netsuite/export/', diff --git a/src/SCREENS.ts b/src/SCREENS.ts index 09cff0c0696c..4d49d3004d48 100644 --- a/src/SCREENS.ts +++ b/src/SCREENS.ts @@ -273,7 +273,7 @@ const SCREENS = { XERO_BILL_PAYMENT_ACCOUNT_SELECTOR: 'Policy_Accounting_Xero_Bill_Payment_Account_Selector', XERO_EXPORT_BANK_ACCOUNT_SELECT: 'Policy_Accounting_Xero_Export_Bank_Account_Select', NETSUITE_IMPORT_MAPPING: 'Policy_Accounting_NetSuite_Import_Mapping', - NETSUITE_IMPORT_JOBS: 'Policy_Accounting_NetSuite_Import_Jobs', + NETSUITE_IMPORT_CUSTOMERS_OR_PROJECTS: 'Policy_Accounting_NetSuite_Import_CustomersOrProjects', NETSUITE_SUBSIDIARY_SELECTOR: 'Policy_Accounting_NetSuite_Subsidiary_Selector', NETSUITE_IMPORT: 'Policy_Accounting_NetSuite_Import', NETSUITE_EXPORT: 'Policy_Accounting_NetSuite_Export', 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 359af8629975..632fc5696103 100755 --- a/src/libs/Navigation/linkingConfig/FULL_SCREEN_TO_RHP_MAPPING.ts +++ b/src/libs/Navigation/linkingConfig/FULL_SCREEN_TO_RHP_MAPPING.ts @@ -58,7 +58,7 @@ const FULL_SCREEN_TO_RHP_MAPPING: Partial> = { SCREENS.WORKSPACE.ACCOUNTING.NETSUITE_SUBSIDIARY_SELECTOR, SCREENS.WORKSPACE.ACCOUNTING.NETSUITE_IMPORT, SCREENS.WORKSPACE.ACCOUNTING.NETSUITE_IMPORT_MAPPING, - SCREENS.WORKSPACE.ACCOUNTING.NETSUITE_IMPORT_JOBS, + SCREENS.WORKSPACE.ACCOUNTING.NETSUITE_IMPORT_CUSTOMERS_OR_PROJECTS, SCREENS.WORKSPACE.ACCOUNTING.NETSUITE_EXPORT, SCREENS.WORKSPACE.ACCOUNTING.NETSUITE_PREFERRED_EXPORTER_SELECT, SCREENS.WORKSPACE.ACCOUNTING.NETSUITE_DATE_SELECT, diff --git a/src/libs/Navigation/linkingConfig/config.ts b/src/libs/Navigation/linkingConfig/config.ts index e5e640fd2ef4..bd8f1c11db16 100644 --- a/src/libs/Navigation/linkingConfig/config.ts +++ b/src/libs/Navigation/linkingConfig/config.ts @@ -356,7 +356,7 @@ const config: LinkingOptions['config'] = { [SCREENS.WORKSPACE.ACCOUNTING.NETSUITE_SUBSIDIARY_SELECTOR]: {path: ROUTES.POLICY_ACCOUNTING_NETSUITE_SUBSIDIARY_SELECTOR.route}, [SCREENS.WORKSPACE.ACCOUNTING.NETSUITE_IMPORT]: {path: ROUTES.POLICY_ACCOUNTING_NETSUITE_IMPORT.route}, [SCREENS.WORKSPACE.ACCOUNTING.NETSUITE_IMPORT_MAPPING]: {path: ROUTES.POLICY_ACCOUNTING_NETSUITE_IMPORT_MAPPING.route}, - [SCREENS.WORKSPACE.ACCOUNTING.NETSUITE_IMPORT_JOBS]: {path: ROUTES.POLICY_ACCOUNTING_NETSUITE_IMPORT_JOBS.route}, + [SCREENS.WORKSPACE.ACCOUNTING.NETSUITE_IMPORT_CUSTOMERS_OR_PROJECTS]: {path: ROUTES.POLICY_ACCOUNTING_NETSUITE_IMPORT_CUSTOMERS_OR_PROJECTS.route}, [SCREENS.WORKSPACE.ACCOUNTING.NETSUITE_EXPORT]: { path: ROUTES.POLICY_ACCOUNTING_NETSUITE_EXPORT.route, }, diff --git a/src/libs/Navigation/types.ts b/src/libs/Navigation/types.ts index 3ac5c6210798..7ba1de3e3949 100644 --- a/src/libs/Navigation/types.ts +++ b/src/libs/Navigation/types.ts @@ -419,7 +419,7 @@ type SettingsNavigatorParamList = { [SCREENS.WORKSPACE.ACCOUNTING.NETSUITE_IMPORT]: { policyID: string; }; - [SCREENS.WORKSPACE.ACCOUNTING.NETSUITE_IMPORT_JOBS]: { + [SCREENS.WORKSPACE.ACCOUNTING.NETSUITE_IMPORT_CUSTOMERS_OR_PROJECTS]: { policyID: string; }; [SCREENS.WORKSPACE.ACCOUNTING.NETSUITE_IMPORT_MAPPING]: { diff --git a/src/pages/workspace/accounting/netsuite/import/NetSuiteImportCustomersOrProjectsPage.tsx b/src/pages/workspace/accounting/netsuite/import/NetSuiteImportCustomersOrProjectsPage.tsx index b469c4f92987..74810338c17c 100644 --- a/src/pages/workspace/accounting/netsuite/import/NetSuiteImportCustomersOrProjectsPage.tsx +++ b/src/pages/workspace/accounting/netsuite/import/NetSuiteImportCustomersOrProjectsPage.tsx @@ -132,7 +132,7 @@ function NetSuiteImportCustomersOrProjectsPage({policy}: WithPolicyConnectionsPr title={translate(`workspace.netsuite.import.importTypes.${importedValue}.label`)} shouldShowRightIcon onPress={() => { - Navigation.navigate(ROUTES.POLICY_ACCOUNTING_NETSUITE_IMPORT_JOBS.getRoute(policyID)); + Navigation.navigate(ROUTES.POLICY_ACCOUNTING_NETSUITE_IMPORT_CUSTOMERS_OR_PROJECTS.getRoute(policyID)); }} brickRoadIndicator={!!config?.errorFields?.customers || !!config?.errorFields?.jobs ? CONST.BRICK_ROAD_INDICATOR_STATUS.ERROR : undefined} /> diff --git a/src/pages/workspace/accounting/netsuite/import/NetSuiteImportPage.tsx b/src/pages/workspace/accounting/netsuite/import/NetSuiteImportPage.tsx index 456f53cab041..a08d2d3b5686 100644 --- a/src/pages/workspace/accounting/netsuite/import/NetSuiteImportPage.tsx +++ b/src/pages/workspace/accounting/netsuite/import/NetSuiteImportPage.tsx @@ -90,7 +90,7 @@ function NetSuiteImportPage({policy}: WithPolicyConnectionsProps) { title={PolicyUtils.getCustomersOrJobsLabelNetSuite(policy)} shouldShowRightIcon onPress={() => { - Navigation.navigate(ROUTES.POLICY_ACCOUNTING_NETSUITE_IMPORT_JOBS.getRoute(policyID)); + Navigation.navigate(ROUTES.POLICY_ACCOUNTING_NETSUITE_IMPORT_CUSTOMERS_OR_PROJECTS.getRoute(policyID)); }} brickRoadIndicator={!!config?.errorFields?.customers || !!config?.errorFields?.jobs ? CONST.BRICK_ROAD_INDICATOR_STATUS.ERROR : undefined} /> From 64c12cf3efa99db2570d8047f74117f6f0015b6d Mon Sep 17 00:00:00 2001 From: Manan Jadhav Date: Thu, 4 Jul 2024 03:20:04 +0530 Subject: [PATCH 35/47] feat: added displayed as page --- src/ROUTES.ts | 4 + src/SCREENS.ts | 1 + .../ModalStackNavigators/index.tsx | 5 +- .../FULL_SCREEN_TO_RHP_MAPPING.ts | 1 + src/libs/Navigation/linkingConfig/config.ts | 1 + src/libs/Navigation/types.ts | 3 + ...uiteImportCustomersOrProjectSelectPage.tsx | 73 +++++++++++++++++++ .../NetSuiteImportCustomersOrProjectsPage.tsx | 2 +- 8 files changed, 88 insertions(+), 2 deletions(-) create mode 100644 src/pages/workspace/accounting/netsuite/import/NetSuiteImportCustomersOrProjectSelectPage.tsx diff --git a/src/ROUTES.ts b/src/ROUTES.ts index bb98a8e655fb..5d6ea30530ae 100644 --- a/src/ROUTES.ts +++ b/src/ROUTES.ts @@ -973,6 +973,10 @@ const ROUTES = { route: 'settings/workspaces/:policyID/accounting/netsuite/import/customer-projects', getRoute: (policyID: string) => `settings/workspaces/${policyID}/accounting/netsuite/import/customer-projects` as const, }, + POLICY_ACCOUNTING_NETSUITE_IMPORT_CUSTOMERS_OR_PROJECTS_SELECT: { + route: 'settings/workspaces/:policyID/accounting/netsuite/import/customer-projects/select', + getRoute: (policyID: string) => `settings/workspaces/${policyID}/accounting/netsuite/import/customer-projects/select` as const, + }, POLICY_ACCOUNTING_NETSUITE_EXPORT: { route: 'settings/workspaces/:policyID/connections/netsuite/export/', getRoute: (policyID: string) => `settings/workspaces/${policyID}/connections/netsuite/export/` as const, diff --git a/src/SCREENS.ts b/src/SCREENS.ts index 4d49d3004d48..1c9650ef60ef 100644 --- a/src/SCREENS.ts +++ b/src/SCREENS.ts @@ -274,6 +274,7 @@ const SCREENS = { XERO_EXPORT_BANK_ACCOUNT_SELECT: 'Policy_Accounting_Xero_Export_Bank_Account_Select', NETSUITE_IMPORT_MAPPING: 'Policy_Accounting_NetSuite_Import_Mapping', NETSUITE_IMPORT_CUSTOMERS_OR_PROJECTS: 'Policy_Accounting_NetSuite_Import_CustomersOrProjects', + NETSUITE_IMPORT_CUSTOMERS_OR_PROJECTS_SELECT: 'Policy_Accounting_NetSuite_Import_CustomersOrProjects_Select', NETSUITE_SUBSIDIARY_SELECTOR: 'Policy_Accounting_NetSuite_Subsidiary_Selector', NETSUITE_IMPORT: 'Policy_Accounting_NetSuite_Import', NETSUITE_EXPORT: 'Policy_Accounting_NetSuite_Export', diff --git a/src/libs/Navigation/AppNavigator/ModalStackNavigators/index.tsx b/src/libs/Navigation/AppNavigator/ModalStackNavigators/index.tsx index 5af0d8c218d9..38ab108a627f 100644 --- a/src/libs/Navigation/AppNavigator/ModalStackNavigators/index.tsx +++ b/src/libs/Navigation/AppNavigator/ModalStackNavigators/index.tsx @@ -322,7 +322,10 @@ const SettingsModalStackNavigator = createModalStackNavigator require('../../../../pages/workspace/accounting/netsuite/NetSuiteSubsidiarySelector').default, [SCREENS.WORKSPACE.ACCOUNTING.NETSUITE_IMPORT]: () => require('../../../../pages/workspace/accounting/netsuite/import/NetSuiteImportPage').default, [SCREENS.WORKSPACE.ACCOUNTING.NETSUITE_IMPORT_MAPPING]: () => require('../../../../pages/workspace/accounting/netsuite/import/NetSuiteImportMappingPage').default, - [SCREENS.WORKSPACE.ACCOUNTING.NETSUITE_IMPORT_JOBS]: () => require('../../../../pages/workspace/accounting/netsuite/import/NetSuiteImportCustomersOrProjectsPage').default, + [SCREENS.WORKSPACE.ACCOUNTING.NETSUITE_IMPORT_CUSTOMERS_OR_PROJECTS]: () => + require('../../../../pages/workspace/accounting/netsuite/import/NetSuiteImportCustomersOrProjectsPage').default, + [SCREENS.WORKSPACE.ACCOUNTING.NETSUITE_IMPORT_CUSTOMERS_OR_PROJECTS_SELECT]: () => + require('../../../../pages/workspace/accounting/netsuite/import/NetSuiteImportCustomersOrProjectSelectPage').default, [SCREENS.WORKSPACE.ACCOUNTING.NETSUITE_EXPORT]: () => require('../../../../pages/workspace/accounting/netsuite/export/NetSuiteExportConfigurationPage').default, [SCREENS.WORKSPACE.ACCOUNTING.NETSUITE_PREFERRED_EXPORTER_SELECT]: () => require('../../../../pages/workspace/accounting/netsuite/export/NetSuitePreferredExporterSelectPage').default, diff --git a/src/libs/Navigation/linkingConfig/FULL_SCREEN_TO_RHP_MAPPING.ts b/src/libs/Navigation/linkingConfig/FULL_SCREEN_TO_RHP_MAPPING.ts index 632fc5696103..9a0d6e2bf598 100755 --- a/src/libs/Navigation/linkingConfig/FULL_SCREEN_TO_RHP_MAPPING.ts +++ b/src/libs/Navigation/linkingConfig/FULL_SCREEN_TO_RHP_MAPPING.ts @@ -59,6 +59,7 @@ const FULL_SCREEN_TO_RHP_MAPPING: Partial> = { SCREENS.WORKSPACE.ACCOUNTING.NETSUITE_IMPORT, SCREENS.WORKSPACE.ACCOUNTING.NETSUITE_IMPORT_MAPPING, SCREENS.WORKSPACE.ACCOUNTING.NETSUITE_IMPORT_CUSTOMERS_OR_PROJECTS, + SCREENS.WORKSPACE.ACCOUNTING.NETSUITE_IMPORT_CUSTOMERS_OR_PROJECTS_SELECT, SCREENS.WORKSPACE.ACCOUNTING.NETSUITE_EXPORT, SCREENS.WORKSPACE.ACCOUNTING.NETSUITE_PREFERRED_EXPORTER_SELECT, SCREENS.WORKSPACE.ACCOUNTING.NETSUITE_DATE_SELECT, diff --git a/src/libs/Navigation/linkingConfig/config.ts b/src/libs/Navigation/linkingConfig/config.ts index bd8f1c11db16..59f37ebcba0e 100644 --- a/src/libs/Navigation/linkingConfig/config.ts +++ b/src/libs/Navigation/linkingConfig/config.ts @@ -357,6 +357,7 @@ const config: LinkingOptions['config'] = { [SCREENS.WORKSPACE.ACCOUNTING.NETSUITE_IMPORT]: {path: ROUTES.POLICY_ACCOUNTING_NETSUITE_IMPORT.route}, [SCREENS.WORKSPACE.ACCOUNTING.NETSUITE_IMPORT_MAPPING]: {path: ROUTES.POLICY_ACCOUNTING_NETSUITE_IMPORT_MAPPING.route}, [SCREENS.WORKSPACE.ACCOUNTING.NETSUITE_IMPORT_CUSTOMERS_OR_PROJECTS]: {path: ROUTES.POLICY_ACCOUNTING_NETSUITE_IMPORT_CUSTOMERS_OR_PROJECTS.route}, + [SCREENS.WORKSPACE.ACCOUNTING.NETSUITE_IMPORT_CUSTOMERS_OR_PROJECTS_SELECT]: {path: ROUTES.POLICY_ACCOUNTING_NETSUITE_IMPORT_CUSTOMERS_OR_PROJECTS_SELECT.route}, [SCREENS.WORKSPACE.ACCOUNTING.NETSUITE_EXPORT]: { path: ROUTES.POLICY_ACCOUNTING_NETSUITE_EXPORT.route, }, diff --git a/src/libs/Navigation/types.ts b/src/libs/Navigation/types.ts index 7ba1de3e3949..7f25ddc0e019 100644 --- a/src/libs/Navigation/types.ts +++ b/src/libs/Navigation/types.ts @@ -422,6 +422,9 @@ type SettingsNavigatorParamList = { [SCREENS.WORKSPACE.ACCOUNTING.NETSUITE_IMPORT_CUSTOMERS_OR_PROJECTS]: { policyID: string; }; + [SCREENS.WORKSPACE.ACCOUNTING.NETSUITE_IMPORT_CUSTOMERS_OR_PROJECTS_SELECT]: { + policyID: string; + }; [SCREENS.WORKSPACE.ACCOUNTING.NETSUITE_IMPORT_MAPPING]: { policyID: string; importField: TupleToUnion; diff --git a/src/pages/workspace/accounting/netsuite/import/NetSuiteImportCustomersOrProjectSelectPage.tsx b/src/pages/workspace/accounting/netsuite/import/NetSuiteImportCustomersOrProjectSelectPage.tsx new file mode 100644 index 000000000000..6b2a144d1637 --- /dev/null +++ b/src/pages/workspace/accounting/netsuite/import/NetSuiteImportCustomersOrProjectSelectPage.tsx @@ -0,0 +1,73 @@ +import React, {useCallback} from 'react'; +import type {ValueOf} from 'type-fest'; +import RadioListItem from '@components/SelectionList/RadioListItem'; +import type {SelectorType} from '@components/SelectionScreen'; +import SelectionScreen from '@components/SelectionScreen'; +import useLocalize from '@hooks/useLocalize'; +import {updateNetSuiteImportMapping} from '@libs/actions/connections/NetSuiteCommands'; +import Navigation from '@libs/Navigation/Navigation'; +import withPolicyConnections from '@pages/workspace/withPolicyConnections'; +import type {WithPolicyConnectionsProps} from '@pages/workspace/withPolicyConnections'; +import CONST from '@src/CONST'; + +type ImportListItem = SelectorType & { + value: ValueOf; +}; + +function NetSuiteImportCustomersOrProjectSelectPage({policy}: WithPolicyConnectionsProps) { + const policyID = policy?.id ?? '-1'; + const {translate} = useLocalize(); + + const netsuiteConfig = policy?.connections?.netsuite?.options?.config; + const importMappings = netsuiteConfig?.syncOptions?.mapping; + + const importCustomer = importMappings?.customers ?? CONST.INTEGRATION_ENTITY_MAP_TYPES.NETSUITE_DEFAULT; + const importJobs = importMappings?.jobs ?? CONST.INTEGRATION_ENTITY_MAP_TYPES.NETSUITE_DEFAULT; + const importedValue = importMappings?.customers !== CONST.INTEGRATION_ENTITY_MAP_TYPES.NETSUITE_DEFAULT ? importCustomer : importJobs; + + const inputOptions = [CONST.INTEGRATION_ENTITY_MAP_TYPES.TAG, CONST.INTEGRATION_ENTITY_MAP_TYPES.REPORT_FIELD]; + + const inputSectionData: ImportListItem[] = + inputOptions.map((inputOption) => ({ + text: translate(`workspace.netsuite.import.importTypes.${inputOption}.label`), + keyForList: inputOption, + isSelected: importedValue === inputOption, + value: inputOption, + alternateText: translate(`workspace.netsuite.import.importTypes.${inputOption}.description`), + })) ?? []; + + const updateImportMapping = useCallback( + ({value}: ImportListItem) => { + if (value !== importedValue) { + if (importCustomer !== CONST.INTEGRATION_ENTITY_MAP_TYPES.NETSUITE_DEFAULT) { + updateNetSuiteImportMapping(policyID, 'jobs', value, importMappings?.jobs); + } + if (importJobs !== CONST.INTEGRATION_ENTITY_MAP_TYPES.NETSUITE_DEFAULT) { + updateNetSuiteImportMapping(policyID, 'customers', value, importMappings?.customers); + } + } + Navigation.goBack(); + }, + [importCustomer, importJobs, importMappings?.customers, importMappings?.jobs, importedValue, policyID], + ); + + return ( + 0 ? [{data: inputSectionData}] : []} + listItem={RadioListItem} + connectionName={CONST.POLICY.CONNECTIONS.NAME.NETSUITE} + onSelectRow={(selection: SelectorType) => updateImportMapping(selection as ImportListItem)} + initiallyFocusedOptionKey={inputSectionData.find((inputOption) => inputOption.isSelected)?.keyForList} + onBackButtonPress={() => Navigation.goBack()} + title="workspace.common.displayedAs" + /> + ); +} + +NetSuiteImportCustomersOrProjectSelectPage.displayName = 'NetSuiteImportCustomersOrProjectSelectPage'; + +export default withPolicyConnections(NetSuiteImportCustomersOrProjectSelectPage); diff --git a/src/pages/workspace/accounting/netsuite/import/NetSuiteImportCustomersOrProjectsPage.tsx b/src/pages/workspace/accounting/netsuite/import/NetSuiteImportCustomersOrProjectsPage.tsx index 74810338c17c..7114674ba478 100644 --- a/src/pages/workspace/accounting/netsuite/import/NetSuiteImportCustomersOrProjectsPage.tsx +++ b/src/pages/workspace/accounting/netsuite/import/NetSuiteImportCustomersOrProjectsPage.tsx @@ -132,7 +132,7 @@ function NetSuiteImportCustomersOrProjectsPage({policy}: WithPolicyConnectionsPr title={translate(`workspace.netsuite.import.importTypes.${importedValue}.label`)} shouldShowRightIcon onPress={() => { - Navigation.navigate(ROUTES.POLICY_ACCOUNTING_NETSUITE_IMPORT_CUSTOMERS_OR_PROJECTS.getRoute(policyID)); + Navigation.navigate(ROUTES.POLICY_ACCOUNTING_NETSUITE_IMPORT_CUSTOMERS_OR_PROJECTS_SELECT.getRoute(policyID)); }} brickRoadIndicator={!!config?.errorFields?.customers || !!config?.errorFields?.jobs ? CONST.BRICK_ROAD_INDICATOR_STATUS.ERROR : undefined} /> From 70f82de40aa079a6266a5b89d837b3f31d895013 Mon Sep 17 00:00:00 2001 From: Manan Jadhav Date: Thu, 4 Jul 2024 03:23:08 +0530 Subject: [PATCH 36/47] fix: api call --- .../import/NetSuiteImportCustomersOrProjectSelectPage.tsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/pages/workspace/accounting/netsuite/import/NetSuiteImportCustomersOrProjectSelectPage.tsx b/src/pages/workspace/accounting/netsuite/import/NetSuiteImportCustomersOrProjectSelectPage.tsx index 6b2a144d1637..6a24837197ec 100644 --- a/src/pages/workspace/accounting/netsuite/import/NetSuiteImportCustomersOrProjectSelectPage.tsx +++ b/src/pages/workspace/accounting/netsuite/import/NetSuiteImportCustomersOrProjectSelectPage.tsx @@ -39,10 +39,10 @@ function NetSuiteImportCustomersOrProjectSelectPage({policy}: WithPolicyConnecti const updateImportMapping = useCallback( ({value}: ImportListItem) => { if (value !== importedValue) { - if (importCustomer !== CONST.INTEGRATION_ENTITY_MAP_TYPES.NETSUITE_DEFAULT) { + if (importJobs !== CONST.INTEGRATION_ENTITY_MAP_TYPES.NETSUITE_DEFAULT) { updateNetSuiteImportMapping(policyID, 'jobs', value, importMappings?.jobs); } - if (importJobs !== CONST.INTEGRATION_ENTITY_MAP_TYPES.NETSUITE_DEFAULT) { + if (importCustomer !== CONST.INTEGRATION_ENTITY_MAP_TYPES.NETSUITE_DEFAULT) { updateNetSuiteImportMapping(policyID, 'customers', value, importMappings?.customers); } } From ce909a93ee1c587c21342057537fe6c2c7d43fdc Mon Sep 17 00:00:00 2001 From: Manan Jadhav Date: Thu, 4 Jul 2024 03:46:00 +0530 Subject: [PATCH 37/47] feat: added label translations --- src/languages/en.ts | 3 +++ src/languages/es.ts | 3 +++ src/libs/PolicyUtils.ts | 23 +++++++++++++++++-- .../netsuite/import/NetSuiteImportPage.tsx | 2 +- 4 files changed, 28 insertions(+), 3 deletions(-) diff --git a/src/languages/en.ts b/src/languages/en.ts index 52e9d22d61e4..a06b1523946e 100755 --- a/src/languages/en.ts +++ b/src/languages/en.ts @@ -2322,6 +2322,9 @@ export default { subtitle: 'Choose how to handle NetSuite *customers* and *projects* in Expensify.', importCustomers: 'Import customers', importJobs: 'Import projects', + customers: 'customers', + jobs: 'projects', + label: (importFields: string[], importType: string) => `${importFields.join(' and ')}, ${importType}`, }, importTaxDescription: 'Import tax groups from NetSuite', importCustomFields: { diff --git a/src/languages/es.ts b/src/languages/es.ts index 9f11ae9ca5f3..340d81f22171 100644 --- a/src/languages/es.ts +++ b/src/languages/es.ts @@ -2354,6 +2354,9 @@ export default { subtitle: 'Elija cómo manejar los *clientes* y *proyectos* de NetSuite en Expensify.', importCustomers: 'Importar clientes', importJobs: 'Importar proyectos', + customers: 'clientes', + jobs: 'proyectos', + label: (importFields: string[], importType: string) => `${importFields.join(' y ')}, ${importType}`, }, importTaxDescription: 'Importar grupos de impuestos desde NetSuite', importCustomFields: { diff --git a/src/libs/PolicyUtils.ts b/src/libs/PolicyUtils.ts index 501311b12b42..1c94e1de2669 100644 --- a/src/libs/PolicyUtils.ts +++ b/src/libs/PolicyUtils.ts @@ -2,6 +2,7 @@ import {Str} from 'expensify-common'; import type {OnyxCollection, OnyxEntry} from 'react-native-onyx'; import Onyx from 'react-native-onyx'; import type {ValueOf} from 'type-fest'; +import type {LocaleContextProps} from '@components/LocaleContextProvider'; import type {SelectorType} from '@components/SelectionScreen'; import CONST from '@src/CONST'; import ONYXKEYS from '@src/ONYXKEYS'; @@ -536,12 +537,30 @@ function canUseProvincialTaxNetSuite(subsidiaryCountry?: string) { return subsidiaryCountry === '_canada'; } -function getCustomersOrJobsLabelNetSuite(policy: Policy | undefined): string | undefined { +function getCustomersOrJobsLabelNetSuite(policy: Policy | undefined, translate: LocaleContextProps['translate']): string | undefined { const importMapping = policy?.connections?.netsuite?.options?.config?.syncOptions?.mapping; if (!importMapping?.customers && !importMapping?.jobs) { return undefined; } - return 'Test'; + const importFields: string[] = []; + const importCustomer = importMapping?.customers ?? CONST.INTEGRATION_ENTITY_MAP_TYPES.NETSUITE_DEFAULT; + const importJobs = importMapping?.jobs ?? CONST.INTEGRATION_ENTITY_MAP_TYPES.NETSUITE_DEFAULT; + const importedValue = importMapping?.customers !== CONST.INTEGRATION_ENTITY_MAP_TYPES.NETSUITE_DEFAULT ? importCustomer : importJobs; + + if (!importedValue || importedValue === CONST.INTEGRATION_ENTITY_MAP_TYPES.NETSUITE_DEFAULT) { + return undefined; + } + + if (importCustomer !== CONST.INTEGRATION_ENTITY_MAP_TYPES.NETSUITE_DEFAULT) { + importFields.push(translate('workspace.netsuite.import.customersOrJobs.customers')); + } + + if (importJobs !== CONST.INTEGRATION_ENTITY_MAP_TYPES.NETSUITE_DEFAULT) { + importFields.push(translate('workspace.netsuite.import.customersOrJobs.jobs')); + } + + const importedValueLabel = translate(`workspace.netsuite.import.customersOrJobs.label`, importFields, translate(`workspace.accounting.importTypes.${importedValue}`)); + return importedValueLabel.charAt(0).toUpperCase() + importedValueLabel.slice(1); } function getIntegrationLastSuccessfulDate(connection?: Connections[keyof Connections]) { diff --git a/src/pages/workspace/accounting/netsuite/import/NetSuiteImportPage.tsx b/src/pages/workspace/accounting/netsuite/import/NetSuiteImportPage.tsx index a08d2d3b5686..21da5034d20a 100644 --- a/src/pages/workspace/accounting/netsuite/import/NetSuiteImportPage.tsx +++ b/src/pages/workspace/accounting/netsuite/import/NetSuiteImportPage.tsx @@ -87,7 +87,7 @@ function NetSuiteImportPage({policy}: WithPolicyConnectionsProps) { > { Navigation.navigate(ROUTES.POLICY_ACCOUNTING_NETSUITE_IMPORT_CUSTOMERS_OR_PROJECTS.getRoute(policyID)); From 5bacddd6bc1e909d7e67694967825bed1da14e71 Mon Sep 17 00:00:00 2001 From: Manan Jadhav Date: Thu, 4 Jul 2024 19:45:54 +0530 Subject: [PATCH 38/47] refactor: design updates --- .../NetSuiteImportCustomersOrProjectsPage.tsx | 125 +++++++------- .../netsuite/import/NetSuiteImportPage.tsx | 157 +++++++++--------- 2 files changed, 134 insertions(+), 148 deletions(-) diff --git a/src/pages/workspace/accounting/netsuite/import/NetSuiteImportCustomersOrProjectsPage.tsx b/src/pages/workspace/accounting/netsuite/import/NetSuiteImportCustomersOrProjectsPage.tsx index 7114674ba478..4a6bf83d420d 100644 --- a/src/pages/workspace/accounting/netsuite/import/NetSuiteImportCustomersOrProjectsPage.tsx +++ b/src/pages/workspace/accounting/netsuite/import/NetSuiteImportCustomersOrProjectsPage.tsx @@ -60,7 +60,6 @@ function NetSuiteImportCustomersOrProjectsPage({policy}: WithPolicyConnectionsPr - - ${parser.replace(translate(`workspace.netsuite.import.customersOrJobs.subtitle` as TranslationPaths))}`} /> + + ${parser.replace(translate(`workspace.netsuite.import.customersOrJobs.subtitle` as TranslationPaths))}`} /> - - { - updateMapping('customers', isEnabled); - }} - pendingAction={config?.syncOptions?.mapping?.pendingFields?.customers} - errors={ErrorUtils.getLatestErrorField(config ?? {}, CONST.NETSUITE_CONFIG.SYNC_OPTIONS.MAPPING.CUSTOMERS)} - onCloseError={() => Policy.clearNetSuiteErrorField(policyID, CONST.NETSUITE_CONFIG.SYNC_OPTIONS.MAPPING.CUSTOMERS)} - /> - - - - { - updateMapping('jobs', isEnabled); - }} - pendingAction={config?.syncOptions?.mapping?.pendingFields?.jobs} - errors={ErrorUtils.getLatestErrorField(config ?? {}, CONST.NETSUITE_CONFIG.SYNC_OPTIONS.MAPPING.JOBS)} - onCloseError={() => Policy.clearNetSuiteErrorField(policyID, CONST.NETSUITE_CONFIG.SYNC_OPTIONS.MAPPING.JOBS)} - /> - - - { - updateNetSuiteCrossSubsidiaryCustomersConfiguration(policyID, isEnabled); - }} - pendingAction={config?.syncOptions?.pendingFields?.crossSubsidiaryCustomers} - errors={ErrorUtils.getLatestErrorField(config ?? {}, CONST.NETSUITE_CONFIG.SYNC_OPTIONS.CROSS_SUBSIDIARY_CUSTOMERS)} - onCloseError={() => Policy.clearNetSuiteErrorField(policyID, CONST.NETSUITE_CONFIG.SYNC_OPTIONS.CROSS_SUBSIDIARY_CUSTOMERS)} - /> - + { + updateMapping('customers', isEnabled); + }} + pendingAction={config?.syncOptions?.mapping?.pendingFields?.customers} + errors={ErrorUtils.getLatestErrorField(config ?? {}, CONST.NETSUITE_CONFIG.SYNC_OPTIONS.MAPPING.CUSTOMERS)} + onCloseError={() => Policy.clearNetSuiteErrorField(policyID, CONST.NETSUITE_CONFIG.SYNC_OPTIONS.MAPPING.CUSTOMERS)} + /> + { + updateMapping('jobs', isEnabled); + }} + pendingAction={config?.syncOptions?.mapping?.pendingFields?.jobs} + errors={ErrorUtils.getLatestErrorField(config ?? {}, CONST.NETSUITE_CONFIG.SYNC_OPTIONS.MAPPING.JOBS)} + onCloseError={() => Policy.clearNetSuiteErrorField(policyID, CONST.NETSUITE_CONFIG.SYNC_OPTIONS.MAPPING.JOBS)} + /> + { + updateNetSuiteCrossSubsidiaryCustomersConfiguration(policyID, isEnabled); + }} + pendingAction={config?.syncOptions?.pendingFields?.crossSubsidiaryCustomers} + errors={ErrorUtils.getLatestErrorField(config ?? {}, CONST.NETSUITE_CONFIG.SYNC_OPTIONS.CROSS_SUBSIDIARY_CUSTOMERS)} + onCloseError={() => Policy.clearNetSuiteErrorField(policyID, CONST.NETSUITE_CONFIG.SYNC_OPTIONS.CROSS_SUBSIDIARY_CUSTOMERS)} + /> {importedValue !== CONST.INTEGRATION_ENTITY_MAP_TYPES.NETSUITE_DEFAULT && ( - - { - Policy.clearNetSuiteErrorField(policyID, CONST.NETSUITE_CONFIG.SYNC_OPTIONS.MAPPING.CUSTOMERS); - Policy.clearNetSuiteErrorField(policyID, CONST.NETSUITE_CONFIG.SYNC_OPTIONS.MAPPING.JOBS); + { + Policy.clearNetSuiteErrorField(policyID, CONST.NETSUITE_CONFIG.SYNC_OPTIONS.MAPPING.CUSTOMERS); + Policy.clearNetSuiteErrorField(policyID, CONST.NETSUITE_CONFIG.SYNC_OPTIONS.MAPPING.JOBS); + }} + > + { + Navigation.navigate(ROUTES.POLICY_ACCOUNTING_NETSUITE_IMPORT_CUSTOMERS_OR_PROJECTS_SELECT.getRoute(policyID)); }} - > - { - Navigation.navigate(ROUTES.POLICY_ACCOUNTING_NETSUITE_IMPORT_CUSTOMERS_OR_PROJECTS_SELECT.getRoute(policyID)); - }} - brickRoadIndicator={!!config?.errorFields?.customers || !!config?.errorFields?.jobs ? CONST.BRICK_ROAD_INDICATOR_STATUS.ERROR : undefined} - /> - - + brickRoadIndicator={!!config?.errorFields?.customers || !!config?.errorFields?.jobs ? CONST.BRICK_ROAD_INDICATOR_STATUS.ERROR : undefined} + /> + )} ); diff --git a/src/pages/workspace/accounting/netsuite/import/NetSuiteImportPage.tsx b/src/pages/workspace/accounting/netsuite/import/NetSuiteImportPage.tsx index 21da5034d20a..2f37c53b0bb4 100644 --- a/src/pages/workspace/accounting/netsuite/import/NetSuiteImportPage.tsx +++ b/src/pages/workspace/accounting/netsuite/import/NetSuiteImportPage.tsx @@ -1,5 +1,4 @@ import React, {useMemo} from 'react'; -import {View} from 'react-native'; import ConnectionLayout from '@components/ConnectionLayout'; import MenuItemWithTopDescription from '@components/MenuItemWithTopDescription'; import OfflineWithFeedback from '@components/OfflineWithFeedback'; @@ -40,100 +39,94 @@ function NetSuiteImportPage({policy}: WithPolicyConnectionsProps) { titleStyle={styles.ph5} connectionName={CONST.POLICY.CONNECTIONS.NAME.NETSUITE} > - - {}} - /> - - - - {CONST.NETSUITE_CONFIG.IMPORT_FIELDS.map((importField) => ( - Policy.clearNetSuiteErrorField(policyID, importField)} - > - { - Navigation.navigate(ROUTES.POLICY_ACCOUNTING_NETSUITE_IMPORT_MAPPING.getRoute(policyID, importField)); - }} - brickRoadIndicator={config?.errorFields?.[importField] ? CONST.BRICK_ROAD_INDICATOR_STATUS.ERROR : undefined} - /> - - ))} + {}} + /> + {CONST.NETSUITE_CONFIG.IMPORT_FIELDS.map((importField) => ( { - Policy.clearNetSuiteErrorField(policyID, CONST.NETSUITE_CONFIG.SYNC_OPTIONS.MAPPING.CUSTOMERS); - Policy.clearNetSuiteErrorField(policyID, CONST.NETSUITE_CONFIG.SYNC_OPTIONS.MAPPING.JOBS); - }} + key={importField} + errors={ErrorUtils.getLatestErrorField(config ?? {}, importField)} + errorRowStyles={[styles.ph5]} + pendingAction={config?.syncOptions?.mapping?.pendingFields?.[importField]} + onClose={() => Policy.clearNetSuiteErrorField(policyID, importField)} > { - Navigation.navigate(ROUTES.POLICY_ACCOUNTING_NETSUITE_IMPORT_CUSTOMERS_OR_PROJECTS.getRoute(policyID)); + Navigation.navigate(ROUTES.POLICY_ACCOUNTING_NETSUITE_IMPORT_MAPPING.getRoute(policyID, importField)); }} - brickRoadIndicator={!!config?.errorFields?.customers || !!config?.errorFields?.jobs ? CONST.BRICK_ROAD_INDICATOR_STATUS.ERROR : undefined} + brickRoadIndicator={config?.errorFields?.[importField] ? CONST.BRICK_ROAD_INDICATOR_STATUS.ERROR : undefined} /> - + ))} + + { + Policy.clearNetSuiteErrorField(policyID, CONST.NETSUITE_CONFIG.SYNC_OPTIONS.MAPPING.CUSTOMERS); + Policy.clearNetSuiteErrorField(policyID, CONST.NETSUITE_CONFIG.SYNC_OPTIONS.MAPPING.JOBS); + }} + > + { + Navigation.navigate(ROUTES.POLICY_ACCOUNTING_NETSUITE_IMPORT_CUSTOMERS_OR_PROJECTS.getRoute(policyID)); + }} + brickRoadIndicator={!!config?.errorFields?.customers || !!config?.errorFields?.jobs ? CONST.BRICK_ROAD_INDICATOR_STATUS.ERROR : undefined} + /> + {canUseTaxNetSuite(canUseNetSuiteUSATax, selectedSubsidiary?.country) && ( - - { - updateNetSuiteSyncTaxConfiguration(policyID, isEnabled); - }} - pendingAction={config?.syncOptions?.pendingFields?.syncTax} - errors={ErrorUtils.getLatestErrorField(config ?? {}, CONST.NETSUITE_CONFIG.SYNC_OPTIONS.SYNC_TAX)} - onCloseError={() => Policy.clearNetSuiteErrorField(policyID, CONST.NETSUITE_CONFIG.SYNC_OPTIONS.SYNC_TAX)} - /> - + { + updateNetSuiteSyncTaxConfiguration(policyID, isEnabled); + }} + pendingAction={config?.syncOptions?.pendingFields?.syncTax} + errors={ErrorUtils.getLatestErrorField(config ?? {}, CONST.NETSUITE_CONFIG.SYNC_OPTIONS.SYNC_TAX)} + onCloseError={() => Policy.clearNetSuiteErrorField(policyID, CONST.NETSUITE_CONFIG.SYNC_OPTIONS.SYNC_TAX)} + /> )} - - {CONST.NETSUITE_CONFIG.IMPORT_CUSTOM_FIELDS.map((importField) => ( - Policy.clearNetSuiteErrorField(policyID, importField)} - > - { - // TODO: Navigation will be handled in future PRs - }} - brickRoadIndicator={config?.errorFields?.[importField] ? CONST.BRICK_ROAD_INDICATOR_STATUS.ERROR : undefined} - /> - - ))} - + {CONST.NETSUITE_CONFIG.IMPORT_CUSTOM_FIELDS.map((importField) => ( + Policy.clearNetSuiteErrorField(policyID, importField)} + > + { + // TODO: Navigation will be handled in future PRs + }} + brickRoadIndicator={config?.errorFields?.[importField] ? CONST.BRICK_ROAD_INDICATOR_STATUS.ERROR : undefined} + /> + + ))} ); } From dccc36bb678dad39cc7a3929c9afa0971e448469 Mon Sep 17 00:00:00 2001 From: Manan Jadhav Date: Thu, 4 Jul 2024 19:55:28 +0530 Subject: [PATCH 39/47] refactor: design updates --- ...uiteImportCustomersOrProjectSelectPage.tsx | 20 ++++++------- .../NetSuiteImportCustomersOrProjectsPage.tsx | 2 +- .../import/NetSuiteImportMappingPage.tsx | 28 +++++++++---------- 3 files changed, 25 insertions(+), 25 deletions(-) diff --git a/src/pages/workspace/accounting/netsuite/import/NetSuiteImportCustomersOrProjectSelectPage.tsx b/src/pages/workspace/accounting/netsuite/import/NetSuiteImportCustomersOrProjectSelectPage.tsx index 6a24837197ec..f61a8388e118 100644 --- a/src/pages/workspace/accounting/netsuite/import/NetSuiteImportCustomersOrProjectSelectPage.tsx +++ b/src/pages/workspace/accounting/netsuite/import/NetSuiteImportCustomersOrProjectSelectPage.tsx @@ -9,6 +9,7 @@ import Navigation from '@libs/Navigation/Navigation'; import withPolicyConnections from '@pages/workspace/withPolicyConnections'; import type {WithPolicyConnectionsProps} from '@pages/workspace/withPolicyConnections'; import CONST from '@src/CONST'; +import ROUTES from '@src/ROUTES'; type ImportListItem = SelectorType & { value: ValueOf; @@ -27,14 +28,13 @@ function NetSuiteImportCustomersOrProjectSelectPage({policy}: WithPolicyConnecti const inputOptions = [CONST.INTEGRATION_ENTITY_MAP_TYPES.TAG, CONST.INTEGRATION_ENTITY_MAP_TYPES.REPORT_FIELD]; - const inputSectionData: ImportListItem[] = - inputOptions.map((inputOption) => ({ - text: translate(`workspace.netsuite.import.importTypes.${inputOption}.label`), - keyForList: inputOption, - isSelected: importedValue === inputOption, - value: inputOption, - alternateText: translate(`workspace.netsuite.import.importTypes.${inputOption}.description`), - })) ?? []; + const inputSectionData: ImportListItem[] = inputOptions.map((inputOption) => ({ + text: translate(`workspace.netsuite.import.importTypes.${inputOption}.label`), + keyForList: inputOption, + isSelected: importedValue === inputOption, + value: inputOption, + alternateText: translate(`workspace.netsuite.import.importTypes.${inputOption}.description`), + })); const updateImportMapping = useCallback( ({value}: ImportListItem) => { @@ -57,12 +57,12 @@ function NetSuiteImportCustomersOrProjectSelectPage({policy}: WithPolicyConnecti accessVariants={[CONST.POLICY.ACCESS_VARIANTS.ADMIN, CONST.POLICY.ACCESS_VARIANTS.PAID]} featureName={CONST.POLICY.MORE_FEATURES.ARE_CONNECTIONS_ENABLED} displayName={NetSuiteImportCustomersOrProjectSelectPage.displayName} - sections={inputSectionData.length > 0 ? [{data: inputSectionData}] : []} + sections={[{data: inputSectionData}]} listItem={RadioListItem} connectionName={CONST.POLICY.CONNECTIONS.NAME.NETSUITE} onSelectRow={(selection: SelectorType) => updateImportMapping(selection as ImportListItem)} initiallyFocusedOptionKey={inputSectionData.find((inputOption) => inputOption.isSelected)?.keyForList} - onBackButtonPress={() => Navigation.goBack()} + onBackButtonPress={() => Navigation.goBack(ROUTES.POLICY_ACCOUNTING_NETSUITE_IMPORT_CUSTOMERS_OR_PROJECTS.getRoute(policyID))} title="workspace.common.displayedAs" /> ); diff --git a/src/pages/workspace/accounting/netsuite/import/NetSuiteImportCustomersOrProjectsPage.tsx b/src/pages/workspace/accounting/netsuite/import/NetSuiteImportCustomersOrProjectsPage.tsx index 4a6bf83d420d..75c24e7cca1b 100644 --- a/src/pages/workspace/accounting/netsuite/import/NetSuiteImportCustomersOrProjectsPage.tsx +++ b/src/pages/workspace/accounting/netsuite/import/NetSuiteImportCustomersOrProjectsPage.tsx @@ -63,7 +63,7 @@ function NetSuiteImportCustomersOrProjectsPage({policy}: WithPolicyConnectionsPr accessVariants={[CONST.POLICY.ACCESS_VARIANTS.ADMIN, CONST.POLICY.ACCESS_VARIANTS.PAID]} policyID={policyID} featureName={CONST.POLICY.MORE_FEATURES.ARE_CONNECTIONS_ENABLED} - contentContainerStyle={[styles.pb2]} + contentContainerStyle={styles.pb2} titleStyle={styles.ph5} connectionName={CONST.POLICY.CONNECTIONS.NAME.NETSUITE} > diff --git a/src/pages/workspace/accounting/netsuite/import/NetSuiteImportMappingPage.tsx b/src/pages/workspace/accounting/netsuite/import/NetSuiteImportMappingPage.tsx index 4d868e98b8ae..b924f62ecf50 100644 --- a/src/pages/workspace/accounting/netsuite/import/NetSuiteImportMappingPage.tsx +++ b/src/pages/workspace/accounting/netsuite/import/NetSuiteImportMappingPage.tsx @@ -15,6 +15,7 @@ import withPolicyConnections from '@pages/workspace/withPolicyConnections'; import type {WithPolicyConnectionsProps} from '@pages/workspace/withPolicyConnections'; import CONST from '@src/CONST'; import type {TranslationPaths} from '@src/languages/types'; +import ROUTES from '@src/ROUTES'; const parser = new ExpensiMark(); @@ -49,34 +50,33 @@ function NetSuiteImportMappingPage({ const listFooterContent = useMemo( () => ( - + {translate(`workspace.netsuite.import.importTypes.${importValue}.footerContent`, importField)} ), - [importField, importValue, styles.mb4, styles.mt2, styles.ph5, translate], + [importField, importValue, styles.mb4, styles.mt3, styles.ph5, translate], ); const listHeaderComponent = useMemo( () => ( - + ${parser.replace(translate(`workspace.netsuite.import.importFields.${importField}.subtitle` as TranslationPaths))}`} /> ), - [styles.ph5, styles.mt2, styles.mb8, styles.flexRow, translate, importField], + [styles.ph5, styles.pb5, styles.flexRow, translate, importField], ); const inputOptions = [CONST.INTEGRATION_ENTITY_MAP_TYPES.NETSUITE_DEFAULT, CONST.INTEGRATION_ENTITY_MAP_TYPES.TAG, CONST.INTEGRATION_ENTITY_MAP_TYPES.REPORT_FIELD]; - const inputSectionData: ImportListItem[] = - inputOptions.map((inputOption) => ({ - text: translate(`workspace.netsuite.import.importTypes.${inputOption}.label`), - keyForList: inputOption, - isSelected: importValue === inputOption, - value: inputOption, - alternateText: translate(`workspace.netsuite.import.importTypes.${inputOption}.description`), - })) ?? []; + const inputSectionData: ImportListItem[] = inputOptions.map((inputOption) => ({ + text: translate(`workspace.netsuite.import.importTypes.${inputOption}.label`), + keyForList: inputOption, + isSelected: importValue === inputOption, + value: inputOption, + alternateText: translate(`workspace.netsuite.import.importTypes.${inputOption}.description`), + })); const titleKey = `workspace.netsuite.import.importFields.${importField}.title` as TranslationPaths; @@ -97,13 +97,13 @@ function NetSuiteImportMappingPage({ accessVariants={[CONST.POLICY.ACCESS_VARIANTS.ADMIN, CONST.POLICY.ACCESS_VARIANTS.PAID]} featureName={CONST.POLICY.MORE_FEATURES.ARE_CONNECTIONS_ENABLED} displayName={NetSuiteImportMappingPage.displayName} - sections={inputSectionData.length > 0 ? [{data: inputSectionData}] : []} + sections={[{data: inputSectionData}]} listItem={RadioListItem} connectionName={CONST.POLICY.CONNECTIONS.NAME.NETSUITE} onSelectRow={(selection: SelectorType) => updateImportMapping(selection as ImportListItem)} initiallyFocusedOptionKey={inputSectionData.find((inputOption) => inputOption.isSelected)?.keyForList} headerContent={listHeaderComponent} - onBackButtonPress={() => Navigation.goBack()} + onBackButtonPress={() => Navigation.goBack(ROUTES.POLICY_ACCOUNTING_NETSUITE_IMPORT.getRoute(policyID))} title={titleKey} listFooterContent={listFooterContent} /> From 244dff740d30f161deeab49dc0eca15c03efb2ff Mon Sep 17 00:00:00 2001 From: Manan Jadhav Date: Thu, 4 Jul 2024 20:01:49 +0530 Subject: [PATCH 40/47] fix: added back --- .../netsuite/import/NetSuiteImportCustomersOrProjectsPage.tsx | 1 + 1 file changed, 1 insertion(+) diff --git a/src/pages/workspace/accounting/netsuite/import/NetSuiteImportCustomersOrProjectsPage.tsx b/src/pages/workspace/accounting/netsuite/import/NetSuiteImportCustomersOrProjectsPage.tsx index 75c24e7cca1b..86d25886c899 100644 --- a/src/pages/workspace/accounting/netsuite/import/NetSuiteImportCustomersOrProjectsPage.tsx +++ b/src/pages/workspace/accounting/netsuite/import/NetSuiteImportCustomersOrProjectsPage.tsx @@ -66,6 +66,7 @@ function NetSuiteImportCustomersOrProjectsPage({policy}: WithPolicyConnectionsPr contentContainerStyle={styles.pb2} titleStyle={styles.ph5} connectionName={CONST.POLICY.CONNECTIONS.NAME.NETSUITE} + onBackButtonPressRoute={ROUTES.POLICY_ACCOUNTING_NETSUITE_IMPORT.getRoute(policyID)} > ${parser.replace(translate(`workspace.netsuite.import.customersOrJobs.subtitle` as TranslationPaths))}`} /> From a66138703f426dad72179e09f06442250a52a7ba Mon Sep 17 00:00:00 2001 From: Manan Jadhav Date: Thu, 4 Jul 2024 20:05:34 +0530 Subject: [PATCH 41/47] fix: field lower case --- src/libs/PolicyUtils.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/libs/PolicyUtils.ts b/src/libs/PolicyUtils.ts index 1c94e1de2669..9c1939093201 100644 --- a/src/libs/PolicyUtils.ts +++ b/src/libs/PolicyUtils.ts @@ -559,7 +559,7 @@ function getCustomersOrJobsLabelNetSuite(policy: Policy | undefined, translate: importFields.push(translate('workspace.netsuite.import.customersOrJobs.jobs')); } - const importedValueLabel = translate(`workspace.netsuite.import.customersOrJobs.label`, importFields, translate(`workspace.accounting.importTypes.${importedValue}`)); + const importedValueLabel = translate(`workspace.netsuite.import.customersOrJobs.label`, importFields, translate(`workspace.accounting.importTypes.${importedValue}`).toLowerCase()); return importedValueLabel.charAt(0).toUpperCase() + importedValueLabel.slice(1); } From e1d55ce51313ab259fa103b3d57a0c91e6ebfd8e Mon Sep 17 00:00:00 2001 From: Manan Jadhav Date: Thu, 4 Jul 2024 20:21:39 +0530 Subject: [PATCH 42/47] refactor: use const --- .../import/NetSuiteImportCustomersOrProjectSelectPage.tsx | 4 ++-- .../import/NetSuiteImportCustomersOrProjectsPage.tsx | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/pages/workspace/accounting/netsuite/import/NetSuiteImportCustomersOrProjectSelectPage.tsx b/src/pages/workspace/accounting/netsuite/import/NetSuiteImportCustomersOrProjectSelectPage.tsx index f61a8388e118..bfa843665446 100644 --- a/src/pages/workspace/accounting/netsuite/import/NetSuiteImportCustomersOrProjectSelectPage.tsx +++ b/src/pages/workspace/accounting/netsuite/import/NetSuiteImportCustomersOrProjectSelectPage.tsx @@ -40,10 +40,10 @@ function NetSuiteImportCustomersOrProjectSelectPage({policy}: WithPolicyConnecti ({value}: ImportListItem) => { if (value !== importedValue) { if (importJobs !== CONST.INTEGRATION_ENTITY_MAP_TYPES.NETSUITE_DEFAULT) { - updateNetSuiteImportMapping(policyID, 'jobs', value, importMappings?.jobs); + updateNetSuiteImportMapping(policyID, CONST.NETSUITE_CONFIG.SYNC_OPTIONS.MAPPING.JOBS, value, importMappings?.jobs); } if (importCustomer !== CONST.INTEGRATION_ENTITY_MAP_TYPES.NETSUITE_DEFAULT) { - updateNetSuiteImportMapping(policyID, 'customers', value, importMappings?.customers); + updateNetSuiteImportMapping(policyID, CONST.NETSUITE_CONFIG.SYNC_OPTIONS.MAPPING.CUSTOMERS, value, importMappings?.customers); } } Navigation.goBack(); diff --git a/src/pages/workspace/accounting/netsuite/import/NetSuiteImportCustomersOrProjectsPage.tsx b/src/pages/workspace/accounting/netsuite/import/NetSuiteImportCustomersOrProjectsPage.tsx index 86d25886c899..d384a7d61a6a 100644 --- a/src/pages/workspace/accounting/netsuite/import/NetSuiteImportCustomersOrProjectsPage.tsx +++ b/src/pages/workspace/accounting/netsuite/import/NetSuiteImportCustomersOrProjectsPage.tsx @@ -41,7 +41,7 @@ function NetSuiteImportCustomersOrProjectsPage({policy}: WithPolicyConnectionsPr newValue = CONST.INTEGRATION_ENTITY_MAP_TYPES.NETSUITE_DEFAULT; } else { // when we enable any field, and if the other one already has a value set, we should set that, - const otherFieldValue = importField === 'jobs' ? config?.syncOptions?.mapping?.customers : config?.syncOptions?.mapping?.jobs; + const otherFieldValue = importField === CONST.NETSUITE_CONFIG.SYNC_OPTIONS.MAPPING.JOBS ? config?.syncOptions?.mapping?.customers : config?.syncOptions?.mapping?.jobs; if (otherFieldValue === CONST.INTEGRATION_ENTITY_MAP_TYPES.NETSUITE_DEFAULT) { newValue = CONST.INTEGRATION_ENTITY_MAP_TYPES.TAG; } else { @@ -78,7 +78,7 @@ function NetSuiteImportCustomersOrProjectsPage({policy}: WithPolicyConnectionsPr isActive={(config?.syncOptions?.mapping?.customers ?? CONST.INTEGRATION_ENTITY_MAP_TYPES.NETSUITE_DEFAULT) !== CONST.INTEGRATION_ENTITY_MAP_TYPES.NETSUITE_DEFAULT} switchAccessibilityLabel={translate('workspace.netsuite.import.customersOrJobs.importCustomers')} onToggle={(isEnabled: boolean) => { - updateMapping('customers', isEnabled); + updateMapping(CONST.NETSUITE_CONFIG.SYNC_OPTIONS.MAPPING.CUSTOMERS, isEnabled); }} pendingAction={config?.syncOptions?.mapping?.pendingFields?.customers} errors={ErrorUtils.getLatestErrorField(config ?? {}, CONST.NETSUITE_CONFIG.SYNC_OPTIONS.MAPPING.CUSTOMERS)} @@ -90,7 +90,7 @@ function NetSuiteImportCustomersOrProjectsPage({policy}: WithPolicyConnectionsPr isActive={(config?.syncOptions?.mapping?.jobs ?? CONST.INTEGRATION_ENTITY_MAP_TYPES.NETSUITE_DEFAULT) !== CONST.INTEGRATION_ENTITY_MAP_TYPES.NETSUITE_DEFAULT} switchAccessibilityLabel={translate('workspace.netsuite.import.customersOrJobs.importJobs')} onToggle={(isEnabled: boolean) => { - updateMapping('jobs', isEnabled); + updateMapping(CONST.NETSUITE_CONFIG.SYNC_OPTIONS.MAPPING.JOBS, isEnabled); }} pendingAction={config?.syncOptions?.mapping?.pendingFields?.jobs} errors={ErrorUtils.getLatestErrorField(config ?? {}, CONST.NETSUITE_CONFIG.SYNC_OPTIONS.MAPPING.JOBS)} From 4ebd514e1ecd0d856e57218098b9a23b2ed4c869 Mon Sep 17 00:00:00 2001 From: Manan Jadhav Date: Thu, 4 Jul 2024 20:37:29 +0530 Subject: [PATCH 43/47] fix: truncate --- .../workspace/accounting/netsuite/import/NetSuiteImportPage.tsx | 1 + 1 file changed, 1 insertion(+) diff --git a/src/pages/workspace/accounting/netsuite/import/NetSuiteImportPage.tsx b/src/pages/workspace/accounting/netsuite/import/NetSuiteImportPage.tsx index 2f37c53b0bb4..679a3ab6662e 100644 --- a/src/pages/workspace/accounting/netsuite/import/NetSuiteImportPage.tsx +++ b/src/pages/workspace/accounting/netsuite/import/NetSuiteImportPage.tsx @@ -86,6 +86,7 @@ function NetSuiteImportPage({policy}: WithPolicyConnectionsProps) { description={translate(`workspace.netsuite.import.customersOrJobs.title`)} title={PolicyUtils.getCustomersOrJobsLabelNetSuite(policy, translate)} shouldShowRightIcon + numberOfLinesTitle={2} onPress={() => { Navigation.navigate(ROUTES.POLICY_ACCOUNTING_NETSUITE_IMPORT_CUSTOMERS_OR_PROJECTS.getRoute(policyID)); }} From ee5e345427575e772fa0249960a5c90c023026c9 Mon Sep 17 00:00:00 2001 From: Manan Jadhav Date: Thu, 4 Jul 2024 23:20:41 +0530 Subject: [PATCH 44/47] fix: back handler --- .../netsuite/import/NetSuiteImportCustomersOrProjectsPage.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pages/workspace/accounting/netsuite/import/NetSuiteImportCustomersOrProjectsPage.tsx b/src/pages/workspace/accounting/netsuite/import/NetSuiteImportCustomersOrProjectsPage.tsx index d384a7d61a6a..655787a746b0 100644 --- a/src/pages/workspace/accounting/netsuite/import/NetSuiteImportCustomersOrProjectsPage.tsx +++ b/src/pages/workspace/accounting/netsuite/import/NetSuiteImportCustomersOrProjectsPage.tsx @@ -66,7 +66,7 @@ function NetSuiteImportCustomersOrProjectsPage({policy}: WithPolicyConnectionsPr contentContainerStyle={styles.pb2} titleStyle={styles.ph5} connectionName={CONST.POLICY.CONNECTIONS.NAME.NETSUITE} - onBackButtonPressRoute={ROUTES.POLICY_ACCOUNTING_NETSUITE_IMPORT.getRoute(policyID)} + onBackButtonPress={() => Navigation.goBack(ROUTES.POLICY_ACCOUNTING_NETSUITE_IMPORT.getRoute(policyID))} > ${parser.replace(translate(`workspace.netsuite.import.customersOrJobs.subtitle` as TranslationPaths))}`} /> From cddfd35cf37b821ec90d066167063d53b7f95839 Mon Sep 17 00:00:00 2001 From: Manan Jadhav Date: Fri, 5 Jul 2024 02:06:11 +0530 Subject: [PATCH 45/47] refactor: rename const --- src/CONST.ts | 2 +- ...uiteImportCustomersOrProjectSelectPage.tsx | 4 ++-- .../NetSuiteImportCustomersOrProjectsPage.tsx | 22 +++++++++---------- .../netsuite/import/NetSuiteImportPage.tsx | 8 +++---- 4 files changed, 18 insertions(+), 18 deletions(-) diff --git a/src/CONST.ts b/src/CONST.ts index 1bbe90a344ac..23c8a396afdb 100755 --- a/src/CONST.ts +++ b/src/CONST.ts @@ -1397,7 +1397,7 @@ const CONST = { EXPORT_JOURNALS_TO: 'exportJournalsTo', SYNC_TAX: 'syncTax', CROSS_SUBSIDIARY_CUSTOMERS: 'crossSubsidiaryCustomers', - MAPPING: { + CUSTOMER_MAPPINGS: { CUSTOMERS: 'customers', JOBS: 'jobs', }, diff --git a/src/pages/workspace/accounting/netsuite/import/NetSuiteImportCustomersOrProjectSelectPage.tsx b/src/pages/workspace/accounting/netsuite/import/NetSuiteImportCustomersOrProjectSelectPage.tsx index bfa843665446..cd0932c89410 100644 --- a/src/pages/workspace/accounting/netsuite/import/NetSuiteImportCustomersOrProjectSelectPage.tsx +++ b/src/pages/workspace/accounting/netsuite/import/NetSuiteImportCustomersOrProjectSelectPage.tsx @@ -40,10 +40,10 @@ function NetSuiteImportCustomersOrProjectSelectPage({policy}: WithPolicyConnecti ({value}: ImportListItem) => { if (value !== importedValue) { if (importJobs !== CONST.INTEGRATION_ENTITY_MAP_TYPES.NETSUITE_DEFAULT) { - updateNetSuiteImportMapping(policyID, CONST.NETSUITE_CONFIG.SYNC_OPTIONS.MAPPING.JOBS, value, importMappings?.jobs); + updateNetSuiteImportMapping(policyID, CONST.NETSUITE_CONFIG.SYNC_OPTIONS.CUSTOMER_MAPPINGS.JOBS, value, importMappings?.jobs); } if (importCustomer !== CONST.INTEGRATION_ENTITY_MAP_TYPES.NETSUITE_DEFAULT) { - updateNetSuiteImportMapping(policyID, CONST.NETSUITE_CONFIG.SYNC_OPTIONS.MAPPING.CUSTOMERS, value, importMappings?.customers); + updateNetSuiteImportMapping(policyID, CONST.NETSUITE_CONFIG.SYNC_OPTIONS.CUSTOMER_MAPPINGS.CUSTOMERS, value, importMappings?.customers); } } Navigation.goBack(); diff --git a/src/pages/workspace/accounting/netsuite/import/NetSuiteImportCustomersOrProjectsPage.tsx b/src/pages/workspace/accounting/netsuite/import/NetSuiteImportCustomersOrProjectsPage.tsx index 655787a746b0..e4dc6ff40114 100644 --- a/src/pages/workspace/accounting/netsuite/import/NetSuiteImportCustomersOrProjectsPage.tsx +++ b/src/pages/workspace/accounting/netsuite/import/NetSuiteImportCustomersOrProjectsPage.tsx @@ -41,7 +41,7 @@ function NetSuiteImportCustomersOrProjectsPage({policy}: WithPolicyConnectionsPr newValue = CONST.INTEGRATION_ENTITY_MAP_TYPES.NETSUITE_DEFAULT; } else { // when we enable any field, and if the other one already has a value set, we should set that, - const otherFieldValue = importField === CONST.NETSUITE_CONFIG.SYNC_OPTIONS.MAPPING.JOBS ? config?.syncOptions?.mapping?.customers : config?.syncOptions?.mapping?.jobs; + const otherFieldValue = importField === CONST.NETSUITE_CONFIG.SYNC_OPTIONS.CUSTOMER_MAPPINGS.JOBS ? config?.syncOptions?.mapping?.customers : config?.syncOptions?.mapping?.jobs; if (otherFieldValue === CONST.INTEGRATION_ENTITY_MAP_TYPES.NETSUITE_DEFAULT) { newValue = CONST.INTEGRATION_ENTITY_MAP_TYPES.TAG; } else { @@ -78,11 +78,11 @@ function NetSuiteImportCustomersOrProjectsPage({policy}: WithPolicyConnectionsPr isActive={(config?.syncOptions?.mapping?.customers ?? CONST.INTEGRATION_ENTITY_MAP_TYPES.NETSUITE_DEFAULT) !== CONST.INTEGRATION_ENTITY_MAP_TYPES.NETSUITE_DEFAULT} switchAccessibilityLabel={translate('workspace.netsuite.import.customersOrJobs.importCustomers')} onToggle={(isEnabled: boolean) => { - updateMapping(CONST.NETSUITE_CONFIG.SYNC_OPTIONS.MAPPING.CUSTOMERS, isEnabled); + updateMapping(CONST.NETSUITE_CONFIG.SYNC_OPTIONS.CUSTOMER_MAPPINGS.CUSTOMERS, isEnabled); }} pendingAction={config?.syncOptions?.mapping?.pendingFields?.customers} - errors={ErrorUtils.getLatestErrorField(config ?? {}, CONST.NETSUITE_CONFIG.SYNC_OPTIONS.MAPPING.CUSTOMERS)} - onCloseError={() => Policy.clearNetSuiteErrorField(policyID, CONST.NETSUITE_CONFIG.SYNC_OPTIONS.MAPPING.CUSTOMERS)} + errors={ErrorUtils.getLatestErrorField(config ?? {}, CONST.NETSUITE_CONFIG.SYNC_OPTIONS.CUSTOMER_MAPPINGS.CUSTOMERS)} + onCloseError={() => Policy.clearNetSuiteErrorField(policyID, CONST.NETSUITE_CONFIG.SYNC_OPTIONS.CUSTOMER_MAPPINGS.CUSTOMERS)} /> { - updateMapping(CONST.NETSUITE_CONFIG.SYNC_OPTIONS.MAPPING.JOBS, isEnabled); + updateMapping(CONST.NETSUITE_CONFIG.SYNC_OPTIONS.CUSTOMER_MAPPINGS.JOBS, isEnabled); }} pendingAction={config?.syncOptions?.mapping?.pendingFields?.jobs} - errors={ErrorUtils.getLatestErrorField(config ?? {}, CONST.NETSUITE_CONFIG.SYNC_OPTIONS.MAPPING.JOBS)} - onCloseError={() => Policy.clearNetSuiteErrorField(policyID, CONST.NETSUITE_CONFIG.SYNC_OPTIONS.MAPPING.JOBS)} + errors={ErrorUtils.getLatestErrorField(config ?? {}, CONST.NETSUITE_CONFIG.SYNC_OPTIONS.CUSTOMER_MAPPINGS.JOBS)} + onCloseError={() => Policy.clearNetSuiteErrorField(policyID, CONST.NETSUITE_CONFIG.SYNC_OPTIONS.CUSTOMER_MAPPINGS.JOBS)} /> { - Policy.clearNetSuiteErrorField(policyID, CONST.NETSUITE_CONFIG.SYNC_OPTIONS.MAPPING.CUSTOMERS); - Policy.clearNetSuiteErrorField(policyID, CONST.NETSUITE_CONFIG.SYNC_OPTIONS.MAPPING.JOBS); + Policy.clearNetSuiteErrorField(policyID, CONST.NETSUITE_CONFIG.SYNC_OPTIONS.CUSTOMER_MAPPINGS.CUSTOMERS); + Policy.clearNetSuiteErrorField(policyID, CONST.NETSUITE_CONFIG.SYNC_OPTIONS.CUSTOMER_MAPPINGS.JOBS); }} > { - Policy.clearNetSuiteErrorField(policyID, CONST.NETSUITE_CONFIG.SYNC_OPTIONS.MAPPING.CUSTOMERS); - Policy.clearNetSuiteErrorField(policyID, CONST.NETSUITE_CONFIG.SYNC_OPTIONS.MAPPING.JOBS); + Policy.clearNetSuiteErrorField(policyID, CONST.NETSUITE_CONFIG.SYNC_OPTIONS.CUSTOMER_MAPPINGS.CUSTOMERS); + Policy.clearNetSuiteErrorField(policyID, CONST.NETSUITE_CONFIG.SYNC_OPTIONS.CUSTOMER_MAPPINGS.JOBS); }} > Date: Fri, 5 Jul 2024 02:06:28 +0530 Subject: [PATCH 46/47] refactor: simplify condition --- src/libs/PolicyUtils.ts | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/libs/PolicyUtils.ts b/src/libs/PolicyUtils.ts index 9c1939093201..b1ed1df7be91 100644 --- a/src/libs/PolicyUtils.ts +++ b/src/libs/PolicyUtils.ts @@ -545,12 +545,13 @@ function getCustomersOrJobsLabelNetSuite(policy: Policy | undefined, translate: const importFields: string[] = []; const importCustomer = importMapping?.customers ?? CONST.INTEGRATION_ENTITY_MAP_TYPES.NETSUITE_DEFAULT; const importJobs = importMapping?.jobs ?? CONST.INTEGRATION_ENTITY_MAP_TYPES.NETSUITE_DEFAULT; - const importedValue = importMapping?.customers !== CONST.INTEGRATION_ENTITY_MAP_TYPES.NETSUITE_DEFAULT ? importCustomer : importJobs; - if (!importedValue || importedValue === CONST.INTEGRATION_ENTITY_MAP_TYPES.NETSUITE_DEFAULT) { + if (importCustomer === CONST.INTEGRATION_ENTITY_MAP_TYPES.NETSUITE_DEFAULT && importJobs === CONST.INTEGRATION_ENTITY_MAP_TYPES.NETSUITE_DEFAULT) { return undefined; } + const importedValue = importMapping?.customers !== CONST.INTEGRATION_ENTITY_MAP_TYPES.NETSUITE_DEFAULT ? importCustomer : importJobs; + if (importCustomer !== CONST.INTEGRATION_ENTITY_MAP_TYPES.NETSUITE_DEFAULT) { importFields.push(translate('workspace.netsuite.import.customersOrJobs.customers')); } From 3acf1ab66361213353f33cf45db0765b492e3b68 Mon Sep 17 00:00:00 2001 From: Manan Jadhav Date: Fri, 5 Jul 2024 02:08:02 +0530 Subject: [PATCH 47/47] refactor: run prettier --- .../netsuite/import/NetSuiteImportCustomersOrProjectsPage.tsx | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/pages/workspace/accounting/netsuite/import/NetSuiteImportCustomersOrProjectsPage.tsx b/src/pages/workspace/accounting/netsuite/import/NetSuiteImportCustomersOrProjectsPage.tsx index e4dc6ff40114..0192c41beb33 100644 --- a/src/pages/workspace/accounting/netsuite/import/NetSuiteImportCustomersOrProjectsPage.tsx +++ b/src/pages/workspace/accounting/netsuite/import/NetSuiteImportCustomersOrProjectsPage.tsx @@ -41,7 +41,8 @@ function NetSuiteImportCustomersOrProjectsPage({policy}: WithPolicyConnectionsPr newValue = CONST.INTEGRATION_ENTITY_MAP_TYPES.NETSUITE_DEFAULT; } else { // when we enable any field, and if the other one already has a value set, we should set that, - const otherFieldValue = importField === CONST.NETSUITE_CONFIG.SYNC_OPTIONS.CUSTOMER_MAPPINGS.JOBS ? config?.syncOptions?.mapping?.customers : config?.syncOptions?.mapping?.jobs; + const otherFieldValue = + importField === CONST.NETSUITE_CONFIG.SYNC_OPTIONS.CUSTOMER_MAPPINGS.JOBS ? config?.syncOptions?.mapping?.customers : config?.syncOptions?.mapping?.jobs; if (otherFieldValue === CONST.INTEGRATION_ENTITY_MAP_TYPES.NETSUITE_DEFAULT) { newValue = CONST.INTEGRATION_ENTITY_MAP_TYPES.TAG; } else {