From 2d5efb259da5207c4165f18a9ee4394435ab56c5 Mon Sep 17 00:00:00 2001 From: daledah Date: Mon, 30 Sep 2024 17:18:52 +0700 Subject: [PATCH] fix: update connectionName --- src/languages/en.ts | 3 +-- src/languages/es.ts | 3 +-- src/languages/params.ts | 9 ++------- src/libs/ReportActionsUtils.ts | 4 ++-- src/pages/home/report/ContextMenu/ContextMenuActions.tsx | 2 +- src/types/onyx/OriginalMessage.ts | 3 ++- src/types/onyx/Policy.ts | 9 +++++++++ 7 files changed, 18 insertions(+), 15 deletions(-) diff --git a/src/languages/en.ts b/src/languages/en.ts index 06943629a838..851cbb861a8b 100755 --- a/src/languages/en.ts +++ b/src/languages/en.ts @@ -8,7 +8,6 @@ import type { AddEmployeeParams, AddressLineParams, AdminCanceledRequestParams, - AllConnectionNameParams, AlreadySignedInParams, ApprovalWorkflowErrorParams, ApprovedAmountParams, @@ -4271,7 +4270,7 @@ const translations = { addEmployee: ({email, role}: AddEmployeeParams) => `added ${email} as ${role === 'user' ? 'member' : 'admin'}`, updateRole: ({email, currentRole, newRole}: UpdateRoleParams) => `updated the role of ${email} from ${currentRole} to ${newRole}`, removeMember: ({email, role}: AddEmployeeParams) => `removed ${role} ${email}`, - removedConnection: ({connectionName}: AllConnectionNameParams) => `Removed connection to ${connectionName}.`, + removedConnection: ({connectionName}: ConnectionNameParams) => `Removed connection to ${CONST.POLICY.CONNECTIONS.NAME_USER_FRIENDLY[connectionName]}.`, }, }, }, diff --git a/src/languages/es.ts b/src/languages/es.ts index 9553340f96bb..663fa81a3243 100644 --- a/src/languages/es.ts +++ b/src/languages/es.ts @@ -6,7 +6,6 @@ import type { AddEmployeeParams, AddressLineParams, AdminCanceledRequestParams, - AllConnectionNameParams, AlreadySignedInParams, ApprovalWorkflowErrorParams, ApprovedAmountParams, @@ -4317,7 +4316,7 @@ const translations = { updateRole: ({email, currentRole, newRole}: UpdateRoleParams) => `actualicé el rol ${email} de ${currentRole === 'user' ? 'miembro' : 'administrador'} a ${newRole === 'user' ? 'miembro' : 'administrador'}`, removeMember: ({email, role}: AddEmployeeParams) => `eliminado ${role === 'user' ? 'miembro' : 'administrador'} ${email}`, - removedConnection: ({connectionName}: AllConnectionNameParams) => `Conexión eliminada a ${connectionName}.`, + removedConnection: ({connectionName}: ConnectionNameParams) => `Conexión eliminada a ${CONST.POLICY.CONNECTIONS.NAME_USER_FRIENDLY[connectionName]}.`, }, }, }, diff --git a/src/languages/params.ts b/src/languages/params.ts index 7362a688312b..bf47401c2cf0 100644 --- a/src/languages/params.ts +++ b/src/languages/params.ts @@ -1,6 +1,6 @@ import type {OnyxInputOrEntry, ReportAction} from '@src/types/onyx'; import type {DelegateRole} from '@src/types/onyx/Account'; -import type {ConnectionName, PolicyConnectionSyncStage, SageIntacctMappingName, Unit} from '@src/types/onyx/Policy'; +import type {AllConnectionName, ConnectionName, PolicyConnectionSyncStage, SageIntacctMappingName, Unit} from '@src/types/onyx/Policy'; import type {ViolationDataType} from '@src/types/onyx/TransactionViolation'; type AddressLineParams = { @@ -338,11 +338,7 @@ type ApprovalWorkflowErrorParams = { }; type ConnectionNameParams = { - connectionName: ConnectionName; -}; - -type AllConnectionNameParams = { - connectionName: string; + connectionName: AllConnectionName; }; type LastSyncDateParams = { @@ -734,5 +730,4 @@ export type { CharacterLengthLimitParams, OptionalParam, AssignCardParams, - AllConnectionNameParams, }; diff --git a/src/libs/ReportActionsUtils.ts b/src/libs/ReportActionsUtils.ts index 0cbd886870c1..d00d1086f18f 100644 --- a/src/libs/ReportActionsUtils.ts +++ b/src/libs/ReportActionsUtils.ts @@ -1727,8 +1727,8 @@ function getRemovedConnectionMessage(reportAction: OnyxEntry): str return ''; } const originalMessage = getOriginalMessage(reportAction); - const connectionName = originalMessage?.connectionName ?? ''; - return Localize.translateLocal('report.actions.type.removedConnection', {connectionName}); + const connectionName = originalMessage?.connectionName; + return connectionName ? Localize.translateLocal('report.actions.type.removedConnection', {connectionName}) : ''; } function getRenamedAction(reportAction: OnyxEntry>) { diff --git a/src/pages/home/report/ContextMenu/ContextMenuActions.tsx b/src/pages/home/report/ContextMenu/ContextMenuActions.tsx index e4d30bb7ee92..8b1dd967c1c0 100644 --- a/src/pages/home/report/ContextMenu/ContextMenuActions.tsx +++ b/src/pages/home/report/ContextMenu/ContextMenuActions.tsx @@ -478,7 +478,7 @@ const ContextMenuActions: ContextMenuAction[] = [ setClipboardMessage(Localize.translateLocal('report.actions.type.integrationSyncFailed', {label, errorMessage})); } else if (ReportActionsUtils.isCardIssuedAction(reportAction)) { setClipboardMessage(ReportActionsUtils.getCardIssuedMessage(reportAction, true)); - } else if (ReportActionsUtils.isActionOfType(action, CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.DELETE_INTEGRATION)) { + } else if (ReportActionsUtils.isActionOfType(reportAction, CONST.REPORT.ACTIONS.TYPE.POLICY_CHANGE_LOG.DELETE_INTEGRATION)) { setClipboardMessage(ReportActionsUtils.getRemovedConnectionMessage(reportAction)); } else if (content) { setClipboardMessage( diff --git a/src/types/onyx/OriginalMessage.ts b/src/types/onyx/OriginalMessage.ts index 6c72b51f0531..ed05db8a3894 100644 --- a/src/types/onyx/OriginalMessage.ts +++ b/src/types/onyx/OriginalMessage.ts @@ -2,6 +2,7 @@ import type {ValueOf} from 'type-fest'; import type CONST from '@src/CONST'; import type DeepValueOf from '@src/types/utils/DeepValueOf'; import type {OldDotOriginalMessageMap} from './OldDotAction'; +import {AllConnectionName} from './Policy'; import type ReportActionName from './ReportActionName'; /** Types of join workspace resolutions */ @@ -273,7 +274,7 @@ type OriginalMessageChangeLog = { oldValue?: string; /** Name of connection */ - connectionName?: string; + connectionName?: AllConnectionName; }; /** Model of `join policy changelog` report action */ diff --git a/src/types/onyx/Policy.ts b/src/types/onyx/Policy.ts index aae6486c8130..ba1d7f772166 100644 --- a/src/types/onyx/Policy.ts +++ b/src/types/onyx/Policy.ts @@ -1232,9 +1232,17 @@ type Connections = { [CONST.POLICY.CONNECTIONS.NAME.SAGE_INTACCT]: Connection; }; +type AllConnections = Connections & { + /** Quickbooks Desktop integration connection*/ + quickbooksDesktop: any; +}; + /** Names of integration connections */ type ConnectionName = keyof Connections; +/** Names of all integration connections */ +type AllConnectionName = keyof AllConnections; + /** Merchant Category Code. This is a way to identify the type of merchant (and type of spend) when a credit card is swiped. */ type MccGroup = { /** Default category for provided MCC Group */ @@ -1728,6 +1736,7 @@ export type { Connections, SageIntacctOfflineStateKeys, ConnectionName, + AllConnectionName, Tenant, Account, QBONonReimbursableExportAccountType,