diff --git a/src/languages/en.ts b/src/languages/en.ts index 15d135e536c6..7c510197383f 100755 --- a/src/languages/en.ts +++ b/src/languages/en.ts @@ -69,6 +69,7 @@ import type { GoBackMessageParams, GoToRoomParams, ImportedTagsMessageParams, + ImportedTypesParams, ImportFieldParams, ImportMembersSuccessfullDescriptionParams, ImportTagsSuccessfullDescriptionParams, @@ -2773,6 +2774,7 @@ const translations = { importTaxDescription: 'Import tax groups from NetSuite.', importCustomFields: { chooseOptionBelow: 'Choose an option below:', + label: ({importedTypes}: ImportedTypesParams) => `Imported as ${importedTypes.join(' and ')}`, requiredFieldError: ({fieldName}: RequiredFieldParams) => `Please enter the ${fieldName}`, customSegments: { title: 'Custom segments/records', diff --git a/src/languages/es.ts b/src/languages/es.ts index 788b856eb768..88aeffe71566 100644 --- a/src/languages/es.ts +++ b/src/languages/es.ts @@ -67,6 +67,7 @@ import type { GoBackMessageParams, GoToRoomParams, ImportedTagsMessageParams, + ImportedTypesParams, ImportFieldParams, ImportMembersSuccessfullDescriptionParams, ImportTagsSuccessfullDescriptionParams, @@ -2808,6 +2809,7 @@ const translations = { importTaxDescription: 'Importar grupos de impuestos desde NetSuite.', importCustomFields: { chooseOptionBelow: 'Elija una de las opciones siguientes:', + label: ({importedTypes}: ImportedTypesParams) => `Importados como ${importedTypes.join(' y ')}`, requiredFieldError: ({fieldName}: RequiredFieldParams) => `Por favor, introduzca el ${fieldName}`, customSegments: { title: 'Segmentos/registros personalizados', diff --git a/src/languages/params.ts b/src/languages/params.ts index bf47401c2cf0..5560316d2ddd 100644 --- a/src/languages/params.ts +++ b/src/languages/params.ts @@ -533,6 +533,10 @@ type AuthenticationErrorParams = { connectionName: string; }; +type ImportedTypesParams = { + importedTypes: string[]; +}; + export type { AuthenticationErrorParams, ImportMembersSuccessfullDescriptionParams, @@ -730,4 +734,5 @@ export type { CharacterLengthLimitParams, OptionalParam, AssignCardParams, + ImportedTypesParams, }; diff --git a/src/libs/PolicyUtils.ts b/src/libs/PolicyUtils.ts index 2b448d82b863..f7c75d73f2c3 100644 --- a/src/libs/PolicyUtils.ts +++ b/src/libs/PolicyUtils.ts @@ -836,6 +836,23 @@ function getCustomersOrJobsLabelNetSuite(policy: Policy | undefined, translate: return importedValueLabel.charAt(0).toUpperCase() + importedValueLabel.slice(1); } +function getNetSuiteImportCustomFieldLabel( + policy: Policy | undefined, + importField: ValueOf, + translate: LocaleContextProps['translate'], +): string | undefined { + const fieldData = policy?.connections?.netsuite?.options?.config.syncOptions?.[importField] ?? []; + if (fieldData.length === 0) { + return undefined; + } + + const mappingSet = new Set(fieldData.map((item) => item.mapping)); + const importedTypes = Array.from(mappingSet) + .sort((a, b) => b.localeCompare(a)) + .map((mapping) => translate(`workspace.netsuite.import.importTypes.${mapping}.label`).toLowerCase()); + return translate(`workspace.netsuite.import.importCustomFields.label`, {importedTypes}); +} + function isNetSuiteCustomSegmentRecord(customField: NetSuiteCustomList | NetSuiteCustomSegment): boolean { return 'segmentName' in customField; } @@ -1135,6 +1152,7 @@ export { getDomainNameForPolicy, hasUnsupportedIntegration, getWorkflowApprovalsUnavailable, + getNetSuiteImportCustomFieldLabel, }; export type {MemberEmailsToAccountIDs}; diff --git a/src/pages/workspace/accounting/netsuite/import/NetSuiteImportPage.tsx b/src/pages/workspace/accounting/netsuite/import/NetSuiteImportPage.tsx index 0c7ca49d1ec2..0965be4bca81 100644 --- a/src/pages/workspace/accounting/netsuite/import/NetSuiteImportPage.tsx +++ b/src/pages/workspace/accounting/netsuite/import/NetSuiteImportPage.tsx @@ -123,6 +123,7 @@ function NetSuiteImportPage({policy}: WithPolicyConnectionsProps) { shouldDisableStrikeThrough > Navigation.navigate(ROUTES.POLICY_ACCOUNTING_NETSUITE_IMPORT_CUSTOM_FIELD_MAPPING.getRoute(policyID, importField))}