call-control-sdk 6.0.6 → 6.0.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.mts +880 -522
- package/dist/index.d.ts +880 -522
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +1 -1
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -1,170 +1,447 @@
|
|
|
1
1
|
import { SxProps } from '@mui/material';
|
|
2
|
-
import
|
|
2
|
+
import React from 'react';
|
|
3
3
|
|
|
4
|
-
/**
|
|
5
|
-
* 🚪 Logout
|
|
6
|
-
*
|
|
7
|
-
* @
|
|
8
|
-
* @description 🎯
|
|
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
|
-
|
|
4
|
+
/**
|
|
5
|
+
* 🚪 Logout Function Type
|
|
6
|
+
*
|
|
7
|
+
* @type LogoutFunction
|
|
8
|
+
* @description 🎯 Type definition for the logout function
|
|
9
|
+
* Handles secure agent logout with comprehensive cleanup procedures
|
|
10
|
+
*
|
|
11
|
+
* @returns {Promise<any>} Promise that resolves with API response data or rejects with error
|
|
12
|
+
*
|
|
13
|
+
* @example
|
|
14
|
+
* ```typescript
|
|
15
|
+
* const logout: LogoutFunction = async () => {
|
|
16
|
+
* // Logout logic
|
|
17
|
+
* return await apiCall();
|
|
18
|
+
* };
|
|
19
|
+
* ```
|
|
20
|
+
*
|
|
21
|
+
* @since 1.0.0
|
|
22
|
+
* @author CTI SDK Team
|
|
23
|
+
*/
|
|
24
|
+
type LogoutFunction = () => Promise<any>;
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* 📊 Hook State Management Types
|
|
28
|
+
*
|
|
29
|
+
* @type HookStateTypes
|
|
30
|
+
* @description 🎛️ Type definitions for all hook state variables
|
|
31
|
+
* Provides type safety for loading, success, error, and data states
|
|
32
|
+
*
|
|
33
|
+
* @since 1.0.0
|
|
34
|
+
* @author CTI SDK Team
|
|
35
|
+
*/
|
|
36
|
+
type HookStateTypes$2 = {
|
|
37
|
+
/**
|
|
38
|
+
* ⏳ Loading state indicator
|
|
39
|
+
* @description Boolean flag indicating if a logout operation is in progress
|
|
40
|
+
* @type {boolean}
|
|
41
|
+
*/
|
|
42
|
+
isLoading: boolean;
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* ✅ Success state indicator
|
|
46
|
+
* @description Boolean flag indicating if the last logout was successful
|
|
47
|
+
* @type {boolean}
|
|
48
|
+
*/
|
|
49
|
+
isSuccess: boolean;
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
* ❌ Error state indicator
|
|
53
|
+
* @description Boolean flag indicating if the last logout encountered an error
|
|
54
|
+
* @type {boolean}
|
|
55
|
+
*/
|
|
56
|
+
isError: boolean;
|
|
57
|
+
|
|
58
|
+
/**
|
|
59
|
+
* 🛡️ Error object
|
|
60
|
+
* @description Contains the error object when a logout fails
|
|
61
|
+
* @type {any}
|
|
62
|
+
*/
|
|
63
|
+
error: any;
|
|
64
|
+
|
|
65
|
+
/**
|
|
66
|
+
* 📊 Response data
|
|
67
|
+
* @description Contains the response data from successful logout
|
|
68
|
+
* @type {any}
|
|
69
|
+
*/
|
|
70
|
+
data: any;
|
|
71
|
+
};
|
|
72
|
+
|
|
73
|
+
/**
|
|
74
|
+
* 🚪 useLogout Hook Return Type
|
|
75
|
+
*
|
|
76
|
+
* @interface UseLogoutReturn
|
|
77
|
+
* @description 🎯 Complete return type for the useLogout hook
|
|
78
|
+
* Contains all functions and state for logout functionality
|
|
79
|
+
*
|
|
80
|
+
* @properties
|
|
81
|
+
* - `logout: LogoutFunction` - 🚪 Logout function
|
|
82
|
+
* - `isLoading: boolean` - ⏳ Loading state indicator
|
|
83
|
+
* - `isSuccess: boolean` - ✅ Success state indicator
|
|
84
|
+
* - `isError: boolean` - ❌ Error state indicator
|
|
85
|
+
* - `error: any` - 🛡️ Error object when logout fails
|
|
86
|
+
* - `data: any` - 📊 Response data from successful logout
|
|
87
|
+
*
|
|
88
|
+
* @example
|
|
89
|
+
* ```typescript
|
|
90
|
+
* const LogoutButton = () => {
|
|
91
|
+
* const hookReturn: UseLogoutReturn = useLogout();
|
|
92
|
+
* const {
|
|
93
|
+
* logout,
|
|
94
|
+
* isLoading,
|
|
95
|
+
* isSuccess,
|
|
96
|
+
* isError,
|
|
97
|
+
* error
|
|
98
|
+
* } = hookReturn;
|
|
99
|
+
*
|
|
100
|
+
* // Use the hook functionality
|
|
101
|
+
* };
|
|
102
|
+
* ```
|
|
103
|
+
*
|
|
104
|
+
* @since 1.0.0
|
|
105
|
+
* @author CTI SDK Team
|
|
106
|
+
*/
|
|
107
|
+
interface UseLogoutReturn extends HookStateTypes$2 {
|
|
108
|
+
/**
|
|
109
|
+
* 🚪 Logout function
|
|
110
|
+
* @description Handles secure agent logout with comprehensive cleanup procedures
|
|
111
|
+
* @type {LogoutFunction}
|
|
112
|
+
*/
|
|
113
|
+
logout: LogoutFunction;
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
/**
|
|
117
|
+
* 🚪 Logout Custom Hook
|
|
118
|
+
*
|
|
119
|
+
* @function useLogout
|
|
120
|
+
* @description 🎯 Custom React hook that provides comprehensive agent logout functionality
|
|
121
|
+
* for the CTI SDK. It handles secure logout procedures, complete state cleanup,
|
|
122
|
+
* and storage management with intelligent error handling and proper cleanup.
|
|
123
|
+
*
|
|
124
|
+
* @returns {UseLogoutReturn} Hook return object containing:
|
|
125
|
+
* - `logout: LogoutFunction` - 🚪 Logout function
|
|
126
|
+
* - `isLoading: boolean` - ⏳ Loading state indicator
|
|
127
|
+
* - `isSuccess: boolean` - ✅ Success state indicator
|
|
128
|
+
* - `isError: boolean` - ❌ Error state indicator
|
|
129
|
+
* - `error: any` - 🛡️ Error object when logout fails
|
|
130
|
+
* - `data: any` - 📊 Response data from successful logout
|
|
131
|
+
*
|
|
132
|
+
* @example
|
|
133
|
+
* ```typescript
|
|
134
|
+
* // Basic usage in a component
|
|
135
|
+
* const LogoutButton = () => {
|
|
136
|
+
* const {
|
|
137
|
+
* logout,
|
|
138
|
+
* isLoading,
|
|
139
|
+
* isSuccess,
|
|
140
|
+
* isError,
|
|
141
|
+
* error
|
|
142
|
+
* } = useLogout();
|
|
143
|
+
*
|
|
144
|
+
* const handleLogout = async () => {
|
|
145
|
+
* try {
|
|
146
|
+
* const result = await logout();
|
|
147
|
+
* console.log('🚪 Logout successful:', result);
|
|
148
|
+
* // Redirect to login page or handle success
|
|
149
|
+
* } catch (err) {
|
|
150
|
+
* console.error('❌ Logout failed:', err);
|
|
151
|
+
* }
|
|
152
|
+
* };
|
|
153
|
+
*
|
|
154
|
+
* return (
|
|
155
|
+
* <button
|
|
156
|
+
* onClick={handleLogout}
|
|
157
|
+
* disabled={isLoading}
|
|
158
|
+
* >
|
|
159
|
+
* {isLoading ? 'Logging out...' : 'Logout'}
|
|
160
|
+
* </button>
|
|
161
|
+
* );
|
|
162
|
+
* };
|
|
163
|
+
* ```
|
|
164
|
+
*
|
|
165
|
+
* @features
|
|
166
|
+
* - 🚪 Secure agent logout with API validation
|
|
167
|
+
* - 🗑️ Complete state cleanup and reset
|
|
168
|
+
* - 💾 Storage management (localStorage & sessionStorage)
|
|
169
|
+
* - ⏳ Comprehensive loading state management
|
|
170
|
+
* - 🛡️ Robust error handling and recovery
|
|
171
|
+
* - 📊 Real-time state updates via SDK manager
|
|
172
|
+
* - 🔄 Automatic storage cleanup
|
|
173
|
+
*
|
|
174
|
+
* @logic
|
|
175
|
+
* - 🔍 Retrieves agent state from localStorage
|
|
176
|
+
* - 📦 Constructs logout API payload
|
|
177
|
+
* - 📡 Makes API call to logout agent
|
|
178
|
+
* - 🗑️ Clears SDK state manager
|
|
179
|
+
* - 💾 Clears all storage (localStorage & sessionStorage)
|
|
180
|
+
* - 📊 Handles success/error states
|
|
181
|
+
* - ⏳ Manages loading states
|
|
182
|
+
*
|
|
183
|
+
* @since 1.0.0
|
|
184
|
+
* @author CTI SDK Team
|
|
185
|
+
*/
|
|
186
|
+
declare const useLogout: () => UseLogoutReturn;
|
|
82
187
|
|
|
83
|
-
/**
|
|
84
|
-
*
|
|
85
|
-
*
|
|
86
|
-
* @
|
|
87
|
-
* @description
|
|
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
|
-
|
|
188
|
+
/**
|
|
189
|
+
* 📅 End Call Data Interface
|
|
190
|
+
*
|
|
191
|
+
* @interface EndCallData
|
|
192
|
+
* @description 📊 Defines the structure for call termination input data
|
|
193
|
+
* Contains disposition and callback information for ending calls
|
|
194
|
+
*
|
|
195
|
+
* @properties
|
|
196
|
+
* - `disposition?: string` - 📝 Call outcome classification (default: "RES")
|
|
197
|
+
* - `followUp?: string` - 📅 Follow-up requirement (default: "N")
|
|
198
|
+
* - `callbackDate?: string` - 📅 Scheduled callback date (default: "")
|
|
199
|
+
* - `callbackHrs?: string` - 🕐 Scheduled callback hour (default: "")
|
|
200
|
+
* - `callbackMins?: string` - 🕐 Scheduled callback minute (default: "")
|
|
201
|
+
*
|
|
202
|
+
* @example
|
|
203
|
+
* ```typescript
|
|
204
|
+
* // Basic end call data
|
|
205
|
+
* const endCallData: EndCallData = {
|
|
206
|
+
* disposition: "RES",
|
|
207
|
+
* followUp: "N"
|
|
208
|
+
* };
|
|
209
|
+
*
|
|
210
|
+
* // With callback scheduling
|
|
211
|
+
* const endCallWithCallback: EndCallData = {
|
|
212
|
+
* disposition: "RES",
|
|
213
|
+
* followUp: "Y",
|
|
214
|
+
* callbackDate: "2024-01-15",
|
|
215
|
+
* callbackHrs: "14",
|
|
216
|
+
* callbackMins: "30"
|
|
217
|
+
* };
|
|
218
|
+
* ```
|
|
219
|
+
*
|
|
220
|
+
* @since 1.0.0
|
|
221
|
+
* @author CTI SDK Team
|
|
222
|
+
*/
|
|
223
|
+
interface EndCallData {
|
|
224
|
+
/**
|
|
225
|
+
* 📝 Call outcome classification
|
|
226
|
+
* @description How the call ended (default: "RES" for Resolved)
|
|
227
|
+
* @type {string | undefined}
|
|
228
|
+
*/
|
|
229
|
+
disposition?: string;
|
|
230
|
+
|
|
231
|
+
/**
|
|
232
|
+
* 📅 Follow-up requirement
|
|
233
|
+
* @description Whether follow-up is required (default: "N" for No)
|
|
234
|
+
* @type {string | undefined}
|
|
235
|
+
*/
|
|
236
|
+
followUp?: string;
|
|
237
|
+
|
|
238
|
+
/**
|
|
239
|
+
* 📅 Scheduled callback date
|
|
240
|
+
* @description Date for callback scheduling (YYYY-MM-DD format)
|
|
241
|
+
* @type {string | undefined}
|
|
242
|
+
*/
|
|
243
|
+
callbackDate?: string;
|
|
244
|
+
|
|
245
|
+
/**
|
|
246
|
+
* 🕐 Scheduled callback hour
|
|
247
|
+
* @description Hour for callback scheduling (0-23)
|
|
248
|
+
* @type {string | undefined}
|
|
249
|
+
*/
|
|
250
|
+
callbackHrs?: string;
|
|
251
|
+
|
|
252
|
+
/**
|
|
253
|
+
* 🕐 Scheduled callback minute
|
|
254
|
+
* @description Minute for callback scheduling (0-59)
|
|
255
|
+
* @type {string | undefined}
|
|
256
|
+
*/
|
|
257
|
+
callbackMins?: string;
|
|
258
|
+
}
|
|
259
|
+
|
|
260
|
+
/**
|
|
261
|
+
* 📞 Call Termination Function Type
|
|
262
|
+
*
|
|
263
|
+
* @type CallTerminationFunction
|
|
264
|
+
* @description 🎯 Type definition for the call termination function
|
|
265
|
+
* Handles call termination with disposition tracking and callback scheduling
|
|
266
|
+
*
|
|
267
|
+
* @param {EndCallData} data - 📊 Call termination data containing disposition and callback info
|
|
268
|
+
* @returns {Promise<any>} Promise that resolves with API response data or rejects with error
|
|
269
|
+
*
|
|
270
|
+
* @example
|
|
271
|
+
* ```typescript
|
|
272
|
+
* const handleEndCall: CallTerminationFunction = async (data) => {
|
|
273
|
+
* // Call termination logic
|
|
274
|
+
* return await apiCall(data);
|
|
275
|
+
* };
|
|
276
|
+
* ```
|
|
277
|
+
*
|
|
278
|
+
* @since 1.0.0
|
|
279
|
+
* @author CTI SDK Team
|
|
280
|
+
*/
|
|
281
|
+
type CallTerminationFunction = (data: EndCallData) => Promise<any>;
|
|
282
|
+
|
|
283
|
+
/**
|
|
284
|
+
* 📊 Hook State Management Types
|
|
285
|
+
*
|
|
286
|
+
* @type HookStateTypes
|
|
287
|
+
* @description 🎛️ Type definitions for all hook state variables
|
|
288
|
+
* Provides type safety for loading, success, error, and data states
|
|
289
|
+
*
|
|
290
|
+
* @since 1.0.0
|
|
291
|
+
* @author CTI SDK Team
|
|
292
|
+
*/
|
|
293
|
+
type HookStateTypes$1 = {
|
|
294
|
+
/**
|
|
295
|
+
* ⏳ Loading state indicator
|
|
296
|
+
* @description Boolean flag indicating if a call termination operation is in progress
|
|
297
|
+
* @type {boolean}
|
|
298
|
+
*/
|
|
299
|
+
isLoading: boolean;
|
|
300
|
+
|
|
301
|
+
/**
|
|
302
|
+
* ✅ Success state indicator
|
|
303
|
+
* @description Boolean flag indicating if the last call termination was successful
|
|
304
|
+
* @type {boolean}
|
|
305
|
+
*/
|
|
306
|
+
isSuccess: boolean;
|
|
307
|
+
|
|
308
|
+
/**
|
|
309
|
+
* ❌ Error state indicator
|
|
310
|
+
* @description Boolean flag indicating if the last call termination encountered an error
|
|
311
|
+
* @type {boolean}
|
|
312
|
+
*/
|
|
313
|
+
isError: boolean;
|
|
314
|
+
|
|
315
|
+
/**
|
|
316
|
+
* 🛡️ Error object
|
|
317
|
+
* @description Contains the error object when a call termination fails
|
|
318
|
+
* @type {any}
|
|
319
|
+
*/
|
|
320
|
+
error: any;
|
|
321
|
+
|
|
322
|
+
/**
|
|
323
|
+
* 📊 Response data
|
|
324
|
+
* @description Contains the response data from successful call terminations
|
|
325
|
+
* @type {any}
|
|
326
|
+
*/
|
|
327
|
+
data: any;
|
|
328
|
+
};
|
|
329
|
+
|
|
330
|
+
/**
|
|
331
|
+
* 📞 useEndCall Hook Return Type
|
|
332
|
+
*
|
|
333
|
+
* @interface UseEndCallReturn
|
|
334
|
+
* @description 🎯 Complete return type for the useEndCall hook
|
|
335
|
+
* Contains all functions and state for call termination functionality
|
|
336
|
+
*
|
|
337
|
+
* @properties
|
|
338
|
+
* - `handleEndCall: CallTerminationFunction` - 📞 Call termination function
|
|
339
|
+
* - `isLoading: boolean` - ⏳ Loading state indicator
|
|
340
|
+
* - `isSuccess: boolean` - ✅ Success state indicator
|
|
341
|
+
* - `isError: boolean` - ❌ Error state indicator
|
|
342
|
+
* - `error: any` - 🛡️ Error object when call fails
|
|
343
|
+
* - `data: any` - 📊 Response data from successful calls
|
|
344
|
+
*
|
|
345
|
+
* @example
|
|
346
|
+
* ```typescript
|
|
347
|
+
* const EndCallButton = () => {
|
|
348
|
+
* const hookReturn: UseEndCallReturn = useEndCall();
|
|
349
|
+
* const {
|
|
350
|
+
* handleEndCall,
|
|
351
|
+
* isLoading,
|
|
352
|
+
* isSuccess,
|
|
353
|
+
* isError,
|
|
354
|
+
* error
|
|
355
|
+
* } = hookReturn;
|
|
356
|
+
*
|
|
357
|
+
* // Use the hook functionality
|
|
358
|
+
* };
|
|
359
|
+
* ```
|
|
360
|
+
*
|
|
361
|
+
* @since 1.0.0
|
|
362
|
+
* @author CTI SDK Team
|
|
363
|
+
*/
|
|
364
|
+
interface UseEndCallReturn extends HookStateTypes$1 {
|
|
365
|
+
/**
|
|
366
|
+
* 📞 Call termination function
|
|
367
|
+
* @description Handles call termination with disposition tracking and callback scheduling
|
|
368
|
+
* @type {CallTerminationFunction}
|
|
369
|
+
*/
|
|
370
|
+
handleEndCall: CallTerminationFunction;
|
|
371
|
+
}
|
|
372
|
+
|
|
373
|
+
/**
|
|
374
|
+
* 📞 End Call Custom Hook
|
|
375
|
+
*
|
|
376
|
+
* @function useEndCall
|
|
377
|
+
* @description 🎯 Custom React hook that provides comprehensive call termination functionality
|
|
378
|
+
* for the CTI SDK. It handles call disposition capture, callback scheduling,
|
|
379
|
+
* and proper call cleanup with intelligent state management and error handling.
|
|
380
|
+
*
|
|
381
|
+
* @returns {UseEndCallReturn} Hook return object containing:
|
|
382
|
+
* - `handleEndCall: CallTerminationFunction` - 📞 Call termination function
|
|
383
|
+
* - `isLoading: boolean` - ⏳ Loading state indicator
|
|
384
|
+
* - `isSuccess: boolean` - ✅ Success state indicator
|
|
385
|
+
* - `isError: boolean` - ❌ Error state indicator
|
|
386
|
+
* - `error: any` - 🛡️ Error object when call fails
|
|
387
|
+
* - `data: any` - 📊 Response data from successful calls
|
|
388
|
+
*
|
|
389
|
+
* @example
|
|
390
|
+
* ```typescript
|
|
391
|
+
* // Basic usage in a component
|
|
392
|
+
* const EndCallButton = () => {
|
|
393
|
+
* const {
|
|
394
|
+
* handleEndCall,
|
|
395
|
+
* isLoading,
|
|
396
|
+
* isSuccess,
|
|
397
|
+
* isError,
|
|
398
|
+
* error
|
|
399
|
+
* } = useEndCall();
|
|
400
|
+
*
|
|
401
|
+
* const endCall = async () => {
|
|
402
|
+
* try {
|
|
403
|
+
* const result = await handleEndCall({
|
|
404
|
+
* disposition: "RES",
|
|
405
|
+
* followUp: "N"
|
|
406
|
+
* });
|
|
407
|
+
* console.log('📞 Call ended:', result);
|
|
408
|
+
* } catch (err) {
|
|
409
|
+
* console.error('❌ End call failed:', err);
|
|
410
|
+
* }
|
|
411
|
+
* };
|
|
412
|
+
*
|
|
413
|
+
* return (
|
|
414
|
+
* <button
|
|
415
|
+
* onClick={endCall}
|
|
416
|
+
* disabled={isLoading}
|
|
417
|
+
* >
|
|
418
|
+
* {isLoading ? 'Ending...' : 'End Call'}
|
|
419
|
+
* </button>
|
|
420
|
+
* );
|
|
421
|
+
* };
|
|
422
|
+
* ```
|
|
423
|
+
*
|
|
424
|
+
* @features
|
|
425
|
+
* - 🎯 Comprehensive call termination with disposition tracking
|
|
426
|
+
* - 📅 Callback scheduling and follow-up management
|
|
427
|
+
* - 🔄 Intelligent state cleanup and reset
|
|
428
|
+
* - ⏳ Comprehensive loading state management
|
|
429
|
+
* - 🛡️ Robust error handling and recovery
|
|
430
|
+
* - 📊 Real-time state updates via SDK manager
|
|
431
|
+
* - 🔄 Automatic call state management
|
|
432
|
+
*
|
|
433
|
+
* @logic
|
|
434
|
+
* - 🔍 Retrieves agent state from localStorage
|
|
435
|
+
* - 📦 Constructs comprehensive API payload
|
|
436
|
+
* - 📡 Makes API call to end call
|
|
437
|
+
* - 🔄 Updates SDK state manager
|
|
438
|
+
* - 📊 Handles success/error states
|
|
439
|
+
* - ⏳ Manages loading states
|
|
440
|
+
*
|
|
441
|
+
* @since 1.0.0
|
|
442
|
+
* @author CTI SDK Team
|
|
443
|
+
*/
|
|
444
|
+
declare const useEndCall: () => UseEndCallReturn;
|
|
168
445
|
|
|
169
446
|
/**
|
|
170
447
|
* @interface CallData
|
|
@@ -208,7 +485,7 @@ declare const useEndCall: () => {
|
|
|
208
485
|
*
|
|
209
486
|
* @conclusion Essential data structure for all call-related operations and state management.
|
|
210
487
|
*/
|
|
211
|
-
interface CallData {
|
|
488
|
+
interface CallData$1 {
|
|
212
489
|
/** Mobile number of the caller or callee */
|
|
213
490
|
mobileNumber?: string;
|
|
214
491
|
/** Unique reference identifier for the call */
|
|
@@ -262,102 +539,10 @@ interface CallData {
|
|
|
262
539
|
*
|
|
263
540
|
* @conclusion Provides flexible configuration for the call control panel component.
|
|
264
541
|
*/
|
|
265
|
-
interface CallControlPanelProps {
|
|
542
|
+
interface CallControlPanelProps$1 {
|
|
266
543
|
/** Optional callback function triggered when call data changes */
|
|
267
|
-
onDataChange?: (data: CallData) => void;
|
|
544
|
+
onDataChange?: (data: CallData$1) => void;
|
|
268
545
|
}
|
|
269
|
-
/**
|
|
270
|
-
* @type CallStatus
|
|
271
|
-
* @description Union type defining all possible call statuses in the CTI system.
|
|
272
|
-
* Represents the various states a call can be in during its lifecycle.
|
|
273
|
-
*
|
|
274
|
-
* @declaration
|
|
275
|
-
* ```typescript
|
|
276
|
-
* type CallStatus =
|
|
277
|
-
* | "idle"
|
|
278
|
-
* | "ready"
|
|
279
|
-
* | "break"
|
|
280
|
-
* | "on call"
|
|
281
|
-
* | "wrap up"
|
|
282
|
-
* | "dial"
|
|
283
|
-
* | "hold"
|
|
284
|
-
* | "mute";
|
|
285
|
-
* ```
|
|
286
|
-
*
|
|
287
|
-
* @requiredParams None (type definition)
|
|
288
|
-
*
|
|
289
|
-
* @returnType Union type definition
|
|
290
|
-
*
|
|
291
|
-
* @example
|
|
292
|
-
* ```typescript
|
|
293
|
-
* const currentStatus: CallStatus = "on call";
|
|
294
|
-
* const agentStatus: CallStatus = "ready";
|
|
295
|
-
* ```
|
|
296
|
-
*
|
|
297
|
-
* @return Union type with all possible call status values
|
|
298
|
-
*
|
|
299
|
-
* @conclusion Essential type for call state management and UI updates.
|
|
300
|
-
*/
|
|
301
|
-
type CallStatus = "idle" /** Agent is idle and available */ | "ready" /** Agent is ready to receive calls */ | "break" /** Agent is on break */ | "on call" /** Agent is currently on a call */ | "wrap up" /** Agent is in wrap-up phase after call */ | "dial" /** Agent is dialing a number */ | "hold" /** Call is on hold */ | "mute"; /** Call is muted */
|
|
302
|
-
/**
|
|
303
|
-
* @type ConferenceLineTypes
|
|
304
|
-
* @description Type definition for individual conference line data structure.
|
|
305
|
-
* Represents a single line in a conference call with its state and controls.
|
|
306
|
-
*
|
|
307
|
-
* @declaration
|
|
308
|
-
* ```typescript
|
|
309
|
-
* type ConferenceLineTypes = {
|
|
310
|
-
* line: number;
|
|
311
|
-
* status: string;
|
|
312
|
-
* type: "external" | "internal" | "";
|
|
313
|
-
* phone: string;
|
|
314
|
-
* isMute: boolean;
|
|
315
|
-
* isHold: boolean;
|
|
316
|
-
* isCallStart: boolean;
|
|
317
|
-
* isMergeCall: boolean;
|
|
318
|
-
* };
|
|
319
|
-
* ```
|
|
320
|
-
*
|
|
321
|
-
* @requiredParams None (type definition)
|
|
322
|
-
*
|
|
323
|
-
* @returnType Type definition
|
|
324
|
-
*
|
|
325
|
-
* @example
|
|
326
|
-
* ```typescript
|
|
327
|
-
* const conferenceLine: ConferenceLineTypes = {
|
|
328
|
-
* line: 1,
|
|
329
|
-
* status: "ONCALL",
|
|
330
|
-
* type: "internal",
|
|
331
|
-
* phone: "1234567890",
|
|
332
|
-
* isMute: false,
|
|
333
|
-
* isHold: false,
|
|
334
|
-
* isCallStart: true,
|
|
335
|
-
* isMergeCall: false
|
|
336
|
-
* };
|
|
337
|
-
* ```
|
|
338
|
-
*
|
|
339
|
-
* @return Type definition for conference line data
|
|
340
|
-
*
|
|
341
|
-
* @conclusion Essential type for conference call management and line state tracking.
|
|
342
|
-
*/
|
|
343
|
-
type ConferenceLineTypes = {
|
|
344
|
-
/** Line number identifier (1, 2, 3, etc.) */
|
|
345
|
-
line: number;
|
|
346
|
-
/** Current status of the line (ONCALL, IDLE, LINE USED, etc.) */
|
|
347
|
-
status: string;
|
|
348
|
-
/** Type of line (internal for agent, external for third party) */
|
|
349
|
-
type: "external" | "internal" | "";
|
|
350
|
-
/** Phone number associated with this line */
|
|
351
|
-
phone: string;
|
|
352
|
-
/** Whether the line is currently muted */
|
|
353
|
-
isMute: boolean;
|
|
354
|
-
/** Whether the line is currently on hold */
|
|
355
|
-
isHold: boolean;
|
|
356
|
-
/** Whether a call has been started on this line */
|
|
357
|
-
isCallStart: boolean;
|
|
358
|
-
/** Whether this line is merged into a conference */
|
|
359
|
-
isMergeCall: boolean;
|
|
360
|
-
};
|
|
361
546
|
/**
|
|
362
547
|
* @interface SDKConfig
|
|
363
548
|
* @description Configuration interface for customizing the Call Control SDK behavior.
|
|
@@ -418,270 +603,443 @@ interface SDKConfig {
|
|
|
418
603
|
/** Custom styles for outlined button states */
|
|
419
604
|
outlined?: SxProps;
|
|
420
605
|
}
|
|
421
|
-
/**
|
|
422
|
-
* @interface SDKState
|
|
423
|
-
* @description Comprehensive state interface for the Call Control SDK.
|
|
424
|
-
* Contains all necessary state information for managing CTI operations, UI state, and call data.
|
|
425
|
-
*
|
|
426
|
-
* @declaration
|
|
427
|
-
* ```typescript
|
|
428
|
-
* interface SDKState {
|
|
429
|
-
* openConferenceDialog: boolean;
|
|
430
|
-
* openCallTransferDialog: boolean;
|
|
431
|
-
* process?: { process_id: number; process_name: string } | null;
|
|
432
|
-
* agentId: string;
|
|
433
|
-
* sdkConfig: SDKConfig | null;
|
|
434
|
-
* isInitialized: boolean;
|
|
435
|
-
* isHolding: boolean;
|
|
436
|
-
* isMuted: boolean;
|
|
437
|
-
* status: CallStatus;
|
|
438
|
-
* convox_id?: string;
|
|
439
|
-
* process_id?: number;
|
|
440
|
-
* callStartTime: number | null;
|
|
441
|
-
* position?: { x: number; y: number };
|
|
442
|
-
* controlPanelPosition: { x: number; y: number };
|
|
443
|
-
* iframePosition: { x: number; y: number };
|
|
444
|
-
* callData: CallData;
|
|
445
|
-
* conferenceLine: ConferenceLineTypes[];
|
|
446
|
-
* }
|
|
447
|
-
* ```
|
|
448
|
-
*
|
|
449
|
-
* @requiredParams None (interface definition)
|
|
450
|
-
*
|
|
451
|
-
* @returnType Interface definition
|
|
452
|
-
*
|
|
453
|
-
* @example
|
|
454
|
-
* ```typescript
|
|
455
|
-
* const sdkState: SDKState = {
|
|
456
|
-
* openConferenceDialog: false,
|
|
457
|
-
* openCallTransferDialog: false,
|
|
458
|
-
* agentId: "agent001",
|
|
459
|
-
* sdkConfig: { isDraggable: true },
|
|
460
|
-
* isInitialized: true,
|
|
461
|
-
* isHolding: false,
|
|
462
|
-
* isMuted: false,
|
|
463
|
-
* status: "idle",
|
|
464
|
-
* callStartTime: null,
|
|
465
|
-
* controlPanelPosition: { x: 10, y: 10 },
|
|
466
|
-
* iframePosition: { x: 10, y: 80 },
|
|
467
|
-
* callData: {},
|
|
468
|
-
* conferenceLine: []
|
|
469
|
-
* };
|
|
470
|
-
* ```
|
|
471
|
-
*
|
|
472
|
-
* @return Interface definition for SDK state management
|
|
473
|
-
*
|
|
474
|
-
* @conclusion Central state interface that manages all aspects of the CTI system.
|
|
475
|
-
*/
|
|
476
|
-
interface SDKState {
|
|
477
|
-
/** Whether the conference dialog is currently open */
|
|
478
|
-
openConferenceDialog: boolean;
|
|
479
|
-
/** Whether the call transfer dialog is currently open */
|
|
480
|
-
openCallTransferDialog: boolean;
|
|
481
|
-
/** Currently selected process information */
|
|
482
|
-
process?: {
|
|
483
|
-
process_id: number;
|
|
484
|
-
process_name: string;
|
|
485
|
-
} | null;
|
|
486
|
-
/** Unique identifier for the agent */
|
|
487
|
-
agentId: string;
|
|
488
|
-
/** SDK configuration settings */
|
|
489
|
-
sdkConfig: SDKConfig | null;
|
|
490
|
-
/** Whether the SDK has been successfully initialized */
|
|
491
|
-
isInitialized: boolean;
|
|
492
|
-
/** Whether the current call is on hold */
|
|
493
|
-
isHolding: boolean;
|
|
494
|
-
/** Whether the current call is muted */
|
|
495
|
-
isMuted: boolean;
|
|
496
|
-
/** Current agent/call status */
|
|
497
|
-
status: CallStatus;
|
|
498
|
-
/** Convox system call identifier */
|
|
499
|
-
convox_id?: string;
|
|
500
|
-
/** Process identifier for the current call */
|
|
501
|
-
process_id?: number;
|
|
502
|
-
/** Timestamp when the current call started */
|
|
503
|
-
callStartTime: number | null;
|
|
504
|
-
/** Current position of draggable elements */
|
|
505
|
-
position?: {
|
|
506
|
-
x: number;
|
|
507
|
-
y: number;
|
|
508
|
-
};
|
|
509
|
-
/** Position of the main control panel */
|
|
510
|
-
controlPanelPosition: {
|
|
511
|
-
x: number;
|
|
512
|
-
y: number;
|
|
513
|
-
};
|
|
514
|
-
/** Position of the soft phone iframe */
|
|
515
|
-
iframePosition: {
|
|
516
|
-
x: number;
|
|
517
|
-
y: number;
|
|
518
|
-
};
|
|
519
|
-
/** Current call data and metadata */
|
|
520
|
-
callData: CallData;
|
|
521
|
-
/** Array of conference lines and their states */
|
|
522
|
-
conferenceLine: ConferenceLineTypes[];
|
|
523
|
-
}
|
|
524
606
|
|
|
525
|
-
/**
|
|
526
|
-
* @fileoverview 📞
|
|
527
|
-
*
|
|
528
|
-
* This file contains the useClickToCall custom hook
|
|
529
|
-
*
|
|
530
|
-
*
|
|
531
|
-
*
|
|
532
|
-
* 🎯 Key
|
|
533
|
-
* - 📱
|
|
534
|
-
* -
|
|
535
|
-
* - 🔄
|
|
536
|
-
* -
|
|
537
|
-
*
|
|
538
|
-
*
|
|
539
|
-
*
|
|
540
|
-
* @
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
*
|
|
546
|
-
*
|
|
547
|
-
* @
|
|
548
|
-
*
|
|
549
|
-
*
|
|
550
|
-
*
|
|
551
|
-
*
|
|
552
|
-
*
|
|
553
|
-
*
|
|
554
|
-
*
|
|
555
|
-
*
|
|
556
|
-
*
|
|
557
|
-
*
|
|
558
|
-
*
|
|
559
|
-
*
|
|
560
|
-
*
|
|
561
|
-
*
|
|
562
|
-
*
|
|
563
|
-
*
|
|
564
|
-
*
|
|
565
|
-
*
|
|
566
|
-
* @
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
*
|
|
579
|
-
*
|
|
580
|
-
* @
|
|
581
|
-
*
|
|
582
|
-
*
|
|
583
|
-
*
|
|
584
|
-
*
|
|
585
|
-
*
|
|
586
|
-
*
|
|
587
|
-
*
|
|
588
|
-
*
|
|
589
|
-
*
|
|
590
|
-
*
|
|
591
|
-
*
|
|
592
|
-
*
|
|
593
|
-
*
|
|
594
|
-
*
|
|
595
|
-
*
|
|
596
|
-
*
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
*
|
|
602
|
-
*
|
|
603
|
-
*
|
|
604
|
-
*
|
|
605
|
-
*
|
|
606
|
-
*
|
|
607
|
-
*
|
|
608
|
-
*
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
607
|
+
/**
|
|
608
|
+
* @fileoverview 📞 TypeScript Declaration File for useClickToCall Hook
|
|
609
|
+
*
|
|
610
|
+
* This file contains TypeScript type definitions for the useClickToCall custom hook
|
|
611
|
+
* and its related interfaces. It provides comprehensive type safety and IntelliSense
|
|
612
|
+
* support for developers using the CTI SDK.
|
|
613
|
+
*
|
|
614
|
+
* 🎯 Key Type Definitions:
|
|
615
|
+
* - 📱 StartCallPayload interface for call initiation data
|
|
616
|
+
* - 📞 useClickToCall hook return type
|
|
617
|
+
* - 🔄 Call initiation function signature
|
|
618
|
+
* - 📊 State management types
|
|
619
|
+
*
|
|
620
|
+
* @author CTI SDK Team
|
|
621
|
+
* @version 6.1.0
|
|
622
|
+
* @since 1.0.0
|
|
623
|
+
*/
|
|
624
|
+
|
|
625
|
+
/**
|
|
626
|
+
* 📱 Start Call Payload Interface
|
|
627
|
+
*
|
|
628
|
+
* @interface StartCallPayload
|
|
629
|
+
* @description 📊 Defines the structure for call initiation payload data
|
|
630
|
+
* Contains the mobile number required to initiate a call
|
|
631
|
+
*
|
|
632
|
+
* @properties
|
|
633
|
+
* - `mobileNumber: string` - 📱 The phone number to call (required)
|
|
634
|
+
*
|
|
635
|
+
* @example
|
|
636
|
+
* ```typescript
|
|
637
|
+
* // Basic call initiation payload
|
|
638
|
+
* const callPayload: StartCallPayload = {
|
|
639
|
+
* mobileNumber: "1234567890"
|
|
640
|
+
* };
|
|
641
|
+
*
|
|
642
|
+
* // Usage in component
|
|
643
|
+
* const { handleStartCall } = useClickToCall();
|
|
644
|
+
* await handleStartCall({ mobileNumber: "9876543210" });
|
|
645
|
+
* ```
|
|
646
|
+
*
|
|
647
|
+
* @since 1.0.0
|
|
648
|
+
* @author CTI SDK Team
|
|
649
|
+
*/
|
|
650
|
+
interface StartCallPayload {
|
|
651
|
+
/**
|
|
652
|
+
* 📱 Phone number to call
|
|
653
|
+
* @description The mobile number that will be called
|
|
654
|
+
* @type {string}
|
|
655
|
+
*/
|
|
656
|
+
mobileNumber: string;
|
|
657
|
+
}
|
|
658
|
+
|
|
659
|
+
/**
|
|
660
|
+
* 📞 Call Initiation Function Type
|
|
661
|
+
*
|
|
662
|
+
* @type CallInitiationFunction
|
|
663
|
+
* @description 🎯 Type definition for the call initiation function
|
|
664
|
+
* Handles both regular calls and conference calls based on agent state
|
|
665
|
+
*
|
|
666
|
+
* @param {StartCallPayload} data - 📊 Call initiation data containing mobile number
|
|
667
|
+
* @returns {Promise<any>} Promise that resolves with API response data or rejects with error
|
|
668
|
+
*
|
|
669
|
+
* @example
|
|
670
|
+
* ```typescript
|
|
671
|
+
* const handleStartCall: CallInitiationFunction = async (data) => {
|
|
672
|
+
* // Call initiation logic
|
|
673
|
+
* return await apiCall(data);
|
|
674
|
+
* };
|
|
675
|
+
* ```
|
|
676
|
+
*
|
|
677
|
+
* @since 1.0.0
|
|
678
|
+
* @author CTI SDK Team
|
|
679
|
+
*/
|
|
680
|
+
type CallInitiationFunction = (data: StartCallPayload) => Promise<any>;
|
|
681
|
+
|
|
682
|
+
/**
|
|
683
|
+
* 📊 Hook State Management Types
|
|
684
|
+
*
|
|
685
|
+
* @type HookStateTypes
|
|
686
|
+
* @description 🎛️ Type definitions for all hook state variables
|
|
687
|
+
* Provides type safety for loading, success, error, and data states
|
|
688
|
+
*
|
|
689
|
+
* @since 1.0.0
|
|
690
|
+
* @author CTI SDK Team
|
|
691
|
+
*/
|
|
692
|
+
type HookStateTypes = {
|
|
693
|
+
/**
|
|
694
|
+
* ⏳ Loading state indicator
|
|
695
|
+
* @description Boolean flag indicating if a call operation is currently in progress
|
|
696
|
+
* @type {boolean}
|
|
697
|
+
*/
|
|
698
|
+
isLoading: boolean;
|
|
699
|
+
|
|
700
|
+
/**
|
|
701
|
+
* ✅ Success state indicator
|
|
702
|
+
* @description Boolean flag indicating if the last call operation was successful
|
|
703
|
+
* @type {boolean}
|
|
704
|
+
*/
|
|
705
|
+
isSuccess: boolean;
|
|
706
|
+
|
|
707
|
+
/**
|
|
708
|
+
* ❌ Error state indicator
|
|
709
|
+
* @description Boolean flag indicating if the last call operation encountered an error
|
|
710
|
+
* @type {boolean}
|
|
711
|
+
*/
|
|
712
|
+
isError: boolean;
|
|
713
|
+
|
|
714
|
+
/**
|
|
715
|
+
* 🛡️ Error object
|
|
716
|
+
* @description Contains the error object when a call operation fails
|
|
717
|
+
* @type {any}
|
|
718
|
+
*/
|
|
719
|
+
error: any;
|
|
720
|
+
|
|
721
|
+
/**
|
|
722
|
+
* 📊 Response data
|
|
723
|
+
* @description Contains the response data from successful call operations
|
|
724
|
+
* @type {any}
|
|
725
|
+
*/
|
|
726
|
+
data: any;
|
|
727
|
+
};
|
|
728
|
+
|
|
729
|
+
/**
|
|
730
|
+
* 📞 useClickToCall Hook Return Type
|
|
731
|
+
*
|
|
732
|
+
* @interface UseClickToCallReturn
|
|
733
|
+
* @description 🎯 Complete return type for the useClickToCall hook
|
|
734
|
+
* Contains all functions and state for call initiation functionality
|
|
735
|
+
*
|
|
736
|
+
* @properties
|
|
737
|
+
* - `handleStartCall: CallInitiationFunction` - 📞 Call initiation function
|
|
738
|
+
* - `isLoading: boolean` - ⏳ Loading state indicator
|
|
739
|
+
* - `isSuccess: boolean` - ✅ Success state indicator
|
|
740
|
+
* - `isError: boolean` - ❌ Error state indicator
|
|
741
|
+
* - `error: any` - 🛡️ Error object when call fails
|
|
742
|
+
* - `data: any` - 📊 Response data from successful calls
|
|
743
|
+
*
|
|
744
|
+
* @example
|
|
745
|
+
* ```typescript
|
|
746
|
+
* const CallButton = () => {
|
|
747
|
+
* const hookReturn: UseClickToCallReturn = useClickToCall();
|
|
748
|
+
* const {
|
|
749
|
+
* handleStartCall,
|
|
750
|
+
* isLoading,
|
|
751
|
+
* isSuccess,
|
|
752
|
+
* isError,
|
|
753
|
+
* error
|
|
754
|
+
* } = hookReturn;
|
|
755
|
+
*
|
|
756
|
+
* // Use the hook functionality
|
|
757
|
+
* };
|
|
758
|
+
* ```
|
|
759
|
+
*
|
|
760
|
+
* @since 1.0.0
|
|
761
|
+
* @author CTI SDK Team
|
|
762
|
+
*/
|
|
763
|
+
interface UseClickToCallReturn extends HookStateTypes {
|
|
764
|
+
/**
|
|
765
|
+
* 📞 Call initiation function
|
|
766
|
+
* @description Handles call initiation with intelligent routing based on agent state
|
|
767
|
+
* @type {CallInitiationFunction}
|
|
768
|
+
*/
|
|
769
|
+
handleStartCall: CallInitiationFunction;
|
|
770
|
+
}
|
|
771
|
+
|
|
772
|
+
/**
|
|
773
|
+
* 📞 Click-to-Call Custom Hook
|
|
774
|
+
*
|
|
775
|
+
* @function useClickToCall
|
|
776
|
+
* @description 🎯 Custom React hook that provides comprehensive call initiation functionality
|
|
777
|
+
* for the CTI SDK. It intelligently handles both regular calls and conference calls
|
|
778
|
+
* based on the current agent state, with proper loading states and error handling.
|
|
779
|
+
*
|
|
780
|
+
* @returns {UseClickToCallReturn} Hook return object containing:
|
|
781
|
+
* - `handleStartCall: CallInitiationFunction` - 📞 Call initiation function
|
|
782
|
+
* - `isLoading: boolean` - ⏳ Loading state indicator
|
|
783
|
+
* - `isSuccess: boolean` - ✅ Success state indicator
|
|
784
|
+
* - `isError: boolean` - ❌ Error state indicator
|
|
785
|
+
* - `error: any` - 🛡️ Error object when call fails
|
|
786
|
+
* - `data: any` - 📊 Response data from successful calls
|
|
787
|
+
*
|
|
788
|
+
* @example
|
|
789
|
+
* ```typescript
|
|
790
|
+
* // Basic usage in a component
|
|
791
|
+
* const CallButton = () => {
|
|
792
|
+
* const {
|
|
793
|
+
* handleStartCall,
|
|
794
|
+
* isLoading,
|
|
795
|
+
* isSuccess,
|
|
796
|
+
* isError,
|
|
797
|
+
* error
|
|
798
|
+
* } = useClickToCall();
|
|
799
|
+
*
|
|
800
|
+
* const makeCall = async () => {
|
|
801
|
+
* try {
|
|
802
|
+
* const result = await handleStartCall({
|
|
803
|
+
* mobileNumber: "1234567890"
|
|
804
|
+
* });
|
|
805
|
+
* console.log('📞 Call initiated:', result);
|
|
806
|
+
* } catch (err) {
|
|
807
|
+
* console.error('❌ Call failed:', err);
|
|
808
|
+
* }
|
|
809
|
+
* };
|
|
810
|
+
*
|
|
811
|
+
* return (
|
|
812
|
+
* <button
|
|
813
|
+
* onClick={makeCall}
|
|
814
|
+
* disabled={isLoading}
|
|
815
|
+
* >
|
|
816
|
+
* {isLoading ? 'Calling...' : 'Make Call'}
|
|
817
|
+
* </button>
|
|
818
|
+
* );
|
|
819
|
+
* };
|
|
820
|
+
* ```
|
|
821
|
+
*
|
|
822
|
+
* @features
|
|
823
|
+
* - 🎯 Intelligent call routing based on agent state
|
|
824
|
+
* - 📱 Regular call initiation for idle agents
|
|
825
|
+
* - 👥 Conference call initiation for busy agents
|
|
826
|
+
* - ⏳ Comprehensive loading state management
|
|
827
|
+
* - 🛡️ Robust error handling and recovery
|
|
828
|
+
* - 📊 Real-time state updates via SDK manager
|
|
829
|
+
* - 🔄 Automatic conference dialog management
|
|
830
|
+
*
|
|
831
|
+
* @logic
|
|
832
|
+
* - 🔍 Checks agent status from localStorage state
|
|
833
|
+
* - 📞 Initiates regular call if agent is IDLE
|
|
834
|
+
* - 👥 Initiates conference call if agent is ONCALL
|
|
835
|
+
* - ⚠️ Shows alert if agent is not ready
|
|
836
|
+
* - 🔄 Updates conference line state for conference calls
|
|
837
|
+
* - 🎭 Opens conference dialog for conference calls
|
|
838
|
+
*
|
|
839
|
+
* @since 1.0.0
|
|
840
|
+
* @author CTI SDK Team
|
|
841
|
+
*/
|
|
842
|
+
declare const useClickToCall: () => UseClickToCallReturn;
|
|
650
843
|
|
|
651
|
-
/**
|
|
652
|
-
* @
|
|
653
|
-
*
|
|
654
|
-
*
|
|
655
|
-
*
|
|
656
|
-
*
|
|
657
|
-
*
|
|
658
|
-
*
|
|
659
|
-
*
|
|
660
|
-
*
|
|
661
|
-
*
|
|
662
|
-
* -
|
|
663
|
-
*
|
|
664
|
-
*
|
|
665
|
-
*
|
|
666
|
-
* @
|
|
667
|
-
*
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
*
|
|
672
|
-
*
|
|
673
|
-
*
|
|
674
|
-
*
|
|
675
|
-
*
|
|
676
|
-
*
|
|
677
|
-
*
|
|
678
|
-
*
|
|
679
|
-
*
|
|
680
|
-
*
|
|
681
|
-
*
|
|
682
|
-
*
|
|
683
|
-
|
|
684
|
-
|
|
844
|
+
/**
|
|
845
|
+
* @fileoverview 📞 TypeScript Declaration File for CallControlPanel Component
|
|
846
|
+
*
|
|
847
|
+
* This file contains TypeScript type definitions for the CallControlPanel component
|
|
848
|
+
* and its related interfaces. It provides comprehensive type safety and IntelliSense
|
|
849
|
+
* support for developers using the CTI SDK main component.
|
|
850
|
+
*
|
|
851
|
+
* 🎯 Key Type Definitions:
|
|
852
|
+
* - 📞 CallControlPanelProps interface for component props
|
|
853
|
+
* - 📞 CallData interface for call data structure
|
|
854
|
+
* - 🔄 Data change callback types
|
|
855
|
+
* - 📊 Component return types
|
|
856
|
+
* - 🎯 Error handling types
|
|
857
|
+
*
|
|
858
|
+
* @author CTI SDK Team
|
|
859
|
+
* @version 6.1.0
|
|
860
|
+
* @since 1.0.0
|
|
861
|
+
*/
|
|
862
|
+
|
|
863
|
+
/**
|
|
864
|
+
* 📞 Call Data Interface
|
|
865
|
+
*
|
|
866
|
+
* @interface CallData
|
|
867
|
+
* @description 📊 Comprehensive interface defining call-related data structure for CTI operations.
|
|
868
|
+
* Contains all necessary information about active calls, including metadata, status, and references.
|
|
869
|
+
*
|
|
870
|
+
* @properties
|
|
871
|
+
* - `mobileNumber?: string` - 📱 Mobile number of the caller or callee
|
|
872
|
+
* - `callReferenceId?: string` - 🔗 Unique reference identifier for the call
|
|
873
|
+
* - `convoxId?: string` - 🔗 Convox system identifier for the call
|
|
874
|
+
* - `type?: string` - 📞 Type of call (inbound, outbound, internal, etc.)
|
|
875
|
+
* - `status?: string` - 📊 Current status of the call (ONCALL, RINGING, WRAPUP, etc.)
|
|
876
|
+
* - `agent_id?: string` - 👤 Agent identifier associated with the call
|
|
877
|
+
* - `phone_number?: string` - 📱 Phone number involved in the call
|
|
878
|
+
* - `event_time?: string` - ⏰ Timestamp when the call event occurred
|
|
879
|
+
* - `convox_id?: string` - 🔗 Convox system call ID
|
|
880
|
+
* - `process_id?: string` - ⚙️ Process identifier for the call
|
|
881
|
+
* - `process_name?: string` - 📝 Name of the process handling the call
|
|
882
|
+
*
|
|
883
|
+
* @example
|
|
884
|
+
* ```typescript
|
|
885
|
+
* const callData: CallData = {
|
|
886
|
+
* mobileNumber: "1234567890",
|
|
887
|
+
* callReferenceId: "REF123456",
|
|
888
|
+
* status: "ONCALL",
|
|
889
|
+
* agent_id: "agent001",
|
|
890
|
+
* process_id: "proc001",
|
|
891
|
+
* process_name: "Sales Process"
|
|
892
|
+
* };
|
|
893
|
+
* ```
|
|
894
|
+
*
|
|
895
|
+
* @since 1.0.0
|
|
896
|
+
* @author CTI SDK Team
|
|
897
|
+
*/
|
|
898
|
+
interface CallData {
|
|
899
|
+
/** Mobile number of the caller or callee */
|
|
900
|
+
mobileNumber?: string;
|
|
901
|
+
/** Unique reference identifier for the call */
|
|
902
|
+
callReferenceId?: string;
|
|
903
|
+
/** Convox system identifier for the call */
|
|
904
|
+
convoxId?: string;
|
|
905
|
+
/** Type of call (inbound, outbound, internal, etc.) */
|
|
906
|
+
type?: string;
|
|
907
|
+
/** Current status of the call (ONCALL, RINGING, WRAPUP, etc.) */
|
|
908
|
+
status?: string;
|
|
909
|
+
/** Agent identifier associated with the call */
|
|
910
|
+
agent_id?: string;
|
|
911
|
+
/** Phone number involved in the call */
|
|
912
|
+
phone_number?: string;
|
|
913
|
+
/** Timestamp when the call event occurred */
|
|
914
|
+
event_time?: string;
|
|
915
|
+
/** Convox system call ID */
|
|
916
|
+
convox_id?: string;
|
|
917
|
+
/** Process identifier for the call */
|
|
918
|
+
process_id?: string;
|
|
919
|
+
/** Name of the process handling the call */
|
|
920
|
+
process_name?: string;
|
|
921
|
+
}
|
|
922
|
+
|
|
923
|
+
/**
|
|
924
|
+
* 🔄 Data Change Callback Type
|
|
925
|
+
*
|
|
926
|
+
* @type DataChangeCallback
|
|
927
|
+
* @description 🎯 Type definition for data change callback function
|
|
928
|
+
* Called whenever call data changes in the component
|
|
929
|
+
*
|
|
930
|
+
* @param {CallData} data - Updated call data
|
|
931
|
+
* @returns {void} No return value
|
|
932
|
+
*
|
|
933
|
+
* @example
|
|
934
|
+
* ```typescript
|
|
935
|
+
* const onDataChange: DataChangeCallback = (data) => {
|
|
936
|
+
* console.log('Call data updated:', data);
|
|
937
|
+
* // Handle call data changes
|
|
938
|
+
* };
|
|
939
|
+
* ```
|
|
940
|
+
*
|
|
941
|
+
* @since 1.0.0
|
|
942
|
+
* @author CTI SDK Team
|
|
943
|
+
*/
|
|
944
|
+
type DataChangeCallback = (data: CallData) => void;
|
|
945
|
+
|
|
946
|
+
/**
|
|
947
|
+
* 📞 Call Control Panel Props Interface
|
|
948
|
+
*
|
|
949
|
+
* @interface CallControlPanelProps
|
|
950
|
+
* @description 📊 Props interface for the main CallControlPanel component.
|
|
951
|
+
* Defines the properties that can be passed to customize the call control interface behavior.
|
|
952
|
+
*
|
|
953
|
+
* @properties
|
|
954
|
+
* - `onDataChange?: DataChangeCallback` - 🔄 Optional callback function triggered when call data changes
|
|
955
|
+
*
|
|
956
|
+
* @example
|
|
957
|
+
* ```tsx
|
|
958
|
+
* <CallControlPanel
|
|
959
|
+
* onDataChange={(callData) => {
|
|
960
|
+
* console.log('Call status changed:', callData.status);
|
|
961
|
+
* // Handle call data updates
|
|
962
|
+
* }}
|
|
963
|
+
* />
|
|
964
|
+
* ```
|
|
965
|
+
*
|
|
966
|
+
* @since 1.0.0
|
|
967
|
+
* @author CTI SDK Team
|
|
968
|
+
*/
|
|
969
|
+
interface CallControlPanelProps {
|
|
970
|
+
/** Optional callback function triggered when call data changes */
|
|
971
|
+
onDataChange?: DataChangeCallback;
|
|
972
|
+
}
|
|
973
|
+
|
|
974
|
+
/**
|
|
975
|
+
* 📞 Call Control Panel Component Type
|
|
976
|
+
*
|
|
977
|
+
* @type CallControlPanelComponent
|
|
978
|
+
* @description 🎯 Type definition for the CallControlPanel component
|
|
979
|
+
* Memoized React component with proper prop types
|
|
980
|
+
*
|
|
981
|
+
* @param {CallControlPanelProps} props - Component props
|
|
982
|
+
* @returns {JSX.Element} React component element
|
|
983
|
+
*
|
|
984
|
+
* @example
|
|
985
|
+
* ```typescript
|
|
986
|
+
* const CallControlPanel: CallControlPanelComponent = memo(({ onDataChange }) => {
|
|
987
|
+
* // Component implementation
|
|
988
|
+
* });
|
|
989
|
+
* ```
|
|
990
|
+
*
|
|
991
|
+
* @since 1.0.0
|
|
992
|
+
* @author CTI SDK Team
|
|
993
|
+
*/
|
|
994
|
+
|
|
995
|
+
type CallControlPanelComponent = React.MemoExoticComponent<
|
|
996
|
+
(props: CallControlPanelProps) => React.ReactElement
|
|
997
|
+
>;
|
|
998
|
+
|
|
999
|
+
/**
|
|
1000
|
+
* 📞 Call Control Panel Component
|
|
1001
|
+
*
|
|
1002
|
+
* @function CallControlPanel
|
|
1003
|
+
* @description 🎯 Main wrapper component that provides the complete call control interface.
|
|
1004
|
+
* Wraps the CallControls component with necessary providers and context.
|
|
1005
|
+
*
|
|
1006
|
+
* @param {CallControlPanelProps} props - Component props including optional data change callback
|
|
1007
|
+
* @returns {JSX.Element} React component providing complete call control interface
|
|
1008
|
+
*
|
|
1009
|
+
* @example
|
|
1010
|
+
* ```tsx
|
|
1011
|
+
* // Basic usage
|
|
1012
|
+
* <CallControlPanel />
|
|
1013
|
+
*
|
|
1014
|
+
* // With data change callback
|
|
1015
|
+
* <CallControlPanel
|
|
1016
|
+
* onDataChange={(callData) => {
|
|
1017
|
+
* console.log('Call data updated:', callData);
|
|
1018
|
+
* // Handle call data changes
|
|
1019
|
+
* }}
|
|
1020
|
+
* />
|
|
1021
|
+
* ```
|
|
1022
|
+
*
|
|
1023
|
+
* @features
|
|
1024
|
+
* - 📞 **Complete CTI Interface**: Provides full call control functionality
|
|
1025
|
+
* - 🔄 **Data Change Handling**: Optional callback for call data updates
|
|
1026
|
+
* - 🛡️ **Error Handling**: Comprehensive error handling for data changes
|
|
1027
|
+
* - ⚡ **Performance Optimized**: Uses React.memo for optimal re-rendering
|
|
1028
|
+
* - 🎯 **Type Safety**: Full TypeScript support with comprehensive types
|
|
1029
|
+
* - 🔧 **Provider Integration**: Wraps components with necessary providers
|
|
1030
|
+
* - 📊 **State Management**: Integrated with SDK state management
|
|
1031
|
+
*
|
|
1032
|
+
* @logic
|
|
1033
|
+
* - 🔄 Creates internal data change handler with error handling
|
|
1034
|
+
* - 🎯 Wraps CallControls component with SDKProvider
|
|
1035
|
+
* - 📊 Passes data change handler to CallControls
|
|
1036
|
+
* - 🛡️ Handles errors gracefully in data change callbacks
|
|
1037
|
+
* - ⚡ Uses useCallback for performance optimization
|
|
1038
|
+
*
|
|
1039
|
+
* @since 1.0.0
|
|
1040
|
+
* @author CTI SDK Team
|
|
1041
|
+
*/
|
|
1042
|
+
declare const CallControlPanel: CallControlPanelComponent;
|
|
685
1043
|
|
|
686
1044
|
/**
|
|
687
1045
|
* @fileoverview Call Control SDK - Main Entry Point
|
|
@@ -842,4 +1200,4 @@ declare function getSDKVersion(): string;
|
|
|
842
1200
|
*/
|
|
843
1201
|
declare function isSDKInitialized(): boolean;
|
|
844
1202
|
|
|
845
|
-
export { CallControlPanel, type CallControlPanelProps
|
|
1203
|
+
export { CallControlPanel, type CallControlPanelProps$1 as CallControlPanelProps, type CallData$1 as CallData, type SDKConfig, getSDKVersion, initSDK, isSDKInitialized, useClickToCall, useEndCall, useLogout };
|