From 340c415f5fa6fbe4fbea0f7a9602320762cbebcd Mon Sep 17 00:00:00 2001 From: Abdelhafidh Belalia <16493223+s77rt@users.noreply.github.com> Date: Fri, 10 Jan 2025 03:30:46 +0100 Subject: [PATCH 1/3] multiselector draft --- src/CONST.ts | 5 + src/ONYXKEYS.ts | 4 + src/ROUTES.ts | 9 ++ src/SCREENS.ts | 2 + .../ConnectToNetSuiteQuickStartFlow/index.tsx | 16 +++ .../ConnectToNetSuiteQuickStartFlow/types.ts | 10 ++ src/languages/en.ts | 6 + src/libs/AccountingUtils.ts | 2 + .../ModalStackNavigators/index.tsx | 2 + .../FULL_SCREEN_TO_RHP_MAPPING.ts | 2 + src/libs/Navigation/linkingConfig/config.ts | 4 + src/libs/Navigation/types.ts | 7 ++ .../MultiConnectionSelectorPage.tsx | 108 ++++++++++++++++++ .../accounting/PolicyAccountingPage.tsx | 29 ++++- .../nsqs/NetSuiteQuickStartSetupPage.tsx | 76 ++++++++++++ src/pages/workspace/accounting/types.ts | 5 + src/pages/workspace/accounting/utils.tsx | 21 ++++ .../form/NetSuiteQuickStartOAuth2Form.ts | 18 +++ src/types/form/index.ts | 1 + src/types/onyx/Policy.ts | 3 + 20 files changed, 326 insertions(+), 4 deletions(-) create mode 100644 src/components/ConnectToNetSuiteQuickStartFlow/index.tsx create mode 100644 src/components/ConnectToNetSuiteQuickStartFlow/types.ts create mode 100644 src/pages/workspace/accounting/MultiConnectionSelectorPage.tsx create mode 100644 src/pages/workspace/accounting/nsqs/NetSuiteQuickStartSetupPage.tsx create mode 100644 src/types/form/NetSuiteQuickStartOAuth2Form.ts diff --git a/src/CONST.ts b/src/CONST.ts index ea5923ddb706..eeeb9fed39a7 100755 --- a/src/CONST.ts +++ b/src/CONST.ts @@ -2589,17 +2589,20 @@ const CONST = { QBD: 'quickbooksDesktop', XERO: 'xero', NETSUITE: 'netsuite', + NSQS: 'nsqs', SAGE_INTACCT: 'intacct', }, ROUTE: { QBO: 'quickbooks-online', XERO: 'xero', NETSUITE: 'netsuite', + NSQS: 'netsuite-quickstart', SAGE_INTACCT: 'sage-intacct', QBD: 'quickbooks-desktop', }, NAME_USER_FRIENDLY: { netsuite: 'NetSuite', + nsqs: 'NetSuite QuickStart Edition', quickbooksOnline: 'QuickBooks Online', quickbooksDesktop: 'QuickBooks Desktop', xero: 'Xero', @@ -2613,6 +2616,7 @@ const CONST = { "https://help.expensify.com/articles/expensify-classic/connections/sage-intacct/Sage-Intacct-Troubleshooting#:~:text=First%20make%20sure%20that%20you,your%20company's%20Web%20Services%20authorizations.", netsuite: 'https://help.expensify.com/articles/expensify-classic/connections/netsuite/Netsuite-Troubleshooting#expensierror-ns0109-failed-to-login-to-netsuite-please-verify-your-credentials', + // s77rt: do we have a link for nsqs? }, SYNC_STAGE_NAME: { STARTING_IMPORT_QBO: 'startingImportQBO', @@ -4999,6 +5003,7 @@ const CONST = { quickbooksOnline: 'QuickBooks Online', xero: 'Xero', netsuite: 'NetSuite', + // s77rt: Do I need to add NSQS here? intacct: 'Sage Intacct', quickbooksDesktop: 'QuickBooks Desktop', }, diff --git a/src/ONYXKEYS.ts b/src/ONYXKEYS.ts index 6b26ecd73700..01fdf1509f43 100755 --- a/src/ONYXKEYS.ts +++ b/src/ONYXKEYS.ts @@ -708,6 +708,8 @@ const ONYXKEYS = { NETSUITE_TOKEN_INPUT_FORM_DRAFT: 'netsuiteTokenInputFormDraft', NETSUITE_CUSTOM_FORM_ID_FORM: 'netsuiteCustomFormIDForm', NETSUITE_CUSTOM_FORM_ID_FORM_DRAFT: 'netsuiteCustomFormIDFormDraft', + NSQS_OAUTH2_FORM: 'nsqsOAuth2Form', + NSQS_OAUTH2_FORM_DRAFT: 'nsqsOAuth2FormDraft', SAGE_INTACCT_DIMENSION_TYPE_FORM: 'sageIntacctDimensionTypeForm', SAGE_INTACCT_DIMENSION_TYPE_FORM_DRAFT: 'sageIntacctDimensionTypeFormDraft', SEARCH_ADVANCED_FILTERS_FORM: 'searchAdvancedFiltersForm', @@ -817,6 +819,8 @@ type OnyxFormValuesMapping = { [ONYXKEYS.FORMS.NETSUITE_CUSTOM_SEGMENT_ADD_FORM]: FormTypes.NetSuiteCustomFieldForm; [ONYXKEYS.FORMS.NETSUITE_TOKEN_INPUT_FORM]: FormTypes.NetSuiteTokenInputForm; [ONYXKEYS.FORMS.NETSUITE_CUSTOM_FORM_ID_FORM]: FormTypes.NetSuiteCustomFormIDForm; + [ONYXKEYS.FORMS.NSQS_OAUTH2_FORM]: FormTypes.NetSuiteQuickStartOAuth2Form; + [ONYXKEYS.FORMS.NSQS_OAUTH2_FORM_DRAFT]: FormTypes.NetSuiteQuickStartOAuth2Form; [ONYXKEYS.FORMS.SAGE_INTACCT_DIMENSION_TYPE_FORM]: FormTypes.SageIntacctDimensionForm; [ONYXKEYS.FORMS.SEARCH_ADVANCED_FILTERS_FORM]: FormTypes.SearchAdvancedFiltersForm; [ONYXKEYS.FORMS.TEXT_PICKER_MODAL_FORM]: FormTypes.TextPickerModalForm; diff --git a/src/ROUTES.ts b/src/ROUTES.ts index 062da712cd7f..daad01f50de1 100644 --- a/src/ROUTES.ts +++ b/src/ROUTES.ts @@ -1008,6 +1008,11 @@ const ROUTES = { getRoute: (policyID: string, connection?: ValueOf) => `settings/workspaces/${policyID}/accounting/${connection as string}/card-reconciliation/account` as const, }, + WORKSPACE_ACCOUNTING_MULTI_CONNECTION_SELECTOR: { + route: 'settings/workspaces/:policyID/accounting/:connection/connection-selector', + getRoute: (policyID: string, connection?: ValueOf) => + `settings/workspaces/${policyID}/accounting/${connection as string}/connection-selector` as const, + }, WORKSPACE_CATEGORIES: { route: 'settings/workspaces/:policyID/categories', getRoute: (policyID: string) => `settings/workspaces/${policyID}/categories` as const, @@ -1759,6 +1764,10 @@ const ROUTES = { route: 'settings/workspaces/:policyID/connections/netsuite/advanced/autosync/accounting-method', getRoute: (policyID: string) => `settings/workspaces/${policyID}/connections/netsuite/advanced/autosync/accounting-method` as const, }, + POLICY_ACCOUNTING_NSQS_SETUP: { + route: 'settings/workspaces/:policyID/connections/netsuite-quickstart/setup', + getRoute: (policyID: string) => `settings/workspaces/${policyID}/connections/netsuite-quickstart/setup` as const, + }, POLICY_ACCOUNTING_SAGE_INTACCT_PREREQUISITES: { route: 'settings/workspaces/:policyID/accounting/sage-intacct/prerequisites', getRoute: (policyID: string) => `settings/workspaces/${policyID}/accounting/sage-intacct/prerequisites` as const, diff --git a/src/SCREENS.ts b/src/SCREENS.ts index 2359324c9b90..dab5224fefb4 100644 --- a/src/SCREENS.ts +++ b/src/SCREENS.ts @@ -422,6 +422,7 @@ const SCREENS = { NETSUITE_CUSTOM_FORM_ID: 'Policy_Accounting_NetSuite_Custom_Form_ID', NETSUITE_AUTO_SYNC: 'Policy_Accounting_NetSuite_Auto_Sync', NETSUITE_ACCOUNTING_METHOD: 'Policy_Accounting_NetSuite_Accounting_Method', + NSQS_SETUP: 'Policy_Accounting_NetSuite_QuickStart_Setup', 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', @@ -445,6 +446,7 @@ const SCREENS = { SAGE_INTACCT_PAYMENT_ACCOUNT: 'Policy_Accounting_Sage_Intacct_Payment_Account', CARD_RECONCILIATION: 'Policy_Accounting_Card_Reconciliation', RECONCILIATION_ACCOUNT_SETTINGS: 'Policy_Accounting_Reconciliation_Account_Settings', + MULTI_CONNECTION_SELECTOR: 'Policy_Accounting_Multi_Connection_Selector', }, INITIAL: 'Workspace_Initial', PROFILE: 'Workspace_Profile', diff --git a/src/components/ConnectToNetSuiteQuickStartFlow/index.tsx b/src/components/ConnectToNetSuiteQuickStartFlow/index.tsx new file mode 100644 index 000000000000..1eb66affa14d --- /dev/null +++ b/src/components/ConnectToNetSuiteQuickStartFlow/index.tsx @@ -0,0 +1,16 @@ +import {useEffect} from 'react'; +import Navigation from '@libs/Navigation/Navigation'; +import ROUTES from '@src/ROUTES'; +import type {ConnectToNetSuiteQuickStartFlowProps} from './types'; + +// s77rt: verify that using a previously connected nsqs is not a supported feature +function ConnectToNetSuiteQuickStartFlow({policyID}: ConnectToNetSuiteQuickStartFlowProps) { + useEffect(() => { + Navigation.navigate(ROUTES.POLICY_ACCOUNTING_NSQS_SETUP.getRoute(policyID)); + // eslint-disable-next-line react-compiler/react-compiler, react-hooks/exhaustive-deps + }, []); + + return null; +} + +export default ConnectToNetSuiteQuickStartFlow; diff --git a/src/components/ConnectToNetSuiteQuickStartFlow/types.ts b/src/components/ConnectToNetSuiteQuickStartFlow/types.ts new file mode 100644 index 000000000000..9942e421ce5c --- /dev/null +++ b/src/components/ConnectToNetSuiteQuickStartFlow/types.ts @@ -0,0 +1,10 @@ +import type {PolicyConnectionName} from '@src/types/onyx/Policy'; + +type ConnectToNetSuiteQuickStartFlowProps = { + policyID: string; + shouldDisconnectIntegrationBeforeConnecting?: boolean; + integrationToDisconnect?: PolicyConnectionName; +}; + +// eslint-disable-next-line import/prefer-default-export +export type {ConnectToNetSuiteQuickStartFlowProps}; diff --git a/src/languages/en.ts b/src/languages/en.ts index d9600911d162..fdb25b63049f 100755 --- a/src/languages/en.ts +++ b/src/languages/en.ts @@ -3289,6 +3289,7 @@ const translations = { }, }, }, + nsqs: {}, intacct: { sageIntacctSetup: 'Sage Intacct setup', prerequisitesTitle: 'Before you connect...', @@ -3900,6 +3901,7 @@ const translations = { qbd: 'QuickBooks Desktop', xero: 'Xero', netsuite: 'NetSuite', + nsqs: 'NetSuite QuickStart Edition', intacct: 'Sage Intacct', talkYourOnboardingSpecialist: 'Chat with your setup specialist.', talkYourAccountManager: 'Chat with your account manager.', @@ -3913,6 +3915,8 @@ const translations = { return 'Xero'; case CONST.POLICY.CONNECTIONS.NAME.NETSUITE: return 'NetSuite'; + case CONST.POLICY.CONNECTIONS.NAME.NSQS: + return 'NetSuite QuickStart Edition'; case CONST.POLICY.CONNECTIONS.NAME.SAGE_INTACCT: return 'Sage Intacct'; default: { @@ -3947,6 +3951,8 @@ const translations = { return "Can't connect to Xero."; case CONST.POLICY.CONNECTIONS.NAME.NETSUITE: return "Can't connect to NetSuite."; + case CONST.POLICY.CONNECTIONS.NAME.NSQS: + return "Can't connect to NetSuite QuickStart Edition."; case CONST.POLICY.CONNECTIONS.NAME.QBD: return "Can't connect to QuickBooks Desktop."; default: { diff --git a/src/libs/AccountingUtils.ts b/src/libs/AccountingUtils.ts index 7516048241d6..6f1023a1c136 100644 --- a/src/libs/AccountingUtils.ts +++ b/src/libs/AccountingUtils.ts @@ -7,6 +7,7 @@ const ROUTE_NAME_MAPPING = { [CONST.POLICY.CONNECTIONS.ROUTE.XERO]: CONST.POLICY.CONNECTIONS.NAME.XERO, [CONST.POLICY.CONNECTIONS.ROUTE.SAGE_INTACCT]: CONST.POLICY.CONNECTIONS.NAME.SAGE_INTACCT, [CONST.POLICY.CONNECTIONS.ROUTE.NETSUITE]: CONST.POLICY.CONNECTIONS.NAME.NETSUITE, + [CONST.POLICY.CONNECTIONS.ROUTE.NSQS]: CONST.POLICY.CONNECTIONS.NAME.NSQS, [CONST.POLICY.CONNECTIONS.ROUTE.QBD]: CONST.POLICY.CONNECTIONS.NAME.QBD, }; @@ -15,6 +16,7 @@ const NAME_ROUTE_MAPPING = { [CONST.POLICY.CONNECTIONS.NAME.XERO]: CONST.POLICY.CONNECTIONS.ROUTE.XERO, [CONST.POLICY.CONNECTIONS.NAME.SAGE_INTACCT]: CONST.POLICY.CONNECTIONS.ROUTE.SAGE_INTACCT, [CONST.POLICY.CONNECTIONS.NAME.NETSUITE]: CONST.POLICY.CONNECTIONS.ROUTE.NETSUITE, + [CONST.POLICY.CONNECTIONS.NAME.NSQS]: CONST.POLICY.CONNECTIONS.ROUTE.NSQS, [CONST.POLICY.CONNECTIONS.NAME.QBD]: CONST.POLICY.CONNECTIONS.ROUTE.QBD, }; diff --git a/src/libs/Navigation/AppNavigator/ModalStackNavigators/index.tsx b/src/libs/Navigation/AppNavigator/ModalStackNavigators/index.tsx index e05d316bd8ca..a766c9e7ca3a 100644 --- a/src/libs/Navigation/AppNavigator/ModalStackNavigators/index.tsx +++ b/src/libs/Navigation/AppNavigator/ModalStackNavigators/index.tsx @@ -489,6 +489,7 @@ const SettingsModalStackNavigator = createModalStackNavigator require('../../../../pages/workspace/accounting/netsuite/advanced/NetSuiteAutoSyncPage').default, [SCREENS.WORKSPACE.ACCOUNTING.NETSUITE_ACCOUNTING_METHOD]: () => require('../../../../pages/workspace/accounting/netsuite/advanced/NetSuiteAccountingMethodPage').default, + [SCREENS.WORKSPACE.ACCOUNTING.NSQS_SETUP]: () => require('../../../../pages/workspace/accounting/nsqs/NetSuiteQuickStartSetupPage').default, [SCREENS.WORKSPACE.ACCOUNTING.SAGE_INTACCT_PREREQUISITES]: () => require('../../../../pages/workspace/accounting/intacct/SageIntacctPrerequisitesPage').default, [SCREENS.WORKSPACE.ACCOUNTING.ENTER_SAGE_INTACCT_CREDENTIALS]: () => require('../../../../pages/workspace/accounting/intacct/EnterSageIntacctCredentialsPage').default, @@ -516,6 +517,7 @@ const SettingsModalStackNavigator = createModalStackNavigator require('../../../../pages/workspace/accounting/reconciliation/CardReconciliationPage').default, [SCREENS.WORKSPACE.ACCOUNTING.RECONCILIATION_ACCOUNT_SETTINGS]: () => require('../../../../pages/workspace/accounting/reconciliation/ReconciliationAccountSettingsPage').default, + [SCREENS.WORKSPACE.ACCOUNTING.MULTI_CONNECTION_SELECTOR]: () => require('../../../../pages/workspace/accounting/MultiConnectionSelectorPage').default, [SCREENS.WORKSPACE.WORKFLOWS_AUTO_REPORTING_FREQUENCY]: () => require('../../../../pages/workspace/workflows/WorkspaceAutoReportingFrequencyPage').default, [SCREENS.WORKSPACE.WORKFLOWS_AUTO_REPORTING_MONTHLY_OFFSET]: () => require('../../../../pages/workspace/workflows/WorkspaceAutoReportingMonthlyOffsetPage').default, [SCREENS.WORKSPACE.TAX_EDIT]: () => require('../../../../pages/workspace/taxes/WorkspaceEditTaxPage').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 9a03409fb3a2..7874c017e567 100755 --- a/src/libs/Navigation/linkingConfig/FULL_SCREEN_TO_RHP_MAPPING.ts +++ b/src/libs/Navigation/linkingConfig/FULL_SCREEN_TO_RHP_MAPPING.ts @@ -125,6 +125,7 @@ const FULL_SCREEN_TO_RHP_MAPPING: Partial> = { SCREENS.WORKSPACE.ACCOUNTING.NETSUITE_CUSTOM_FORM_ID, SCREENS.WORKSPACE.ACCOUNTING.NETSUITE_AUTO_SYNC, SCREENS.WORKSPACE.ACCOUNTING.NETSUITE_ACCOUNTING_METHOD, + SCREENS.WORKSPACE.ACCOUNTING.NSQS_SETUP, SCREENS.WORKSPACE.ACCOUNTING.SAGE_INTACCT_PREREQUISITES, SCREENS.WORKSPACE.ACCOUNTING.ENTER_SAGE_INTACCT_CREDENTIALS, SCREENS.WORKSPACE.ACCOUNTING.EXISTING_SAGE_INTACCT_CONNECTIONS, @@ -148,6 +149,7 @@ const FULL_SCREEN_TO_RHP_MAPPING: Partial> = { SCREENS.WORKSPACE.ACCOUNTING.SAGE_INTACCT_PAYMENT_ACCOUNT, SCREENS.WORKSPACE.ACCOUNTING.CARD_RECONCILIATION, SCREENS.WORKSPACE.ACCOUNTING.RECONCILIATION_ACCOUNT_SETTINGS, + SCREENS.WORKSPACE.ACCOUNTING.MULTI_CONNECTION_SELECTOR, ], [SCREENS.WORKSPACE.TAXES]: [ SCREENS.WORKSPACE.TAXES_SETTINGS, diff --git a/src/libs/Navigation/linkingConfig/config.ts b/src/libs/Navigation/linkingConfig/config.ts index 28e0a30dcfc8..1432cb8ecaba 100644 --- a/src/libs/Navigation/linkingConfig/config.ts +++ b/src/libs/Navigation/linkingConfig/config.ts @@ -556,6 +556,9 @@ const config: LinkingOptions['config'] = { [SCREENS.WORKSPACE.ACCOUNTING.NETSUITE_ACCOUNTING_METHOD]: { path: ROUTES.POLICY_ACCOUNTING_NETSUITE_ACCOUNTING_METHOD.route, }, + [SCREENS.WORKSPACE.ACCOUNTING.NSQS_SETUP]: { + path: ROUTES.POLICY_ACCOUNTING_NSQS_SETUP.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}, @@ -581,6 +584,7 @@ const config: LinkingOptions['config'] = { [SCREENS.WORKSPACE.ACCOUNTING.SAGE_INTACCT_PAYMENT_ACCOUNT]: {path: ROUTES.POLICY_ACCOUNTING_SAGE_INTACCT_PAYMENT_ACCOUNT.route}, [SCREENS.WORKSPACE.ACCOUNTING.CARD_RECONCILIATION]: {path: ROUTES.WORKSPACE_ACCOUNTING_CARD_RECONCILIATION.route}, [SCREENS.WORKSPACE.ACCOUNTING.RECONCILIATION_ACCOUNT_SETTINGS]: {path: ROUTES.WORKSPACE_ACCOUNTING_RECONCILIATION_ACCOUNT_SETTINGS.route}, + [SCREENS.WORKSPACE.ACCOUNTING.MULTI_CONNECTION_SELECTOR]: {path: ROUTES.WORKSPACE_ACCOUNTING_MULTI_CONNECTION_SELECTOR.route}, [SCREENS.WORKSPACE.DESCRIPTION]: { path: ROUTES.WORKSPACE_PROFILE_DESCRIPTION.route, }, diff --git a/src/libs/Navigation/types.ts b/src/libs/Navigation/types.ts index ffed2519f775..367427a3b555 100644 --- a/src/libs/Navigation/types.ts +++ b/src/libs/Navigation/types.ts @@ -690,6 +690,9 @@ type SettingsNavigatorParamList = { policyID: string; expenseType: ValueOf; }; + [SCREENS.WORKSPACE.ACCOUNTING.NSQS_SETUP]: { + policyID: string; + }; [SCREENS.WORKSPACE.ACCOUNTING.SAGE_INTACCT_IMPORT]: { policyID: string; }; @@ -754,6 +757,10 @@ type SettingsNavigatorParamList = { policyID: string; connection: ValueOf; }; + [SCREENS.WORKSPACE.ACCOUNTING.MULTI_CONNECTION_SELECTOR]: { + policyID: string; + connection: ValueOf; + }; [SCREENS.GET_ASSISTANCE]: { backTo: Routes; }; diff --git a/src/pages/workspace/accounting/MultiConnectionSelectorPage.tsx b/src/pages/workspace/accounting/MultiConnectionSelectorPage.tsx new file mode 100644 index 000000000000..7dc8503d6942 --- /dev/null +++ b/src/pages/workspace/accounting/MultiConnectionSelectorPage.tsx @@ -0,0 +1,108 @@ +import {title} from 'process'; +import React, {useMemo} from 'react'; +import {ValueOf} from 'type-fest'; +import HeaderWithBackButton from '@components/HeaderWithBackButton'; +import Icon from '@components/Icon'; +import MenuItemList from '@components/MenuItemList'; +import ScreenWrapper from '@components/ScreenWrapper'; +import SelectionList from '@components/SelectionList'; +import RadioListItem from '@components/SelectionList/RadioListItem'; +import {SelectorType} from '@components/SelectionScreen'; +import Text from '@components/Text'; +import useLocalize from '@hooks/useLocalize'; +import useThemeStyles from '@hooks/useThemeStyles'; +import {getConnectionNameFromRouteParam} from '@libs/AccountingUtils'; +import {PlatformStackScreenProps} from '@libs/Navigation/PlatformStackNavigation/types'; +import {SettingsNavigatorParamList} from '@libs/Navigation/types'; +import type {WithPolicyConnectionsProps} from '@pages/workspace/withPolicyConnections'; +import withPolicyConnections from '@pages/workspace/withPolicyConnections'; +import CONST from '@src/CONST'; +import SCREENS from '@src/SCREENS'; +import AccessOrNotFoundWrapper from '../AccessOrNotFoundWrapper'; +import {AccountingContextProvider, useAccountingContext} from './AccountingContext'; +import {AccountingIntegration, MenuItemData} from './types'; +import {getAccountingIntegrationData} from './utils'; + +type MultiConnectionSelectorPageProps = WithPolicyConnectionsProps & { + route: { + params: { + connection: ValueOf; + }; + }; +}; + +function MultiConnectionSelectorPage({policy, route}: MultiConnectionSelectorPageProps) { + const policyID = policy?.id ?? '-1'; + const connection = getConnectionNameFromRouteParam(route.params.connection); + const {translate} = useLocalize(); + const styles = useThemeStyles(); + + // s77rt: set popoverAnchorRefs + const {startIntegrationFlow, popoverAnchorRefs} = useAccountingContext(); + + const connectionNames = CONST.POLICY.CONNECTIONS.NAME; + const accountingIntegrations = Object.values(connectionNames); + const connectionsData = accountingIntegrations.reduce((data, integration) => { + const integrationData = getAccountingIntegrationData(integration, policyID, translate); + if (integrationData?.multiConnectorAlias === connection) { + data.push(integrationData); + } + return data; + }, []); + + const connectionsMenuItems: MenuItemData[] = useMemo( + () => + connectionsData.map((connectionData) => ({ + title: connectionData.title, + icon: connectionData.icon, + iconType: CONST.ICON_TYPE_AVATAR, + shouldShowRightIcon: true, + onPress: () => { + startIntegrationFlow({ + name: connectionData.connectionName, + // s77rt + //integrationToDisconnect: connectedIntegration, + //shouldDisconnectIntegrationBeforeConnecting: true, + }); + }, + })), + [], + ); + + return ( + + + + {translate('workspace.planTypePage.description')} + + + + + ); +} + +function MultiConnectionSelectorPageeWrapper(props: MultiConnectionSelectorPageProps) { + return ( + + + + ); +} + +MultiConnectionSelectorPage.displayName = 'MultiConnectionSelectorPage'; + +export default withPolicyConnections(MultiConnectionSelectorPageeWrapper); diff --git a/src/pages/workspace/accounting/PolicyAccountingPage.tsx b/src/pages/workspace/accounting/PolicyAccountingPage.tsx index 2f38e66b1bed..8d8f782b862a 100644 --- a/src/pages/workspace/accounting/PolicyAccountingPage.tsx +++ b/src/pages/workspace/accounting/PolicyAccountingPage.tsx @@ -28,6 +28,7 @@ import useResponsiveLayout from '@hooks/useResponsiveLayout'; import useTheme from '@hooks/useTheme'; import useThemeStyles from '@hooks/useThemeStyles'; import useWindowDimensions from '@hooks/useWindowDimensions'; +import {getRouteParamForConnection} from '@libs/AccountingUtils'; import {isAuthenticationError, isConnectionInProgress, isConnectionUnverified, removePolicyConnection, syncConnection} from '@libs/actions/connections'; import {getAssignedSupportData} from '@libs/actions/Policy/Policy'; import {getConciergeReportID} from '@libs/actions/Report'; @@ -262,6 +263,9 @@ function PolicyAccountingPage({policy}: PolicyAccountingPageProps) { if (!integrationData) { return undefined; } + if (integrationData.multiConnectorAlias && integrationData.multiConnectorAlias != integration) { + return; + } const iconProps = integrationData?.icon ? {icon: integrationData.icon, iconType: CONST.ICON_TYPE_AVATAR} : {}; return { @@ -272,7 +276,15 @@ function PolicyAccountingPage({policy}: PolicyAccountingPageProps) { title: integrationData?.title, rightComponent: (