From e7c5c13e83f737afb07872b4c37c47f7869e569c Mon Sep 17 00:00:00 2001 From: saridsa2 Date: Fri, 20 Mar 2026 06:52:24 +0530 Subject: [PATCH] feat: switch outbound to direct SIP call from browser MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Instead of Kookoo outbound → IVR → dial back to SIP (broken bridge), make the call directly from JsSIP in the browser. The SIP INVITE goes through Ozonetel's SIP server to the PSTN. No intermediary needed. Co-Authored-By: Claude Opus 4.6 (1M context) --- src/components/call-desk/click-to-call-button.tsx | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/src/components/call-desk/click-to-call-button.tsx b/src/components/call-desk/click-to-call-button.tsx index 7be395f..6a95c92 100644 --- a/src/components/call-desk/click-to-call-button.tsx +++ b/src/components/call-desk/click-to-call-button.tsx @@ -4,8 +4,6 @@ import { useSetAtom } from 'jotai'; import { Button } from '@/components/base/buttons/button'; import { useSip } from '@/providers/sip-provider'; import { sipCallStateAtom, sipCallerNumberAtom } from '@/state/sip-state'; -import { setOutboundPending } from '@/state/sip-manager'; -import { apiClient } from '@/lib/api-client'; import { notify } from '@/lib/toast'; interface ClickToCallButtonProps { @@ -15,8 +13,8 @@ interface ClickToCallButtonProps { size?: 'sm' | 'md'; } -export const ClickToCallButton = ({ phoneNumber, leadId, label, size = 'sm' }: ClickToCallButtonProps) => { - const { isRegistered, isInCall } = useSip(); +export const ClickToCallButton = ({ phoneNumber, label, size = 'sm' }: ClickToCallButtonProps) => { + const { isRegistered, isInCall, makeCall } = useSip(); const [dialing, setDialing] = useState(false); const setCallState = useSetAtom(sipCallStateAtom); const setCallerNumber = useSetAtom(sipCallerNumberAtom); @@ -24,18 +22,16 @@ export const ClickToCallButton = ({ phoneNumber, leadId, label, size = 'sm' }: C const handleDial = async () => { setDialing(true); - // Immediately show the call UI and mark outbound pending for auto-answer + // Show call UI immediately setCallState('ringing-out'); setCallerNumber(phoneNumber); - setOutboundPending(true); try { - await apiClient.post('/api/ozonetel/dial', { phoneNumber, leadId }); + // Direct SIP call from browser + makeCall(phoneNumber); } catch { - // API error — reset call state setCallState('idle'); setCallerNumber(null); - setOutboundPending(false); notify.error('Dial Failed', 'Could not place the call'); } finally { setDialing(false);