mirror of
https://dev.azure.com/globalhealthx/EMR/_git/helix-engage
synced 2026-04-11 18:28:15 +00:00
- Single dialOutbound() in sip-provider handles all outbound state: callState, callerNumber, outboundPending, API call, error recovery - ClickToCallButton, PhoneActionCell, Dialler all use dialOutbound() - Removed direct Jotai atom manipulation from calling components - Removed setOutboundPending imports from components - SIP disconnects on provider unmount + auth logout - Dialler input is now editable (type or numpad) Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
46 lines
1.4 KiB
TypeScript
46 lines
1.4 KiB
TypeScript
import type { FC } from 'react';
|
|
import { useState } from 'react';
|
|
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
|
|
import { faPhone } from '@fortawesome/pro-duotone-svg-icons';
|
|
|
|
const Phone01: FC<{ className?: string } & Record<string, any>> = ({ className, ...rest }) => <FontAwesomeIcon icon={faPhone} className={className} {...rest} />;
|
|
import { Button } from '@/components/base/buttons/button';
|
|
import { useSip } from '@/providers/sip-provider';
|
|
import { notify } from '@/lib/toast';
|
|
|
|
interface ClickToCallButtonProps {
|
|
phoneNumber: string;
|
|
leadId?: string;
|
|
label?: string;
|
|
size?: 'sm' | 'md';
|
|
}
|
|
|
|
export const ClickToCallButton = ({ phoneNumber, label, size = 'sm' }: ClickToCallButtonProps) => {
|
|
const { isRegistered, isInCall, dialOutbound } = useSip();
|
|
const [dialing, setDialing] = useState(false);
|
|
|
|
const handleDial = async () => {
|
|
setDialing(true);
|
|
try {
|
|
await dialOutbound(phoneNumber);
|
|
} catch {
|
|
notify.error('Dial Failed', 'Could not place the call');
|
|
} finally {
|
|
setDialing(false);
|
|
}
|
|
};
|
|
|
|
return (
|
|
<Button
|
|
size={size}
|
|
color="primary"
|
|
iconLeading={Phone01}
|
|
onClick={handleDial}
|
|
isDisabled={!isRegistered || isInCall || !phoneNumber || dialing}
|
|
isLoading={dialing}
|
|
>
|
|
{label ?? 'Call'}
|
|
</Button>
|
|
);
|
|
};
|