import clsx from 'clsx'; import React, { useEffect } from 'react'; import type { Call } from '../ActiveCallItemV2'; import ActiveCallList from '../ActiveCallList'; import InsideModal from '../InsideModal'; import LogNotification from '../LogNotification'; import LogSection from '../LogSection'; import { SpinnerOverlay } from '../SpinnerOverlay'; import i18n from './i18n'; import styles from './styles.scss'; type ActiveCallsPanelProps = { currentLocale: string; className?: string; activeRingCalls: any[]; activeOnHoldCalls: any[]; activeCurrentCalls: any[]; otherDeviceCalls: any[]; areaCode: string; countryCode: string; brand?: string; showContactDisplayPlaceholder?: boolean; formatPhone: (...args: any[]) => any; onClickToSms?: (...args: any[]) => any; onCreateContact?: (...args: any[]) => any; outboundSmsPermission?: boolean; internalSmsPermission?: boolean; isLoggedContact?: (...args: any[]) => any; onLogCall?: (...args: any[]) => any; onMergeCall?: (webphoneSessionId: string, telephonySessionId: string) => any; webphoneAnswer?: (...args: any[]) => any; webphoneReject?: (...args: any[]) => any; webphoneHangup?: (...args: any[]) => any; webphoneResume?: (...args: any[]) => any; webphoneToVoicemail?: (...args: any[]) => any; webphoneSwitchCall?: (...args: any[]) => any; webphoneIgnore?: (...args: any[]) => any; modalConfirm?: (...args: any[]) => any; modalClose?: (...args: any[]) => any; autoLog?: boolean; onViewContact?: (...args: any[]) => any; enableContactFallback?: boolean; loggingMap?: object; onCallsEmpty?: (...args: any[]) => any; sourceIcons?: object; phoneTypeRenderer?: (...args: any[]) => any; phoneSourceNameRenderer?: (...args: any[]) => any; isWebRTC: boolean; showSpinner?: boolean; isSessionAConferenceCall?: (...args: any[]) => any; onCallItemClick?: (...args: any[]) => any; getAvatarUrl?: (...args: any[]) => any; conferenceCallParties?: object[]; webphoneHold?: (...args: any[]) => any; useV2?: boolean; updateSessionMatchedContact?: (...args: any[]) => any; isOnHold: (...args: any[]) => any; currentLog?: any; renderEditLogSection?: (...args: any[]) => any; renderSaveLogButton?: (...args: any[]) => any; renderExtraButton?: (...args: any[]) => any; onSaveCallLog?: (...args: any[]) => any; onUpdateCallLog?: (...args: any[]) => any; onCloseLogSection?: (...args: any[]) => any; logNotification?: any; onCloseNotification?: (...args: any[]) => any; onDiscardNotification?: (...args: any[]) => any; onSaveNotification?: (...args: any[]) => any; onExpandNotification?: (...args: any[]) => any; showNotiLogButton?: boolean; notificationContainerStyles?: string; showAvatar?: boolean; renderContactName?: (...args: any[]) => any; renderSubContactName?: (...args: any[]) => any; showOtherDevice?: boolean; ringoutHangup?: (...args: any[]) => any; ringoutTransfer?: (...args: any[]) => any; ringoutReject?: (...args: any[]) => any; disableLinks?: boolean; showRingoutCallControl?: boolean; showMultipleMatch?: boolean; showSwitchCall?: boolean; showTransferCall?: boolean; showHoldOnOtherDevice?: boolean; onLogBasicInfoClick?: (...args: any[]) => any; renderSmallCallContrl?: (...args: any[]) => any; showCallDetail?: boolean; showIgnoreBtn?: boolean; showHoldAnswerBtn?: boolean; useCallDetailV2?: boolean; newCallIcon?: boolean; clickSwitchTrack?: (...args: any[]) => any; onSwitchCall?: (call: Call) => any; isWide?: boolean; allCalls: any[]; showMergeCall?: boolean; showCallerIdName?: boolean; }; export const ActiveCallsPanel: React.FC = ({ activeRingCalls, activeOnHoldCalls, activeCurrentCalls, otherDeviceCalls, className, currentLocale, areaCode, countryCode, showMergeCall, showCallDetail, showCallerIdName, allCalls, onCreateContact, onClickToSms, isLoggedContact, onLogCall, onViewContact, webphoneAnswer, onMergeCall, webphoneReject, webphoneHangup, webphoneResume, webphoneToVoicemail, webphoneSwitchCall, webphoneIgnore, modalConfirm, modalClose, enableContactFallback, onCallsEmpty, sourceIcons, phoneTypeRenderer, phoneSourceNameRenderer, isWebRTC, getAvatarUrl, currentLog, renderEditLogSection, renderSaveLogButton, renderExtraButton, onSaveCallLog, onUpdateCallLog, onCloseLogSection, logNotification, onCloseNotification, onDiscardNotification, onSaveNotification, onExpandNotification, notificationContainerStyles, renderContactName, renderSubContactName, ringoutHangup, ringoutTransfer, ringoutReject, isOnHold, isWide = true, brand = 'RingCentral', showContactDisplayPlaceholder = true, outboundSmsPermission = true, internalSmsPermission = true, loggingMap = {}, autoLog = false, showSpinner = false, isSessionAConferenceCall = () => false, onCallItemClick, conferenceCallParties = [], webphoneHold = (i: any) => i, useV2 = false, updateSessionMatchedContact = (i: any) => i, showNotiLogButton = true, showAvatar = true, showOtherDevice = true, disableLinks = false, showRingoutCallControl = false, showMultipleMatch = true, showSwitchCall = false, showTransferCall = true, showHoldOnOtherDevice = false, onLogBasicInfoClick = () => { // }, renderSmallCallContrl = () => { // }, showIgnoreBtn = false, showHoldAnswerBtn = false, useCallDetailV2 = false, newCallIcon = false, clickSwitchTrack = () => { // }, onSwitchCall, formatPhone, }) => { const hasCalls = activeRingCalls.length > 0 || activeOnHoldCalls.length > 0 || activeCurrentCalls.length > 0 || otherDeviceCalls.length > 0; useEffect(() => { if (!hasCalls) { onCallsEmpty?.(); } // eslint-disable-next-line react-hooks/exhaustive-deps }, [hasCalls]); const renderLogSection = () => { if (!currentLog) return null; return (
{logNotification ? ( ) : null}
); }; const getCallList = ( calls: any, title: any, showCallDetail = false, allCalls: any, showMergeCallBtn?: boolean, ) => { return ( ); }; if (!hasCalls) { return (

{i18n.getString('noActiveCalls', currentLocale)}

{renderLogSection()} {showSpinner ? : null}
); } return (
{getCallList( activeRingCalls, i18n.getString('ringCall', currentLocale), showCallDetail, allCalls, )} {getCallList( activeCurrentCalls, i18n.getString('currentCall', currentLocale), showCallDetail, allCalls, )} {getCallList( activeOnHoldCalls, i18n.getString('onHoldCall', currentLocale), showCallDetail, allCalls, true, )} {showOtherDevice ? getCallList( otherDeviceCalls, i18n.getString('otherDeviceCall', currentLocale), true, allCalls, ) : null}
{renderLogSection()} {showSpinner ? : null}
); }; export default ActiveCallsPanel;