import React from 'react'; import { CallScreen, PropsType as CallScreenPropsType } from './CallScreen'; import { IncomingCallBar, PropsType as IncomingCallBarPropsType, } from './IncomingCallBar'; import { CallState } from '../types/Calling'; import { CallDetailsType } from '../state/ducks/calling'; type CallManagerPropsType = { callDetails?: CallDetailsType; callState?: CallState; }; type PropsType = IncomingCallBarPropsType & CallScreenPropsType & CallManagerPropsType; export const CallManager = ({ acceptCall, callDetails, callState, declineCall, getVideoCapturer, getVideoRenderer, hangUp, hasLocalAudio, hasLocalVideo, hasRemoteVideo, i18n, setLocalAudio, setLocalVideo, setVideoCapturer, setVideoRenderer, }: PropsType): JSX.Element | null => { if (!callDetails || !callState) { return null; } const incoming = callDetails.isIncoming; const outgoing = !incoming; const ongoing = callState === CallState.Accepted || callState === CallState.Reconnecting; const ringing = callState === CallState.Ringing; if (outgoing || ongoing) { return ( ); } if (incoming && ringing) { return ( ); } // Ended || (Incoming && Prering) return null; };