@@ -43,22 +43,35 @@ function isTelephonySupported(deviceType: string, webRtcEnabled: boolean): boole
4343}
4444
4545/**
46- * Check if consulting with an EP_DN agent (matches Agent Desktop's isEPorEPDN)
46+ * Check if consulting with an EP_DN agent (Entry Point Dial Number)
47+ * This function looks for EP-DN participants in the consult media
4748 */
4849function isConsultingWithEpDnAgent ( task : ITask ) : boolean {
49- if ( ! task ?. data ?. interaction ) {
50+ if ( ! task ?. data ?. interaction ?. media || ! task ?. data ?. interaction ?. participants ) {
5051 return false ;
5152 }
5253
53- // eslint-disable-next-line @typescript-eslint/no-explicit-any
54- const destAgentType = ( task . data . interaction as any ) . destAgentType ;
54+ // Find the consult media
55+ const consultMedia = Object . values ( task . data . interaction . media ) . find ( ( media ) => media . mType === 'consult' ) ;
5556
56- return (
57- destAgentType === DestinationAgentType . EP_DN ||
58- destAgentType === DestinationAgentType . EPDN ||
59- destAgentType === DestinationAgentType . ENTRY_POINT ||
60- destAgentType === DestinationAgentType . EP
61- ) ;
57+ if ( ! consultMedia || ! consultMedia . participants ) {
58+ return false ;
59+ }
60+
61+ // Check if any participant in the consult media is an EP-DN
62+ const participants = task . data . interaction . participants ;
63+ return consultMedia . participants . some ( ( participantId : string ) => {
64+ const participant = participants [ participantId ] ;
65+ if ( ! participant ) return false ;
66+
67+ // Check for EP-DN participant types using the type field
68+ return (
69+ participant . type === DestinationAgentType . EP_DN ||
70+ participant . type === DestinationAgentType . EPDN ||
71+ participant . type === DestinationAgentType . ENTRY_POINT ||
72+ participant . type === DestinationAgentType . EP
73+ ) ;
74+ } ) ;
6275}
6376
6477export function findHoldTimestamp ( interaction : Interaction , mType = 'mainCall' ) : number | null {
@@ -114,22 +127,15 @@ export function getEndButtonVisibility(
114127 const isVisible = isBrowser || ( isEndCallEnabled && isCall ) || ! isCall ;
115128 const isEpDnConsult = task && agentId ? isConsultingWithEpDnAgent ( task ) : false ;
116129
117- // EP_DN consult: End button enabled unless main call is held
118- if ( isEpDnConsult && isConsultInitiatedOrAcceptedOrBeingConsulted ) {
119- const isEnabled = ! isHeld || ( isConferenceInProgress && ! isConsultCompleted ) ;
130+ if ( isConsultInitiatedOrAcceptedOrBeingConsulted ) {
131+ let isEnabled = false ;
132+ if ( isEpDnConsult ) {
133+ // EP-DN consult: enabled when on main call OR during conference when main not held
134+ isEnabled = consultCallHeld || ( ! isHeld && isConferenceInProgress && ! isConsultCompleted ) ;
135+ }
120136 return { isVisible, isEnabled} ;
121137 }
122138
123- // Agent-to-agent consult during conference: End button enabled when switched back to main call
124- if ( isConsultInitiatedOrAcceptedOrBeingConsulted && isConferenceInProgress ) {
125- return { isVisible, isEnabled : consultCallHeld } ;
126- }
127-
128- // Regular consult without conference: End button enabled only when on main call
129- if ( isConsultInitiatedOrAcceptedOrBeingConsulted && ! isConferenceInProgress ) {
130- return { isVisible, isEnabled : consultCallHeld } ;
131- }
132-
133139 // Default logic for other states
134140 const isEnabled =
135141 ( ! isHeld || ( isConferenceInProgress && ! isConsultCompleted ) ) &&
0 commit comments