From 3975c8beb7cb82244fb6f5ddc43670305ed67397 Mon Sep 17 00:00:00 2001 From: adhmenon Date: Fri, 31 Oct 2025 15:42:30 +0530 Subject: [PATCH 1/4] ffix(widgets): fixed-consult-transfer-popover-epic-issues --- .../call-control-custom.utils.ts | 57 ++ .../consult-transfer-popover.tsx | 248 ++++---- .../task/CallControl/call-control.styles.scss | 13 + ...consult-transfer-popover.snapshot.tsx.snap | 528 +++++------------- .../consult-transfer-popover.snapshot.tsx | 7 +- .../consult-transfer-popover.tsx | 40 +- packages/contact-center/store/src/store.ts | 2 + .../contact-center/store/src/store.types.ts | 1 + .../store/src/storeEventsWrapper.ts | 7 + .../store/tests/storeEventsWrapper.ts | 10 + 10 files changed, 400 insertions(+), 513 deletions(-) diff --git a/packages/contact-center/cc-components/src/components/task/CallControl/CallControlCustom/call-control-custom.utils.ts b/packages/contact-center/cc-components/src/components/task/CallControl/CallControlCustom/call-control-custom.utils.ts index 06d48003d..671313bd0 100644 --- a/packages/contact-center/cc-components/src/components/task/CallControl/CallControlCustom/call-control-custom.utils.ts +++ b/packages/contact-center/cc-components/src/components/task/CallControl/CallControlCustom/call-control-custom.utils.ts @@ -612,6 +612,30 @@ export const filterAvailableAgents = (agents: BuddyDetails[], logger?): BuddyDet } }; +/** + * Filters buddy agents by a free-text query across name, dn and id. + */ +export const filterAgentsByQuery = (agents: BuddyDetails[], query: string): BuddyDetails[] => { + const q = (query || '').trim().toLowerCase(); + if (!q) return agents || []; + const safeAgents = agents || []; + return safeAgents.filter((a) => { + const name = a.agentName?.toLowerCase() || ''; + const dn = (a as unknown as {dn?: string})?.dn?.toLowerCase() || ''; + const id = a.agentId?.toLowerCase() || ''; + return name.includes(q) || dn.includes(q) || id.includes(q); + }); +}; + +/** + * Returns agents to display for current category, applying search only for Agents tab. + */ +export const getAgentsForDisplay = ( + selectedCategory: 'Agents' | string, + agents: BuddyDetails[], + query: string +): BuddyDetails[] => (selectedCategory === 'Agents' ? filterAgentsByQuery(agents, query) : agents || []); + /** * Filters available queues */ @@ -655,3 +679,36 @@ export const debounce = unknown>( }; } }; + +/** + * Helpers for Dial Number / Entry Point manual actions + */ +export const buildConsultTransferQuickAction = ( + selectedCategory: string, + isEntryPointTabVisible: boolean, + query: string, + entryPoints: {id: string; name: string}[], + onDialNumberSelect: ((dialNumber: string) => void) | undefined, + onEntryPointSelect: ((entryPointId: string, entryPointName: string) => void) | undefined +): {visible: boolean; onClick?: () => void; title?: string} => { + const DN_REGEX = new RegExp('^[+1][0-9]{3,18}$|^[*#:][+1][0-9*#:]{3,18}$|^[0-9*#:]{3,18}$'); + + const isDial = selectedCategory === 'Dial Number'; + const isEntry = selectedCategory === 'Entry Point' && isEntryPointTabVisible; + const valid = DN_REGEX.test(query || ''); + + if (isDial) { + return valid && onDialNumberSelect + ? {visible: true, onClick: () => onDialNumberSelect(query), title: query} + : {visible: false}; + } + + if (isEntry) { + const match = query ? entryPoints?.find((e) => e.name === query || e.id === query) : null; + return valid && match && onEntryPointSelect + ? {visible: true, onClick: () => onEntryPointSelect(match.id, match.name), title: match.name} + : {visible: false}; + } + + return {visible: false}; +}; diff --git a/packages/contact-center/cc-components/src/components/task/CallControl/CallControlCustom/consult-transfer-popover.tsx b/packages/contact-center/cc-components/src/components/task/CallControl/CallControlCustom/consult-transfer-popover.tsx index b17e2158a..ae5613166 100644 --- a/packages/contact-center/cc-components/src/components/task/CallControl/CallControlCustom/consult-transfer-popover.tsx +++ b/packages/contact-center/cc-components/src/components/task/CallControl/CallControlCustom/consult-transfer-popover.tsx @@ -1,9 +1,15 @@ import React from 'react'; -import {Text, ListNext, TextInput, Button} from '@momentum-ui/react-collaboration'; +import {Text, ListNext, TextInput, Button, ButtonCircle, TooltipNext} from '@momentum-ui/react-collaboration'; +import {Icon} from '@momentum-design/components/dist/react'; import ConsultTransferListComponent from './consult-transfer-list-item'; import {ConsultTransferPopoverComponentProps} from '../../task.types'; import ConsultTransferEmptyState from './consult-transfer-empty-state'; -import {isAgentsEmpty, handleAgentSelection, handleQueueSelection} from './call-control-custom.utils'; +import { + handleAgentSelection, + handleQueueSelection, + buildConsultTransferQuickAction, + getAgentsForDisplay, +} from './call-control-custom.utils'; import {useConsultTransferPopover} from './consult-transfer-popover-hooks'; import { SEARCH_PLACEHOLDER, @@ -31,6 +37,7 @@ const ConsultTransferPopoverComponent: React.FC { const {showDialNumberTab = true, showEntryPointTab = true} = consultTransferOptions || {}; + const isEntryPointTabVisible = (showEntryPointTab ?? true) && heading === 'Consult'; const { selectedCategory, searchQuery, @@ -51,15 +58,13 @@ const ConsultTransferPopoverComponent: React.FC( items: T[], onButtonPress: (item: T) => void @@ -84,11 +89,18 @@ const ConsultTransferPopoverComponent: React.FC ); - const noQueues = queuesData.length === 0; + const noQueues = !allowConsultToQueue || queuesData.length === 0; const noDialNumbers = !showDialNumberTab || dialNumbers.length === 0; - const noEntryPoints = !showEntryPointTab || entryPoints.length === 0; + const noEntryPoints = !isEntryPointTabVisible || entryPoints.length === 0; - const hasAnyData = !noAgents || !noQueues || !noDialNumbers || !noEntryPoints; + const consultTransferManualAction = buildConsultTransferQuickAction( + selectedCategory, + isEntryPointTabVisible, + searchQuery, + entryPoints, + onDialNumberSelect, + onEntryPointSelect + ); return (
@@ -96,7 +108,7 @@ const ConsultTransferPopoverComponent: React.FC -
+
+ {consultTransferManualAction.visible && ( + + + + } + color="primary" + delay={[0, 0]} + placement="bottom-start" + type="description" + variant="small" + className="tooltip" + > +

{`${heading} via search`}

+
+ )}
@@ -119,17 +155,18 @@ const ConsultTransferPopoverComponent: React.FC Agents - + {allowConsultToQueue && ( + + )} {showDialNumberTab && (
); }; diff --git a/packages/contact-center/cc-components/src/components/task/CallControl/call-control.styles.scss b/packages/contact-center/cc-components/src/components/task/CallControl/call-control.styles.scss index f560902d8..4c362f71f 100644 --- a/packages/contact-center/cc-components/src/components/task/CallControl/call-control.styles.scss +++ b/packages/contact-center/cc-components/src/components/task/CallControl/call-control.styles.scss @@ -217,8 +217,21 @@ pointer-events: auto; } + .consult-search-row { + display: flex; + align-items: center; + width: 100%; + gap: 0.5rem; + } + .consult-search-input { width: 100%; + flex: 1 1 auto; + min-width: 0; + } + + .consult-quick-action-button { + flex: 0 0 2rem; /* 32px */ } .consult-category-buttons { diff --git a/packages/contact-center/cc-components/tests/components/task/CallControl/CallControlCustom/__snapshots__/consult-transfer-popover.snapshot.tsx.snap b/packages/contact-center/cc-components/tests/components/task/CallControl/CallControlCustom/__snapshots__/consult-transfer-popover.snapshot.tsx.snap index 6b4be453d..bbcdb219c 100644 --- a/packages/contact-center/cc-components/tests/components/task/CallControl/CallControlCustom/__snapshots__/consult-transfer-popover.snapshot.tsx.snap +++ b/packages/contact-center/cc-components/tests/components/task/CallControl/CallControlCustom/__snapshots__/consult-transfer-popover.snapshot.tsx.snap @@ -11,7 +11,9 @@ exports[`ConsultTransferPopoverComponent Snapshots Interactions should render co > Select an Agent -
+
-
    Select an Agent -
    +
    -
      Select an Agent -
      +
      -
        - Select an Agent + Consult -
        +
        Select an Agent -
        +
        -
          Select an Agent -
          +
          - -
            Select an Agent -
            +
            -
            Choose Transfer Target -
            +
            -
              Select an Agent -
              +
              -
              Select an Agent -
              +
              - + No data available for consult transfer. +
              `; @@ -2182,7 +2034,9 @@ exports[`ConsultTransferPopoverComponent Snapshots Rendering - Tests for UI elem > Select an Agent -
              +
              -
                Select an Agent -
                +
                -
                  Select an Agent -
                  +
                  -
                    Select an Agent -
                    +
                    -
                      New Heading -
                      +
                      -
                        Select an Agent -
                        +
                        -
                          { it('should render the component with heading and category buttons', async () => { let screen; await act(async () => { - screen = render(); + screen = render(); }); - expect(screen.getByText('Select an Agent')).toBeInTheDocument(); + expect(screen.getByText('Consult')).toBeInTheDocument(); const btns = Array.from(screen.container.querySelectorAll('button')).map( (b) => (b as HTMLButtonElement).textContent ); @@ -172,8 +172,7 @@ describe('ConsultTransferPopoverComponent Snapshots', () => { const el = btn as HTMLButtonElement; return el && el.textContent === 'Queues'; }) as HTMLButtonElement | undefined; - expect(queuesButton).toBeDefined(); - expect(queuesButton?.disabled).toBe(true); + expect(queuesButton).toBeUndefined(); const container = screen.container.querySelector('.agent-popover-content'); mockUIDProps(container); expect(container).toMatchSnapshot(); diff --git a/packages/contact-center/cc-components/tests/components/task/CallControl/CallControlCustom/consult-transfer-popover.tsx b/packages/contact-center/cc-components/tests/components/task/CallControl/CallControlCustom/consult-transfer-popover.tsx index 704c816f7..e55c65850 100644 --- a/packages/contact-center/cc-components/tests/components/task/CallControl/CallControlCustom/consult-transfer-popover.tsx +++ b/packages/contact-center/cc-components/tests/components/task/CallControl/CallControlCustom/consult-transfer-popover.tsx @@ -3,8 +3,6 @@ import {render, fireEvent, waitFor, act} from '@testing-library/react'; import '@testing-library/jest-dom'; import ConsultTransferPopoverComponent from '../../../../../src/components/task/CallControl/CallControlCustom/consult-transfer-popover'; import {ContactServiceQueue} from '@webex/cc-store'; -// hooks import no longer needed in this test -import * as utils from '../../../../../src/components/task/CallControl/CallControlCustom/call-control-custom.utils'; import {DEFAULT_PAGE_SIZE} from '../../../../../src/components/task/constants'; const loggerMock = { @@ -68,7 +66,7 @@ describe('ConsultTransferPopoverComponent', () => { }); it('renders heading and tabs when showTabs is true', async () => { - const screen = await render(); + const screen = await render(); // Verify main container expect(screen.container.querySelector('.agent-popover-content')).toBeInTheDocument(); @@ -76,7 +74,7 @@ describe('ConsultTransferPopoverComponent', () => { // Verify heading - it's wrapped in mdc-text component const heading = screen.container.querySelector('.agent-popover-title'); expect(heading).toBeInTheDocument(); - expect(heading).toHaveTextContent('Select an Agent'); + expect(heading).toHaveTextContent('Consult'); expect(heading?.tagName.toLowerCase()).toBe('mdc-text'); expect(heading).toHaveAttribute('tagname', 'h3'); expect(heading).toHaveAttribute('type', 'body-large-bold'); @@ -201,7 +199,7 @@ describe('ConsultTransferPopoverComponent', () => { buddyAgents: [], }; - const screen = await render(); + const screen = await render(); const buttons = Array.from(screen.container.querySelectorAll('button')).map( (b) => (b as HTMLButtonElement).textContent ); @@ -222,35 +220,27 @@ describe('ConsultTransferPopoverComponent', () => { expect(screen.container.querySelectorAll('.call-control-list-item').length).toBe(0); }); - it('disables queue selection when allowConsultToQueue is false', async () => { + it('hides queue tab when allowConsultToQueue is false', async () => { const propsWithoutQueue = { ...baseProps, allowConsultToQueue: false, }; const screen = await render(); - const queuesButton = screen.getByRole('button', {name: 'Queues'}) as HTMLButtonElement; - expect(queuesButton.disabled).toBe(true); + const maybeQueuesButton = screen.queryByRole('button', {name: 'Queues'}) as HTMLButtonElement | null; + expect(maybeQueuesButton).toBeNull(); }); it('covers edge case for empty items in renderList (line 50)', async () => { - // Mock isAgentsEmpty to return false even with empty array to force renderList call - const mockIsAgentsEmpty = jest.spyOn(utils, 'isAgentsEmpty').mockReturnValue(false); - - try { - const propsWithEmptyAgents = { - ...baseProps, - buddyAgents: [], // Empty array but mocked to return false for isEmpty - }; - - const screen = await render(); - - // Should render the "No agents found" text via empty list state - expect(screen.getByText('No agents found')).toBeInTheDocument(); - } finally { - // Restore original functions - mockIsAgentsEmpty.mockRestore(); - } + const propsWithEmptyAgents = { + ...baseProps, + buddyAgents: [], + }; + + const screen = await render(); + + // With zero agents, the per-tab empty state should render + expect(screen.getByText('No data available for consult transfer.')).toBeInTheDocument(); }); describe('Search behavior', () => { diff --git a/packages/contact-center/store/src/store.ts b/packages/contact-center/store/src/store.ts index a0b07714c..e22b63d1f 100644 --- a/packages/contact-center/store/src/store.ts +++ b/packages/contact-center/store/src/store.ts @@ -48,6 +48,7 @@ class Store implements IStore { consultOfferReceived: boolean = false; featureFlags: {[key: string]: boolean} = {}; isEndConsultEnabled: boolean = false; + isAddressBookEnabled: boolean = false; allowConsultToQueue: boolean = false; agentProfile: AgentLoginProfile = {}; isMuted: boolean = false; @@ -109,6 +110,7 @@ class Store implements IStore { this.lastStateChangeTimestamp = response.lastStateChangeTimestamp; this.lastIdleCodeChangeTimestamp = response.lastIdleCodeChangeTimestamp; this.isEndConsultEnabled = response.isEndConsultEnabled; + this.isAddressBookEnabled = Boolean(response.addressBookId); this.allowConsultToQueue = response.allowConsultToQueue; this.agentProfile.agentName = response.agentName; }) diff --git a/packages/contact-center/store/src/store.types.ts b/packages/contact-center/store/src/store.types.ts index 6a4d7409a..56ab781b7 100644 --- a/packages/contact-center/store/src/store.types.ts +++ b/packages/contact-center/store/src/store.types.ts @@ -127,6 +127,7 @@ interface IStore { allowConsultToQueue: boolean; agentProfile: AgentLoginProfile; isMuted: boolean; + isAddressBookEnabled: boolean; init(params: InitParams, callback: (ccSDK: IContactCenter) => void): Promise; registerCC(webex?: WithWebex['webex']): Promise; } diff --git a/packages/contact-center/store/src/storeEventsWrapper.ts b/packages/contact-center/store/src/storeEventsWrapper.ts index 41418f67d..bc661d9fd 100644 --- a/packages/contact-center/store/src/storeEventsWrapper.ts +++ b/packages/contact-center/store/src/storeEventsWrapper.ts @@ -167,6 +167,10 @@ class StoreWrapper implements IStoreWrapper { return this.store.isMuted; } + get isAddressBookEnabled() { + return this.store.isAddressBookEnabled; + } + setIsMuted = (value: boolean): void => { runInAction(() => { this.store.isMuted = value; @@ -718,6 +722,9 @@ class StoreWrapper implements IStoreWrapper { getAddressBookEntries = async (params?: AddressBookEntrySearchParams): Promise => { try { + if (!this.store.isAddressBookEnabled) { + return {data: [], meta: {page: 0, totalPages: 0}}; + } const response: AddressBookEntriesResponse = await this.store.cc.addressBook.getEntries(params ?? {}); return response; } catch (error) { diff --git a/packages/contact-center/store/tests/storeEventsWrapper.ts b/packages/contact-center/store/tests/storeEventsWrapper.ts index a5c328a44..8f8e913ce 100644 --- a/packages/contact-center/store/tests/storeEventsWrapper.ts +++ b/packages/contact-center/store/tests/storeEventsWrapper.ts @@ -871,6 +871,7 @@ describe('storeEventsWrapper', () => { }); it('should fetch address book entries successfully', async () => { + storeWrapper['store'].isAddressBookEnabled = true; jest.spyOn(storeWrapper['store'].cc.addressBook, 'getEntries').mockResolvedValue(mockAddressBookEntriesResponse); const result = await storeWrapper.getAddressBookEntries({page: 0, pageSize: 25}); @@ -879,9 +880,18 @@ describe('storeEventsWrapper', () => { }); it('should handle error while fetching address book entries', async () => { + storeWrapper['store'].isAddressBookEnabled = true; jest.spyOn(storeWrapper['store'].cc.addressBook, 'getEntries').mockRejectedValue(new Error('ab error')); await expect(storeWrapper.getAddressBookEntries({page: 0, pageSize: 25})).rejects.toThrow('ab error'); }); + + it('should return empty list and not call API when address book is disabled', async () => { + storeWrapper['store'].isAddressBookEnabled = false; + const getEntriesSpy = jest.spyOn(storeWrapper['store'].cc.addressBook, 'getEntries'); + const result = await storeWrapper.getAddressBookEntries({page: 0, pageSize: 25}); + expect(result).toEqual({data: [], meta: {page: 0, totalPages: 0}}); + expect(getEntriesSpy).not.toHaveBeenCalled(); + }); }); describe('storeEventsWrapper events reactions', () => { From 1f40ad8924936004c9a6afc68ccc5a88544394c8 Mon Sep 17 00:00:00 2001 From: adhmenon Date: Fri, 31 Oct 2025 16:24:03 +0530 Subject: [PATCH 2/4] fix(widgets): claned-pr-title --- .../CallControl/CallControlCustom/call-control-custom.utils.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/contact-center/cc-components/src/components/task/CallControl/CallControlCustom/call-control-custom.utils.ts b/packages/contact-center/cc-components/src/components/task/CallControl/CallControlCustom/call-control-custom.utils.ts index 671313bd0..bea2d5fdc 100644 --- a/packages/contact-center/cc-components/src/components/task/CallControl/CallControlCustom/call-control-custom.utils.ts +++ b/packages/contact-center/cc-components/src/components/task/CallControl/CallControlCustom/call-control-custom.utils.ts @@ -628,7 +628,7 @@ export const filterAgentsByQuery = (agents: BuddyDetails[], query: string): Budd }; /** - * Returns agents to display for current category, applying search only for Agents tab. + * Returns agents to display for current category, applying search only for Agents tab, since other tabs support via the SDK */ export const getAgentsForDisplay = ( selectedCategory: 'Agents' | string, From af35d6b5ab2b04a0261130e6bbfa58465064466e Mon Sep 17 00:00:00 2001 From: adhmenon Date: Fri, 31 Oct 2025 17:36:18 +0530 Subject: [PATCH 3/4] fix(widgets): resolved-comments --- .../call-control-custom.utils.ts | 2 +- .../consult-transfer-popover.tsx | 35 ++++++++++--------- .../src/components/task/constants.ts | 1 + packages/contact-center/store/src/store.ts | 1 + 4 files changed, 21 insertions(+), 18 deletions(-) diff --git a/packages/contact-center/cc-components/src/components/task/CallControl/CallControlCustom/call-control-custom.utils.ts b/packages/contact-center/cc-components/src/components/task/CallControl/CallControlCustom/call-control-custom.utils.ts index bea2d5fdc..1cc6a94aa 100644 --- a/packages/contact-center/cc-components/src/components/task/CallControl/CallControlCustom/call-control-custom.utils.ts +++ b/packages/contact-center/cc-components/src/components/task/CallControl/CallControlCustom/call-control-custom.utils.ts @@ -683,7 +683,7 @@ export const debounce = unknown>( /** * Helpers for Dial Number / Entry Point manual actions */ -export const buildConsultTransferQuickAction = ( +export const shouldAddConsultTransferAction = ( selectedCategory: string, isEntryPointTabVisible: boolean, query: string, diff --git a/packages/contact-center/cc-components/src/components/task/CallControl/CallControlCustom/consult-transfer-popover.tsx b/packages/contact-center/cc-components/src/components/task/CallControl/CallControlCustom/consult-transfer-popover.tsx index ae5613166..dd43968cf 100644 --- a/packages/contact-center/cc-components/src/components/task/CallControl/CallControlCustom/consult-transfer-popover.tsx +++ b/packages/contact-center/cc-components/src/components/task/CallControl/CallControlCustom/consult-transfer-popover.tsx @@ -7,7 +7,7 @@ import ConsultTransferEmptyState from './consult-transfer-empty-state'; import { handleAgentSelection, handleQueueSelection, - buildConsultTransferQuickAction, + shouldAddConsultTransferAction, getAgentsForDisplay, } from './call-control-custom.utils'; import {useConsultTransferPopover} from './consult-transfer-popover-hooks'; @@ -20,6 +20,7 @@ import { LOADING_MORE_ENTRY_POINTS, NO_DATA_AVAILABLE_CONSULT_TRANSFER, } from '../../constants'; +import {CATEGORY_AGENTS, CATEGORY_DIAL_NUMBER, CATEGORY_ENTRY_POINT, CATEGORY_QUEUES} from '../../task.types'; const ConsultTransferPopoverComponent: React.FC = ({ heading, @@ -37,7 +38,7 @@ const ConsultTransferPopoverComponent: React.FC { const {showDialNumberTab = true, showEntryPointTab = true} = consultTransferOptions || {}; - const isEntryPointTabVisible = (showEntryPointTab ?? true) && heading === 'Consult'; + const isEntryPointTabVisible = showEntryPointTab && heading === 'Consult'; const { selectedCategory, searchQuery, @@ -93,7 +94,7 @@ const ConsultTransferPopoverComponent: React.FC {allowConsultToQueue && ( )} {showDialNumberTab && ( )} {isEntryPointTabVisible && ( )}
                        @@ -232,7 +233,7 @@ const ConsultTransferPopoverComponent: React.FC ) : ( @@ -264,7 +265,7 @@ const ConsultTransferPopoverComponent: React.FC ) : ( diff --git a/packages/contact-center/cc-components/src/components/task/constants.ts b/packages/contact-center/cc-components/src/components/task/constants.ts index ff01108b1..633dbff01 100644 --- a/packages/contact-center/cc-components/src/components/task/constants.ts +++ b/packages/contact-center/cc-components/src/components/task/constants.ts @@ -26,6 +26,7 @@ export const LOADING_MORE_QUEUES = 'Loading more queues...'; export const LOADING_MORE_DIAL_NUMBERS = 'Loading more dial numbers...'; export const LOADING_MORE_ENTRY_POINTS = 'Loading more entry points...'; export const NO_DATA_AVAILABLE_CONSULT_TRANSFER = 'No data available for consult transfer.'; +export const VIA_SEARCH_SUFFIX = ' via search'; // Pagination export const DEFAULT_PAGE_SIZE = 25; // CallControlCAD constants diff --git a/packages/contact-center/store/src/store.ts b/packages/contact-center/store/src/store.ts index e22b63d1f..af58008de 100644 --- a/packages/contact-center/store/src/store.ts +++ b/packages/contact-center/store/src/store.ts @@ -110,6 +110,7 @@ class Store implements IStore { this.lastStateChangeTimestamp = response.lastStateChangeTimestamp; this.lastIdleCodeChangeTimestamp = response.lastIdleCodeChangeTimestamp; this.isEndConsultEnabled = response.isEndConsultEnabled; + // TODO: Remove this once SDK performs the validation this.isAddressBookEnabled = Boolean(response.addressBookId); this.allowConsultToQueue = response.allowConsultToQueue; this.agentProfile.agentName = response.agentName; From 2ce77aeee4f93f7571f8247355694be9e5727517 Mon Sep 17 00:00:00 2001 From: adhmenon Date: Fri, 31 Oct 2025 18:38:17 +0530 Subject: [PATCH 4/4] fix(widgets): removed-unknowns --- .../call-control-custom.utils.ts | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/packages/contact-center/cc-components/src/components/task/CallControl/CallControlCustom/call-control-custom.utils.ts b/packages/contact-center/cc-components/src/components/task/CallControl/CallControlCustom/call-control-custom.utils.ts index 1cc6a94aa..3c0edccbf 100644 --- a/packages/contact-center/cc-components/src/components/task/CallControl/CallControlCustom/call-control-custom.utils.ts +++ b/packages/contact-center/cc-components/src/components/task/CallControl/CallControlCustom/call-control-custom.utils.ts @@ -616,15 +616,13 @@ export const filterAvailableAgents = (agents: BuddyDetails[], logger?): BuddyDet * Filters buddy agents by a free-text query across name, dn and id. */ export const filterAgentsByQuery = (agents: BuddyDetails[], query: string): BuddyDetails[] => { - const q = (query || '').trim().toLowerCase(); - if (!q) return agents || []; - const safeAgents = agents || []; - return safeAgents.filter((a) => { - const name = a.agentName?.toLowerCase() || ''; - const dn = (a as unknown as {dn?: string})?.dn?.toLowerCase() || ''; - const id = a.agentId?.toLowerCase() || ''; - return name.includes(q) || dn.includes(q) || id.includes(q); - }); + const searchTerm = (query ?? '').trim().toLowerCase(); + if (!searchTerm) return agents ?? []; + return (agents ?? []).filter((agent) => + `${agent.agentName ?? ''}|${(agent as {dn?: string}).dn ?? ''}|${agent.agentId ?? ''}` + .toLowerCase() + .includes(searchTerm) + ); }; /**