• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

ringcentral / ringcentral-js-widgets / 9984535799

18 Jul 2024 02:28AM UTC coverage: 63.055% (+1.7%) from 61.322%
9984535799

push

github

web-flow
misc: sync features and bugfixes from f39b7a45 (#1747)

* misc: sync features and bugfixes from ba8d789

* misc: add i18n-dayjs and react-hooks packages

* version to 0.15.0

* chore: update crius

* misc: sync from f39b7a45

* chore: fix tests

* chore: fix tests

* chore: run test with --updateSnapshot

9782 of 17002 branches covered (57.53%)

Branch coverage included in aggregate %.

2206 of 3368 new or added lines in 501 files covered. (65.5%)

219 existing lines in 52 files now uncovered.

16601 of 24839 relevant lines covered (66.83%)

178566.16 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

6.25
/packages/ringcentral-widgets/components/SimpleCallControlPanel/SimpleCallControlPanel.tsx
1
import { formatNumber } from '@ringcentral-integration/commons/lib/formatNumber';
2
import type { FunctionComponent } from 'react';
3
import React, { useCallback, useEffect, useRef, useState } from 'react';
4

5
import callCtrlLayouts from '../../enums/callCtrlLayouts';
6
import { ACTIONS_CTRL_MAP } from '../ActiveCallPad';
7
import CallCtrlPanel from '../CallCtrlPanel';
8

9
import type { SimpleCallControlPanelProps } from './SimpleCallControlPanel.interface';
10
import i18n from './i18n';
11

12
const SimpleCallControlPanel: FunctionComponent<
13
  SimpleCallControlPanelProps
14
> = ({
201✔
15
  activeSession,
16
  areaCode,
17
  countryCode,
18
  nameMatches,
19
  sessionId,
20
  currentLocale,
21
  fallBackName,
22
  phoneNumber,
23
  actions,
24
  showContactDisplayPlaceholder,
25
  controlBusy,
26
  brandName,
27
  onBackButtonClick,
28
  setActiveSessionId,
29
  onMute,
30
  onUnmute,
31
  onHold,
32
  onUnhold,
33
  onHangup,
34
  onTransfer,
35
  maxExtensionNumberLength = 6,
×
36
}) => {
NEW
37
  const [selectedMatcherIndex, setSelectedMatcherIndex] = useState(0);
×
NEW
38
  const formatPhone = useCallback(
×
39
    (phoneNumber) =>
NEW
40
      formatNumber({
×
41
        phoneNumber,
42
        areaCode,
43
        countryCode,
44
        maxExtensionLength: maxExtensionNumberLength,
45
      }),
46
    [areaCode, countryCode],
47
  );
NEW
48
  const onSelectMatcherName = useCallback(
×
49
    (option) => {
NEW
50
      let selectedMatcherIndex = (nameMatches ?? []).findIndex(
×
NEW
51
        (match) => match.id === option.id,
×
52
      );
NEW
53
      if (selectedMatcherIndex < 0) {
×
NEW
54
        selectedMatcherIndex = 0;
×
55
      }
NEW
56
      setSelectedMatcherIndex(selectedMatcherIndex);
×
57
    },
58
    [nameMatches],
59
  );
NEW
60
  const renderTime = useRef(0);
×
NEW
61
  useEffect(() => {
×
NEW
62
    if (renderTime.current > 0 && !activeSession) {
×
NEW
63
      onBackButtonClick();
×
64
    }
NEW
65
    renderTime.current += 1;
×
66
  });
NEW
67
  useEffect(() => {
×
NEW
68
    setActiveSessionId?.(sessionId);
×
69
  }, []);
NEW
70
  if (!activeSession) {
×
71
    // or using skeleton screen here
NEW
72
    return null;
×
73
  }
NEW
74
  return (
×
75
    <CallCtrlPanel
76
      sessionId={sessionId}
77
      currentLocale={currentLocale}
78
      fallBackName={fallBackName}
79
      phoneNumber={phoneNumber}
80
      onMute={onMute}
81
      onUnmute={onUnmute}
82
      onHold={onHold}
83
      onUnhold={onUnhold}
84
      onHangup={onHangup}
85
      onTransfer={onTransfer}
86
      showBackButton
87
      backButtonLabel={i18n.getString('allCalls', currentLocale)}
88
      onBackButtonClick={onBackButtonClick}
89
      formatPhone={formatPhone}
90
      areaCode={areaCode}
91
      countryCode={countryCode}
92
      selectedMatcherIndex={selectedMatcherIndex}
93
      layout={callCtrlLayouts.normalCtrl}
94
      startTime={activeSession.startTime}
95
      actions={actions}
96
      isOnMute={activeSession.isOnMute}
97
      isOnHold={activeSession.isOnHold}
98
      nameMatches={nameMatches}
99
      onSelectMatcherName={onSelectMatcherName}
100
      brand={brandName}
101
      showContactDisplayPlaceholder={showContactDisplayPlaceholder}
102
      controlBusy={controlBusy}
103
    />
104
  );
105
};
106

107
SimpleCallControlPanel.defaultProps = {
201✔
108
  setActiveSessionId() {},
109
  currentLocale: 'en-US',
110
  activeSession: null,
111
  // @ts-expect-error TS(2322): Type 'null' is not assignable to type 'string | un... Remove this comment to see the full error message
112
  sessionId: null,
113
  nameMatches: [],
114
  fallBackName: '',
115
  phoneNumber: '',
116
  showContactDisplayPlaceholder: false,
117
  controlBusy: false,
118
  actions: [
119
    ACTIONS_CTRL_MAP.muteCtrl,
120
    ACTIONS_CTRL_MAP.transferCtrl,
121
    ACTIONS_CTRL_MAP.holdCtrl,
122
  ],
123
};
124

125
export { SimpleCallControlPanel };
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc