Skip to content

Commit

Permalink
Merge pull request #49580 from mananjadhav/mj-netsuite-helper-text-cu…
Browse files Browse the repository at this point in the history
…stom-list

[NetSuite] Add helper text for custom segment/records/list
  • Loading branch information
yuwenmemon authored Oct 1, 2024
2 parents edfcce4 + 65f8753 commit def32f4
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/languages/en.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ import type {
GoBackMessageParams,
GoToRoomParams,
ImportedTagsMessageParams,
ImportedTypesParams,
ImportFieldParams,
ImportMembersSuccessfullDescriptionParams,
ImportTagsSuccessfullDescriptionParams,
Expand Down Expand Up @@ -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',
Expand Down
2 changes: 2 additions & 0 deletions src/languages/es.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ import type {
GoBackMessageParams,
GoToRoomParams,
ImportedTagsMessageParams,
ImportedTypesParams,
ImportFieldParams,
ImportMembersSuccessfullDescriptionParams,
ImportTagsSuccessfullDescriptionParams,
Expand Down Expand Up @@ -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',
Expand Down
5 changes: 5 additions & 0 deletions src/languages/params.ts
Original file line number Diff line number Diff line change
Expand Up @@ -533,6 +533,10 @@ type AuthenticationErrorParams = {
connectionName: string;
};

type ImportedTypesParams = {
importedTypes: string[];
};

export type {
AuthenticationErrorParams,
ImportMembersSuccessfullDescriptionParams,
Expand Down Expand Up @@ -730,4 +734,5 @@ export type {
CharacterLengthLimitParams,
OptionalParam,
AssignCardParams,
ImportedTypesParams,
};
18 changes: 18 additions & 0 deletions src/libs/PolicyUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<typeof CONST.NETSUITE_CONFIG.IMPORT_CUSTOM_FIELDS>,
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;
}
Expand Down Expand Up @@ -1135,6 +1152,7 @@ export {
getDomainNameForPolicy,
hasUnsupportedIntegration,
getWorkflowApprovalsUnavailable,
getNetSuiteImportCustomFieldLabel,
};

export type {MemberEmailsToAccountIDs};
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,7 @@ function NetSuiteImportPage({policy}: WithPolicyConnectionsProps) {
shouldDisableStrikeThrough
>
<MenuItemWithTopDescription
title={PolicyUtils.getNetSuiteImportCustomFieldLabel(policy, importField, translate)}
description={translate(`workspace.netsuite.import.importCustomFields.${importField}.title`)}
shouldShowRightIcon
onPress={() => Navigation.navigate(ROUTES.POLICY_ACCOUNTING_NETSUITE_IMPORT_CUSTOM_FIELD_MAPPING.getRoute(policyID, importField))}
Expand Down

0 comments on commit def32f4

Please sign in to comment.