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);