forked from webex/widgets
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcall-control-cad.tsx
More file actions
233 lines (212 loc) · 7.97 KB
/
Copy pathcall-control-cad.tsx
File metadata and controls
233 lines (212 loc) · 7.97 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
import React from 'react';
import CallControlComponent from '../CallControl/call-control';
import {Text} from '@momentum-ui/react-collaboration';
import {Brandvisual, Icon, Tooltip} from '@momentum-design/components/dist/react';
import './call-control-cad.styles.scss';
import TaskTimer from '../TaskTimer/index';
import CallControlConsultComponent from '../CallControl/CallControlCustom/call-control-consult';
import {MEDIA_CHANNEL as MediaChannelType, CallControlComponentProps} from '../task.types';
import {getMediaTypeInfo} from '../../../utils';
import {
NO_CUSTOMER_NAME,
NO_CALLER_ID,
NO_PHONE_NUMBER,
NO_TEAM_NAME,
NO_RONA,
ON_HOLD,
QUEUE,
PHONE_NUMBER,
CUSTOMER_NAME,
RONA,
} from '../constants';
const CallControlCADComponent: React.FC<CallControlComponentProps> = (props) => {
const {
currentTask,
isHeld,
isRecording,
holdTime,
consultAccepted,
consultInitiated,
consultAgentName,
consultStartTimeStamp,
endConsultCall,
consultAgentId,
consultCompleted,
consultTransfer,
callControlClassName,
callControlConsultClassName,
startTimestamp,
isEndConsultEnabled,
lastTargetType,
controlVisibility,
logger,
} = props;
const formatTime = (time: number): string => {
const minutes = Math.floor((time % 3600) / 60);
const seconds = time % 60;
return `${minutes.toString().padStart(2, '0')}:${seconds.toString().padStart(2, '0')}`;
};
const currentMediaType = getMediaTypeInfo(
currentTask.data.interaction.mediaType as MediaChannelType,
currentTask.data.interaction.mediaChannel as MediaChannelType
);
const mediaChannel = currentTask.data.interaction.mediaType as MediaChannelType;
const isSocial = mediaChannel === MediaChannelType.SOCIAL;
const isTelephony = mediaChannel === MediaChannelType.TELEPHONY;
//@ts-expect-error To be fixed in SDK - https://jira-eng-sjc12.cisco.com/jira/browse/CAI-6762
const customerName = currentTask?.data?.interaction?.callAssociatedDetails?.customerName;
//@ts-expect-error To be fixed in SDK - https://jira-eng-sjc12.cisco.com/jira/browse/CAI-6762
const ani = currentTask?.data?.interaction?.callAssociatedDetails?.ani;
// Create unique IDs for tooltips
const customerNameTriggerId = `customer-name-trigger-${currentTask.data.interaction.interactionId}`;
const customerNameTooltipId = `customer-name-tooltip-${currentTask.data.interaction.interactionId}`;
const phoneNumberTriggerId = `phone-number-trigger-${currentTask.data.interaction.interactionId}`;
const phoneNumberTooltipId = `phone-number-tooltip-${currentTask.data.interaction.interactionId}`;
const renderCustomerName = () => {
const customerText = isSocial ? customerName || NO_CUSTOMER_NAME : ani || NO_CALLER_ID;
const textComponent = (
<Text
className={!isTelephony ? 'digital-customer-name' : 'voice-customer-name'}
type="body-large-bold"
tagName={'p'}
id={!isTelephony ? customerNameTriggerId : undefined}
>
{customerText}
</Text>
);
if (!isTelephony) {
return (
<>
{textComponent}
<Tooltip
color="contrast"
delay="0,0"
id={customerNameTooltipId}
placement="top-start"
offset={4}
tooltip-type="description"
triggerID={customerNameTriggerId}
className="call-control-task-tooltip"
>
<Text tagName="small">{customerText}</Text>
</Tooltip>
</>
);
}
return textComponent;
};
const renderPhoneNumber = () => {
const phoneText = isSocial ? customerName || NO_CUSTOMER_NAME : ani || NO_PHONE_NUMBER;
const labelText = isSocial ? CUSTOMER_NAME : PHONE_NUMBER;
const textComponent = (
<Text
className={!isTelephony ? 'digital-phone-number' : 'voice-phone-number'}
type="body-secondary"
tagName={'p'}
id={!isTelephony ? phoneNumberTriggerId : undefined}
>
<strong>{labelText}</strong> <span>{phoneText}</span>
</Text>
);
if (!isTelephony) {
return (
<>
{textComponent}
<Tooltip
color="contrast"
delay="0,0"
id={phoneNumberTooltipId}
placement="top-start"
offset={4}
tooltip-type="description"
triggerID={phoneNumberTriggerId}
className="call-control-task-tooltip"
>
<Text tagName="small">{phoneText}</Text>
</Tooltip>
</>
);
}
return textComponent;
};
if (!currentTask) return null;
return (
<>
<div className={`call-control-container ${callControlClassName || ''}`}>
{/* Caller Information */}
<div className="caller-info">
<div className="call-icon-background">
{currentMediaType.isBrandVisual ? (
<Brandvisual name={currentMediaType.iconName} className={`media-icon ${currentMediaType.className}`} />
) : (
<Icon name={currentMediaType.iconName} size={1} className={`media-icon ${currentMediaType.className}`} />
)}
</div>
<div className="customer-info">
{renderCustomerName()}
<div className="call-details">
<Text className="call-timer" type="body-secondary" tagName={'small'}>
{currentMediaType.labelName} - <TaskTimer startTimeStamp={startTimestamp} />
</Text>
<div className="call-status">
{!controlVisibility.wrapup && isHeld && (
<>
<span className="dot">•</span>
<div className="on-hold">
<Icon name="call-hold-filled" size={1} className="call-hold-filled-icon" />
<span className="on-hold-chip-text">
{ON_HOLD} {formatTime(holdTime)}
</span>
</div>
</>
)}
</div>
</div>
</div>
</div>
{!controlVisibility.wrapup && controlVisibility.recordingIndicator && (
<div className="recording-indicator">
<Icon name={isRecording ? 'record-active-badge-filled' : 'record-paused-badge-filled'} size={1.3} />
</div>
)}
<CallControlComponent {...props} />
<div className="cad-variables">
<Text className="queue" type="body-secondary" tagName={'small'}>
<strong>{QUEUE}</strong>{' '}
<span>
{
//@ts-expect-error To be fixed in SDK - https://jira-eng-sjc12.cisco.com/jira/browse/CAI-6762
currentTask?.data?.interaction?.callAssociatedDetails?.virtualTeamName || NO_TEAM_NAME
}
</span>
</Text>
{renderPhoneNumber()}
<Text className="rona" type="body-secondary" tagName={'small'}>
<strong>{RONA}</strong>{' '}
<span>
{
//@ts-expect-error To be fixed in SDK - https://jira-eng-sjc12.cisco.com/jira/browse/CAI-6762
currentTask?.data?.interaction?.callAssociatedDetails?.ronaTimeout || NO_RONA
}
</span>
</Text>
</div>
</div>
{(consultAccepted || consultInitiated) && !controlVisibility.wrapup && isTelephony && (
<div className={`call-control-consult-container ${callControlConsultClassName || ''}`}>
<CallControlConsultComponent
agentName={consultAgentName}
startTimeStamp={consultStartTimeStamp}
endConsultCall={endConsultCall}
onTransfer={() => consultTransfer(consultAgentId || currentTask.data.destAgentId, lastTargetType)}
consultCompleted={consultCompleted}
isAgentBeingConsulted={!consultAccepted}
isEndConsultEnabled={isEndConsultEnabled}
logger={logger}
/>
</div>
)}
</>
);
};
export default CallControlCADComponent;