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

[NetSuite] Add helper text for custom segment/records/list #49580

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
1 change: 1 addition & 0 deletions src/languages/en.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2680,6 +2680,7 @@ export default {
importCustomFields: {
chooseOptionBelow: 'Choose an option below:',
requiredFieldError: (fieldName: string) => `Please enter the ${fieldName}`,
label: (importedTypes: string[]) => `Imported as ${importedTypes.join(' and ')}`,
customSegments: {
title: 'Custom segments/records',
addText: 'Add custom segment/record',
Expand Down
1 change: 1 addition & 0 deletions src/languages/es.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2724,6 +2724,7 @@ export default {
importCustomFields: {
chooseOptionBelow: 'Elija una de las opciones siguientes:',
requiredFieldError: (fieldName: string) => `Por favor, introduzca el ${fieldName}`,
label: (importedTypes: string[]) => `Importados como ${importedTypes.join(' y ')}`,
customSegments: {
title: 'Segmentos/registros personalizados',
addText: 'Añadir segmento/registro personalizado',
Expand Down
16 changes: 16 additions & 0 deletions src/libs/PolicyUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -828,6 +828,21 @@ 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).map((mapping) => translate(`workspace.netsuite.import.importTypes.${mapping}.label`).toLowerCase());
Copy link
Collaborator Author

@mananjadhav mananjadhav Sep 22, 2024

Choose a reason for hiding this comment

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

@yuwenmemon The GH issue mentions Imported as tags and report fields. Do we care for the order? I am using a loop so if the first mapping is report we could end up seeing Imported as report fields and tags. Is that okay or we always want tags before report fields ?

return translate(`workspace.netsuite.import.importCustomFields.label`, importedTypes);
}

function isNetSuiteCustomSegmentRecord(customField: NetSuiteCustomList | NetSuiteCustomSegment): boolean {
return 'segmentName' in customField;
}
Expand Down Expand Up @@ -1127,6 +1142,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
Loading