From a306311f08a0db0b587951996c3c938f833087cf Mon Sep 17 00:00:00 2001 From: saridsa2 Date: Mon, 20 Apr 2026 11:41:04 +0530 Subject: [PATCH] fix: disable Book Appt/Enquiry until customer answers outbound call (#568) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit For outbound calls, SIP state transitions to 'active' when the agent's bridge connects — before the customer picks up. Ozonetel state stays 'calling' until customer answers, then goes to 'in-call'. Now reads ozonetelState from useAgentState and computes customerAnswered (callState=active AND ozonetelState!=calling). Action buttons (Book Appt, Enquiry, Transfer) disabled until customerAnswered is true. Co-Authored-By: Claude Opus 4.6 (1M context) --- src/components/call-desk/active-call-card.tsx | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/src/components/call-desk/active-call-card.tsx b/src/components/call-desk/active-call-card.tsx index 145c7fb..b0f0a31 100644 --- a/src/components/call-desk/active-call-card.tsx +++ b/src/components/call-desk/active-call-card.tsx @@ -105,7 +105,11 @@ export const ActiveCallCard = ({ lead, callerPhone, missedCallId, onCallComplete const agentConfig = localStorage.getItem('helix_agent_config'); const agentIdForState = agentConfig ? (() => { try { return JSON.parse(agentConfig).ozonetelAgentId; } catch { return null; } })() : null; - const { supervisorPresence } = useAgentState(agentIdForState); + const { state: ozonetelState, supervisorPresence } = useAgentState(agentIdForState); + // For outbound calls, SIP goes 'active' when the agent's bridge connects + // (before customer answers). Ozonetel state stays 'calling' until customer + // picks up, then transitions to 'in-call'. Use this to gate action buttons. + const customerAnswered = callState === 'active' && ozonetelState !== 'calling'; const callDirectionRef = useRef(callState === 'ringing-out' ? 'OUTBOUND' : 'INBOUND'); const wasAnsweredRef = useRef(callState === 'active'); @@ -275,7 +279,7 @@ export const ActiveCallCard = ({ lead, callerPhone, missedCallId, onCallComplete // Active call if (callState === 'active' || dispositionOpen) { - wasAnsweredRef.current = true; + if (customerAnswered) wasAnsweredRef.current = true; return ( <>
@@ -357,17 +361,17 @@ export const ActiveCallCard = ({ lead, callerPhone, missedCallId, onCallComplete