Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[#Wave-Control: Add NetSuite] Add Support for NetSuite Token Input #44661

Merged
merged 48 commits into from
Jul 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
48 commits
Select commit Hold shift + click to select a range
a020d54
feat: added page for token input
mananjadhav Jun 27, 2024
b977ffd
feat: added connection layout
mananjadhav Jun 27, 2024
9a307a4
Merge branch 'main' of github.com:mananjadhav/App into mj-netsuite-to…
mananjadhav Jun 28, 2024
3f847a4
feat: ui setup for form steps
mananjadhav Jun 28, 2024
25498ed
fix: added form messages
mananjadhav Jun 28, 2024
deaf512
Merge branch 'main' of github.com:mananjadhav/App into mj-netsuite-to…
mananjadhav Jun 28, 2024
3f6bdee
fix: allow dynamic header
mananjadhav Jun 28, 2024
4c3dbe7
feat: customize back handler and clean up
mananjadhav Jun 28, 2024
40f66c5
feat: added step setup
mananjadhav Jun 29, 2024
57178a3
refactor: styling and prettier fixes
mananjadhav Jun 29, 2024
05f538d
feat: added input form
mananjadhav Jun 29, 2024
ec16dbe
fix: design and spacing updates
mananjadhav Jun 29, 2024
f5d8358
feat: form submission
mananjadhav Jun 29, 2024
e7cd84d
refactor: run prettier
mananjadhav Jun 29, 2024
cc9039a
feat: connect to api
mananjadhav Jun 29, 2024
d113252
fix: update api calls
mananjadhav Jun 29, 2024
22f7ae6
refactor: run prettier
mananjadhav Jun 29, 2024
69463f3
feat: added helper text
mananjadhav Jun 29, 2024
08c30e0
fix: translation
mananjadhav Jun 29, 2024
7edd2b3
refactor: change prop name
mananjadhav Jun 29, 2024
73fae35
refactor: replace for html
mananjadhav Jun 29, 2024
8edf5fc
refactor: run prettier
mananjadhav Jun 29, 2024
d54e38d
refactor: remove unwanted code
mananjadhav Jun 29, 2024
d4b9f35
Merge branch 'main' of github.com:mananjadhav/App into mj-netsuite-to…
mananjadhav Jun 29, 2024
712aae9
refactor: run prettier
mananjadhav Jun 29, 2024
9807cab
refactor: remove setstate and use ref
mananjadhav Jun 30, 2024
0d551f2
refactor: style fixes
mananjadhav Jun 30, 2024
b8c3790
Merge branch 'main' of github.com:mananjadhav/App into mj-netsuite-to…
mananjadhav Jul 1, 2024
7b721f3
refactor: run prettier
mananjadhav Jul 1, 2024
9cadc4b
refactor: remove unused var
mananjadhav Jul 1, 2024
c61be5b
refactor: rename params
mananjadhav Jul 1, 2024
82efe3d
Merge branch 'main' of github.com:mananjadhav/App into mj-netsuite-to…
mananjadhav Jul 1, 2024
f794a89
fix: styling and type errors
mananjadhav Jul 1, 2024
267d32a
Merge branch 'main' of github.com:mananjadhav/App into mj-netsuite-to…
mananjadhav Jul 1, 2024
f777abc
Merge branch 'main' of github.com:mananjadhav/App into mj-netsuite-to…
mananjadhav Jul 2, 2024
4526f4f
fix: broken const file
mananjadhav Jul 2, 2024
385bfda
Merge branch 'main' of github.com:mananjadhav/App into mj-netsuite-to…
mananjadhav Jul 2, 2024
f10ee55
fix: broken const file
mananjadhav Jul 2, 2024
6367eff
refactor: run prettier
mananjadhav Jul 2, 2024
3fce9c1
fix: missing keys
mananjadhav Jul 2, 2024
919c27a
Merge branch 'main' of github.com:mananjadhav/App into mj-netsuite-to…
mananjadhav Jul 3, 2024
0e0d04c
fix: gback
mananjadhav Jul 3, 2024
2c9f2da
refactor: cleanup
mananjadhav Jul 3, 2024
2f73185
Merge branch 'main' of github.com:mananjadhav/App into mj-netsuite-to…
mananjadhav Jul 3, 2024
82388e2
refactor: run prettier
mananjadhav Jul 3, 2024
6da7961
fix: remove optimisticdata
mananjadhav Jul 3, 2024
7753420
fix: add back optimistic data
mananjadhav Jul 3, 2024
7bc2813
fix: remove unwanted change
mananjadhav Jul 4, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions src/CONST.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1372,6 +1372,14 @@ const CONST = {
PROVINCIAL_TAX_POSTING_ACCOUNT: 'provincialTaxPostingAccount',
ALLOW_FOREIGN_CURRENCY: 'allowForeignCurrency',
EXPORT_TO_NEXT_OPEN_PERIOD: 'exportToNextOpenPeriod',
TOKEN_INPUT_STEP_NAMES: ['1', '2,', '3', '4', '5'],
TOKEN_INPUT_STEP_KEYS: {
0: 'installBundle',
1: 'enableTokenAuthentication',
2: 'enableSoapServices',
3: 'createAccessToken',
4: 'enterCredentials',
},
IMPORT_FIELDS: ['departments', 'classes', 'locations', 'customers', 'jobs'],
IMPORT_CUSTOM_FIELDS: ['customSegments', 'customLists'],
SYNC_OPTIONS: {
Expand Down
3 changes: 3 additions & 0 deletions src/ONYXKEYS.ts
Original file line number Diff line number Diff line change
Expand Up @@ -559,6 +559,8 @@ const ONYXKEYS = {
ISSUE_NEW_EXPENSIFY_CARD_FORM_DRAFT: 'issueNewExpensifyCardFormDraft',
SAGE_INTACCT_CREDENTIALS_FORM: 'sageIntacctCredentialsForm',
SAGE_INTACCT_CREDENTIALS_FORM_DRAFT: 'sageIntacctCredentialsFormDraft',
NETSUITE_TOKEN_INPUT_FORM: 'netsuiteTokenInputForm',
NETSUITE_TOKEN_INPUT_FORM_DRAFT: 'netsuiteTokenInputFormDraft',
},
} as const;

Expand Down Expand Up @@ -622,6 +624,7 @@ type OnyxFormValuesMapping = {
[ONYXKEYS.FORMS.SUBSCRIPTION_SIZE_FORM]: FormTypes.SubscriptionSizeForm;
[ONYXKEYS.FORMS.ISSUE_NEW_EXPENSIFY_CARD_FORM]: FormTypes.IssueNewExpensifyCardForm;
[ONYXKEYS.FORMS.SAGE_INTACCT_CREDENTIALS_FORM]: FormTypes.SageIntactCredentialsForm;
[ONYXKEYS.FORMS.NETSUITE_TOKEN_INPUT_FORM]: FormTypes.NetSuiteTokenInputForm;
};

type OnyxFormDraftValuesMapping = {
Expand Down
4 changes: 4 additions & 0 deletions src/ROUTES.ts
Original file line number Diff line number Diff line change
Expand Up @@ -960,6 +960,10 @@ const ROUTES = {
route: 'settings/workspaces/:policyID/accounting/netsuite/subsidiary-selector',
getRoute: (policyID: string) => `settings/workspaces/${policyID}/accounting/netsuite/subsidiary-selector` as const,
},
POLICY_ACCOUNTING_NETSUITE_TOKEN_INPUT: {
route: 'settings/workspaces/:policyID/accounting/netsuite/token-input',
getRoute: (policyID: string) => `settings/workspaces/${policyID}/accounting/netsuite/token-input` as const,
},
POLICY_ACCOUNTING_NETSUITE_IMPORT: {
route: 'settings/workspaces/:policyID/accounting/netsuite/import',
getRoute: (policyID: string) => `settings/workspaces/${policyID}/accounting/netsuite/import` as const,
Expand Down
1 change: 1 addition & 0 deletions src/SCREENS.ts
Original file line number Diff line number Diff line change
Expand Up @@ -272,6 +272,7 @@ const SCREENS = {
XERO_EXPORT_PREFERRED_EXPORTER_SELECT: 'Workspace_Accounting_Xero_Export_Preferred_Exporter_Select',
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_TOKEN_INPUT: 'Policy_Accounting_NetSuite_Token_Input',
NETSUITE_SUBSIDIARY_SELECTOR: 'Policy_Accounting_NetSuite_Subsidiary_Selector',
NETSUITE_IMPORT: 'Policy_Accounting_NetSuite_Import',
NETSUITE_EXPORT: 'Policy_Accounting_NetSuite_Export',
Expand Down
6 changes: 2 additions & 4 deletions src/components/ConnectToNetSuiteButton/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,7 @@ function ConnectToNetSuiteButton({policyID, shouldDisconnectIntegrationBeforeCon
return;
}

// TODO: Will be updated to new token input page
Navigation.navigate(ROUTES.POLICY_ACCOUNTING_NETSUITE_SUBSIDIARY_SELECTOR.getRoute(policyID));
Navigation.navigate(ROUTES.POLICY_ACCOUNTING_NETSUITE_TOKEN_INPUT.getRoute(policyID));
}}
text={translate('workspace.accounting.setup')}
style={styles.justifyContentCenter}
Expand All @@ -39,8 +38,7 @@ function ConnectToNetSuiteButton({policyID, shouldDisconnectIntegrationBeforeCon
onConfirm={() => {
removePolicyConnection(policyID, integrationToDisconnect);

// TODO: Will be updated to new token input page
Navigation.navigate(ROUTES.POLICY_ACCOUNTING_NETSUITE_SUBSIDIARY_SELECTOR.getRoute(policyID));
Navigation.navigate(ROUTES.POLICY_ACCOUNTING_NETSUITE_TOKEN_INPUT.getRoute(policyID));
setIsDisconnectModalOpen(false);
}}
integrationToConnect={CONST.POLICY.CONNECTIONS.NAME.NETSUITE}
Expand Down
17 changes: 10 additions & 7 deletions src/components/ConnectionLayout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import * as PolicyUtils from '@libs/PolicyUtils';
import type {AccessVariant} from '@pages/workspace/AccessOrNotFoundWrapper';
import AccessOrNotFoundWrapper from '@pages/workspace/AccessOrNotFoundWrapper';
import type {TranslationPaths} from '@src/languages/types';
import type {Route} from '@src/ROUTES';
import type {ConnectionName, PolicyFeatureName} from '@src/types/onyx/Policy';
import HeaderWithBackButton from './HeaderWithBackButton';
import ScreenWrapper from './ScreenWrapper';
Expand All @@ -20,9 +19,6 @@ type ConnectionLayoutProps = {
/** Used to set the testID for tests */
displayName: string;

/* The route on back button press */
onBackButtonPressRoute?: Route;

/** Header title to be translated for the connection component */
headerTitle?: TranslationPaths;

Expand Down Expand Up @@ -64,6 +60,12 @@ type ConnectionLayoutProps = {

/** Name of the current connection */
connectionName: ConnectionName;

/** Block the screen when the connection is not empty */
reverseConnectionEmptyCheck?: boolean;
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For the Token Input we want that the connection should be empty and it should be blocked when connection is not empty. I couldn't come up with a better name.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How about `isForEmptyConnection


/** Handler for back button press */
onBackButtonPress?: () => void;
mananjadhav marked this conversation as resolved.
Show resolved Hide resolved
};

type ConnectionLayoutContentProps = Pick<ConnectionLayoutProps, 'title' | 'titleStyle' | 'children' | 'titleAlreadyTranslated'>;
Expand All @@ -81,7 +83,6 @@ function ConnectionLayoutContent({title, titleStyle, children, titleAlreadyTrans

function ConnectionLayout({
displayName,
onBackButtonPressRoute,
headerTitle,
children,
title,
Expand All @@ -96,6 +97,8 @@ function ConnectionLayout({
shouldUseScrollView = true,
headerTitleAlreadyTranslated,
titleAlreadyTranslated,
reverseConnectionEmptyCheck = false,
onBackButtonPress = () => Navigation.goBack(),
}: ConnectionLayoutProps) {
const {translate} = useLocalize();

Expand All @@ -120,7 +123,7 @@ function ConnectionLayout({
policyID={policyID}
accessVariants={accessVariants}
featureName={featureName}
shouldBeBlocked={isConnectionEmpty}
shouldBeBlocked={reverseConnectionEmptyCheck ? !isConnectionEmpty : isConnectionEmpty}
>
<ScreenWrapper
includeSafeAreaPaddingBottom={!!shouldIncludeSafeAreaPaddingBottom}
Expand All @@ -130,7 +133,7 @@ function ConnectionLayout({
<HeaderWithBackButton
title={headerTitleAlreadyTranslated ?? (headerTitle ? translate(headerTitle) : '')}
subtitle={headerSubtitle}
onBackButtonPress={() => Navigation.goBack(onBackButtonPressRoute)}
onBackButtonPress={onBackButtonPress}
/>
{shouldUseScrollView ? (
<ScrollView contentContainerStyle={contentContainerStyle}>{renderSelectionContent}</ScrollView>
Expand Down
6 changes: 6 additions & 0 deletions src/components/InteractiveStepSubHeader.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@ type InteractiveStepSubHeaderProps = {
type InteractiveStepSubHeaderHandle = {
/** Move to the next step */
moveNext: () => void;

/** Move to the previous step */
movePrevious: () => void;
};

const MIN_AMOUNT_FOR_EXPANDING = 3;
Expand All @@ -45,6 +48,9 @@ function InteractiveStepSubHeader({stepNames, startStepIndex = 0, onStepSelected
moveNext: () => {
setCurrentStep((actualStep) => actualStep + 1);
},
movePrevious: () => {
setCurrentStep((actualStep) => actualStep - 1);
},
}),
[],
);
Expand Down
31 changes: 31 additions & 0 deletions src/languages/en.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2298,6 +2298,37 @@ export default {
noItemsFoundDescription: 'Add invoice items in NetSuite and sync the connection again.',
noSubsidiariesFound: 'No subsidiaries found',
noSubsidiariesFoundDescription: 'Add the subsidiary in NetSuite and sync the connection again.',
tokenInput: {
title: 'NetSuite setup',
formSteps: {
installBundle: {
title: 'Install the Expensify bundle',
description: 'In NetSuite, go to *Customization > SuiteBundler > Search & Install Bundles* > search for "Expensify" > install the bundle.',
},
enableTokenAuthentication: {
title: 'Enable token-based authentication',
description: 'In NetSuite, go to *Setup > Company > Enable Features > SuiteCloud* > enable *token-based authentication*.',
mananjadhav marked this conversation as resolved.
Show resolved Hide resolved
},
enableSoapServices: {
title: 'Enable SOAP web services',
description: 'In NetSuite, go to *Setup > Company > Enable Features > SuiteCloud* > enable *SOAP Web Services*.',
},
createAccessToken: {
title: 'Create an access token',
description:
'In NetSuite, go to *Setup > Users/Roles > Access Tokens* > create an access token for the "Expensify" app and either the "Expensify Integration" or "Administrator" role.\n\n*Important:* Make sure you save the *Token ID* and *Token Secret* from this step. You\'ll need it for the next step.',
},
enterCredentials: {
title: 'Enter your NetSuite credentials',
formInputs: {
netSuiteAccountID: 'NetSuite Account ID',
netSuiteTokenID: 'Token ID',
netSuiteTokenSecret: 'Token Secret',
},
netSuiteAccountIDDescription: 'In NetSuite, go to *Setup > Integration > SOAP Web Services Preferences*.',
},
},
},
import: {
expenseCategories: 'Expense categories',
expenseCategoriesDescription: 'NetSuite expense categories import into Expensify as categories.',
Expand Down
33 changes: 32 additions & 1 deletion src/languages/es.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2331,6 +2331,37 @@ export default {
noItemsFoundDescription: 'Añade artículos de factura en NetSuite y sincroniza la conexión de nuevo.',
noSubsidiariesFound: 'No se ha encontrado subsidiarias',
noSubsidiariesFoundDescription: 'Añade la subsidiaria en NetSuite y sincroniza de nuevo la conexión.',
tokenInput: {
title: 'Netsuite configuración',
formSteps: {
installBundle: {
title: 'Instala el paquete de Expensify',
description: 'En NetSuite, ir a *Personalización > SuiteBundler > Buscar e Instalar Paquetes* > busca "Expensify" > instala el paquete.',
},
enableTokenAuthentication: {
title: 'Habilitar la autenticación basada en token',
description: 'En NetSuite, ir a *Configuración > Empresa > Habilitar Funciones > SuiteCloud* > activar *autenticación basada en token*.',
},
enableSoapServices: {
title: 'Habilitar servicios web SOAP',
description: 'En NetSuite, ir a *Configuración > Empresa > Habilitar funciones > SuiteCloud* > habilitar *Servicios Web SOAP*.',
},
createAccessToken: {
title: 'Crear un token de acceso',
description:
'En NetSuite, ir a *Configuración > Usuarios/Roles > Tokens de Acceso* > crear un token de acceso para la aplicación "Expensify" y tambiém para el rol de "Integración Expensify" o "Administrador".\n\n*Importante:* Asegúrese de guardar el ID y el secreto del Token en este paso. Los necesitará para el siguiente paso.',
},
enterCredentials: {
title: 'Ingresa tus credenciales de NetSuite',
formInputs: {
netSuiteAccountID: 'ID de Cuenta NetSuite',
netSuiteTokenID: 'ID de Token',
netSuiteTokenSecret: 'Secreto de Token',
},
netSuiteAccountIDDescription: 'En NetSuite, ir a *Configuración > Integración > Preferencias de Servicios Web SOAP*.',
},
},
},
import: {
expenseCategories: 'Categorías de gastos',
expenseCategoriesDescription: 'Las categorías de gastos de NetSuite se importan a Expensify como categorías.',
Expand All @@ -2343,7 +2374,7 @@ export default {
},
importTaxDescription: 'Importar grupos de impuestos desde NetSuite',
importCustomFields: {
customSegments: 'Segmentos/registros personalizado',
customSegments: 'Segmentos/registros personalizados',
customLists: 'Listas personalizado',
},
},
Expand Down
8 changes: 8 additions & 0 deletions src/libs/API/parameters/ConnectPolicyToNetSuiteParams.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
type ConnectPolicyToNetSuiteParams = {
policyID: string;
netSuiteAccountID: string;
netSuiteTokenID: string;
netSuiteTokenSecret: string;
};

export default ConnectPolicyToNetSuiteParams;
1 change: 1 addition & 0 deletions src/libs/API/parameters/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -237,6 +237,7 @@ export type {default as DeleteMoneyRequestOnSearchParams} from './DeleteMoneyReq
export type {default as HoldMoneyRequestOnSearchParams} from './HoldMoneyRequestOnSearchParams';
export type {default as UnholdMoneyRequestOnSearchParams} from './UnholdMoneyRequestOnSearchParams';
export type {default as UpdateNetSuiteSubsidiaryParams} from './UpdateNetSuiteSubsidiaryParams';
export type {default as ConnectPolicyToNetSuiteParams} from './ConnectPolicyToNetSuiteParams';
export type {default as CreateWorkspaceReportFieldParams} from './CreateWorkspaceReportFieldParams';
export type {default as OpenPolicyExpensifyCardsPageParams} from './OpenPolicyExpensifyCardsPageParams';
export type {default as RequestExpensifyCardLimitIncreaseParams} from './RequestExpensifyCardLimitIncreaseParams';
Expand Down
2 changes: 2 additions & 0 deletions src/libs/API/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -253,6 +253,7 @@ const WRITE_COMMANDS = {
UPDATE_NETSUITE_EXPORT_TO_NEXT_OPEN_PERIOD: 'UpdateNetSuiteExportToNextOpenPeriod',
REQUEST_EXPENSIFY_CARD_LIMIT_INCREASE: 'RequestExpensifyCardLimitIncrease',
CONNECT_POLICY_TO_SAGE_INTACCT: 'ConnectPolicyToSageIntacct',
CONNECT_POLICY_TO_NETSUITE: 'ConnectPolicyToNetSuite',
CLEAR_OUTSTANDING_BALANCE: 'ClearOutstandingBalance',
} as const;

Expand Down Expand Up @@ -495,6 +496,7 @@ type WriteCommandParameters = {

// Netsuite parameters
[WRITE_COMMANDS.UPDATE_NETSUITE_SUBSIDIARY]: Parameters.UpdateNetSuiteSubsidiaryParams;
[WRITE_COMMANDS.CONNECT_POLICY_TO_NETSUITE]: Parameters.ConnectPolicyToNetSuiteParams;

// Workspace report field parameters
[WRITE_COMMANDS.CREATE_WORKSPACE_REPORT_FIELD]: Parameters.CreateWorkspaceReportFieldParams;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -320,6 +320,8 @@ const SettingsModalStackNavigator = createModalStackNavigator<SettingsNavigatorP
require<ReactComponentModule>('../../../../pages/workspace/accounting/xero/advanced/XeroBillPaymentAccountSelectorPage').default,

[SCREENS.WORKSPACE.ACCOUNTING.NETSUITE_SUBSIDIARY_SELECTOR]: () => require<ReactComponentModule>('../../../../pages/workspace/accounting/netsuite/NetSuiteSubsidiarySelector').default,
[SCREENS.WORKSPACE.ACCOUNTING.NETSUITE_TOKEN_INPUT]: () =>
require<ReactComponentModule>('../../../../pages/workspace/accounting/netsuite/NetSuiteTokenInput/NetSuiteTokenInputPage').default,
[SCREENS.WORKSPACE.ACCOUNTING.NETSUITE_IMPORT]: () => require<ReactComponentModule>('../../../../pages/workspace/accounting/netsuite/import/NetSuiteImportPage').default,
[SCREENS.WORKSPACE.ACCOUNTING.NETSUITE_EXPORT]: () => require<ReactComponentModule>('../../../../pages/workspace/accounting/netsuite/export/NetSuiteExportConfigurationPage').default,
[SCREENS.WORKSPACE.ACCOUNTING.NETSUITE_PREFERRED_EXPORTER_SELECT]: () =>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ const FULL_SCREEN_TO_RHP_MAPPING: Partial<Record<FullScreenName, string[]>> = {
SCREENS.WORKSPACE.ACCOUNTING.XERO_BILL_PAYMENT_ACCOUNT_SELECTOR,
SCREENS.WORKSPACE.ACCOUNTING.XERO_EXPORT_BANK_ACCOUNT_SELECT,
SCREENS.WORKSPACE.ACCOUNTING.NETSUITE_SUBSIDIARY_SELECTOR,
SCREENS.WORKSPACE.ACCOUNTING.NETSUITE_TOKEN_INPUT,
SCREENS.WORKSPACE.ACCOUNTING.NETSUITE_IMPORT,
SCREENS.WORKSPACE.ACCOUNTING.NETSUITE_EXPORT,
SCREENS.WORKSPACE.ACCOUNTING.NETSUITE_PREFERRED_EXPORTER_SELECT,
Expand Down
1 change: 1 addition & 0 deletions src/libs/Navigation/linkingConfig/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -354,6 +354,7 @@ const config: LinkingOptions<RootStackParamList>['config'] = {
[SCREENS.WORKSPACE.ACCOUNTING.XERO_EXPORT_PREFERRED_EXPORTER_SELECT]: {path: ROUTES.POLICY_ACCOUNTING_XERO_PREFERRED_EXPORTER_SELECT.route},
[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_TOKEN_INPUT]: {path: ROUTES.POLICY_ACCOUNTING_NETSUITE_TOKEN_INPUT.route},
[SCREENS.WORKSPACE.ACCOUNTING.NETSUITE_IMPORT]: {path: ROUTES.POLICY_ACCOUNTING_NETSUITE_IMPORT.route},
[SCREENS.WORKSPACE.ACCOUNTING.NETSUITE_EXPORT]: {
path: ROUTES.POLICY_ACCOUNTING_NETSUITE_EXPORT.route,
Expand Down
3 changes: 3 additions & 0 deletions src/libs/Navigation/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -416,6 +416,9 @@ type SettingsNavigatorParamList = {
[SCREENS.WORKSPACE.ACCOUNTING.NETSUITE_SUBSIDIARY_SELECTOR]: {
policyID: string;
};
[SCREENS.WORKSPACE.ACCOUNTING.NETSUITE_TOKEN_INPUT]: {
policyID: string;
};
[SCREENS.WORKSPACE.ACCOUNTING.NETSUITE_IMPORT]: {
policyID: string;
};
Expand Down
21 changes: 21 additions & 0 deletions src/libs/actions/connections/NetSuiteCommands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import type {OnyxUpdate} from 'react-native-onyx';
import Onyx from 'react-native-onyx';
import type {ValueOf} from 'type-fest';
import * as API from '@libs/API';
import type {ConnectPolicyToNetSuiteParams} from '@libs/API/parameters';
import {WRITE_COMMANDS} from '@libs/API/types';
import * as ErrorUtils from '@libs/ErrorUtils';
import CONST from '@src/CONST';
Expand All @@ -14,6 +15,25 @@ type SubsidiaryParam = {
subsidiary: string;
};

function connectPolicyToNetSuite(policyID: string, credentials: Omit<ConnectPolicyToNetSuiteParams, 'policyID'>) {
const optimisticData: OnyxUpdate[] = [
{
onyxMethod: Onyx.METHOD.MERGE,
key: `${ONYXKEYS.COLLECTION.POLICY_CONNECTION_SYNC_PROGRESS}${policyID}`,
value: {
stageInProgress: CONST.POLICY.CONNECTIONS.SYNC_STAGE_NAME.NETSUITE_SYNC_CONNECTION,
connectionName: CONST.POLICY.CONNECTIONS.NAME.NETSUITE,
timestamp: new Date().toISOString(),
},
},
];
const parameters: ConnectPolicyToNetSuiteParams = {
policyID,
...credentials,
};
API.write(WRITE_COMMANDS.CONNECT_POLICY_TO_NETSUITE, parameters, {optimisticData});
}

function updateNetSuiteOnyxData<TSettingName extends keyof Connections['netsuite']['options']['config']>(
policyID: string,
settingName: TSettingName,
Expand Down Expand Up @@ -449,4 +469,5 @@ export {
updateNetSuiteProvincialTaxPostingAccount,
updateNetSuiteAllowForeignCurrency,
updateNetSuiteExportToNextOpenPeriod,
connectPolicyToNetSuite,
};
Loading
Loading