Skip to content

Commit d69e11b

Browse files
author
molker
committed
Update with SDK changes
1 parent b86d5fa commit d69e11b

12 files changed

Lines changed: 675 additions & 1144 deletions

File tree

packages/contact-center/cc-components/src/components/task/OutdialCall/outdial-call.tsx

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import React, {useMemo, useState} from 'react';
1+
import React, {useEffect, useMemo, useState} from 'react';
22
import {OutdialCallComponentProps} from '../task.types';
33
import './outdial-call.style.scss';
44
import {withMetrics} from '@webex/cc-ui-logging';
@@ -40,21 +40,34 @@ interface OutdialANIEntry {
4040
* @property startOutdial - Function to initiate the outdial call with the entered destination number.
4141
*/
4242
const OutdialCallComponent: React.FunctionComponent<OutdialCallComponentProps> = (props) => {
43-
const {startOutdial, outdialANIEntries} = props;
43+
const {startOutdial, getOutdialANIEntries} = props;
4444

4545
// State Hooks
4646
const [destination, setDestination] = useState('');
4747
const [isValidNumber, setIsValidNumber] = useState('');
48-
const [selectedANI, setSelectedANI] = useState('');
48+
const [selectedANI, setSelectedANI] = useState(undefined);
49+
const [outdialANIList, setOutdialANIList] = useState<OutdialANIEntry[]>([]);
4950

5051
// Validate the input format using regex from agent desktop
5152
const regExForDnSpecialChars = useMemo(
5253
() => new RegExp('^[+1][0-9]{3,18}$|^[*#][+1][0-9*#:]{3,18}$|^[0-9*#]{3,18}$'),
5354
[]
5455
);
5556

56-
// Give Select an empty list if outdial ANI entries are not provided
57-
const outdialANIList: OutdialANIEntry[] = outdialANIEntries ?? [];
57+
// useEffect and useState to allow for async fetching of outdial ANI entries
58+
useEffect(() => {
59+
// Give Select an empty list if outdial ANI entries are not provided
60+
const updateList = async () => {
61+
try {
62+
const result = await getOutdialANIEntries();
63+
setOutdialANIList(result);
64+
} catch (error) {
65+
console.error('Error fetching outdial ANI entries:', error);
66+
setOutdialANIList([]);
67+
}
68+
};
69+
updateList();
70+
}, [getOutdialANIEntries]);
5871

5972
/**
6073
* validateOutboundNumber
@@ -144,7 +157,7 @@ const OutdialCallComponent: React.FunctionComponent<OutdialCallComponentProps> =
144157
data-testid="outdial-call-button"
145158
className="button"
146159
prefixIcon={'handset-regular'}
147-
onClick={() => startOutdial(destination)}
160+
onClick={() => startOutdial(destination, selectedANI)}
148161
disabled={!!isValidNumber || !destination}
149162
/>
150163
</article>

packages/contact-center/cc-components/src/components/task/task.types.ts

Lines changed: 19 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -456,28 +456,34 @@ export type CallControlComponentProps = Pick<
456456
| 'cancelAutoWrapup'
457457
>;
458458

459+
export type OutdialAniEntry = {
460+
/** Unique identifier for the ANI entry */
461+
id: string;
462+
/** Display name for the ANI entry */
463+
name: string;
464+
/** Phone number associated with this ANI entry */
465+
number: string;
466+
/** Related links for this ANI entry */
467+
links: string[];
468+
/** Timestamp when this entry was created (Unix timestamp in milliseconds) */
469+
createdTime: number;
470+
/** Timestamp when this entry was last updated (Unix timestamp in milliseconds) */
471+
lastUpdatedTime: number;
472+
};
473+
459474
/**
460475
* Interface representing the properties for OutdialCall component.
461476
*/
462477
export interface OutdialCallProps {
463478
/**
464479
* Function to start outdial call.
465480
*/
466-
startOutdial: (destination: string) => void;
481+
startOutdial: (destination: string, origin: string | undefined) => void;
467482

468483
/**
469-
* Array of Outdial ANI entries.
470-
* TODO: update with exported type when SDK PR#4513 is merged
484+
* Function to get a list of Outdial ANI entries.
471485
*/
472-
outdialANIEntries?: Array<{
473-
organizationId?: string;
474-
id?: string;
475-
version?: number;
476-
name: string;
477-
number: string;
478-
createdTime?: number;
479-
lastUpdatedTime?: number;
480-
}>;
486+
getOutdialANIEntries?: () => Array<OutdialAniEntry>;
481487

482488
/**
483489
* CC SDK Instance.
@@ -490,7 +496,7 @@ export interface OutdialCallProps {
490496
logger: ILogger;
491497
}
492498

493-
export type OutdialCallComponentProps = Pick<OutdialCallProps, 'startOutdial' | 'outdialANIEntries'>;
499+
export type OutdialCallComponentProps = Pick<OutdialCallProps, 'startOutdial' | 'getOutdialANIEntries'>;
494500

495501
/**
496502
* Interface representing the properties for CallControlListItem component.

packages/contact-center/cc-components/tests/components/task/CallControl/CallControlCustom/call-control-custom.util.tsx

Lines changed: 220 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -84,31 +84,243 @@ const mockQueues: ContactServiceQueue[] = [
8484
queueType: 'inbound',
8585
checkAgentAvailability: true,
8686
channelType: 'telephony',
87-
} as ContactServiceQueue,
87+
skillProfileId: 'skill1',
88+
siteId: 'site1',
89+
version: 1,
90+
isActive: true,
91+
maxWaitTime: 300,
92+
serviceLevelThreshold: 20,
93+
serviceLevelType: 'percentage',
94+
maxHandlingTime: 600,
95+
abandonedThreshold: 30,
96+
distributionPolicy: 'longest_idle',
97+
routingPolicy: 'skill_based',
98+
wrapUpTime: 60,
99+
autoAnswer: false,
100+
recordingPolicy: 'always',
101+
monitoringPolicy: 'supervisor',
102+
scriptId: 'script1',
103+
surveyId: 'survey1',
104+
outdialANI: '1234567890',
105+
outdialMethod: 'progressive',
106+
dialMode: 'preview',
107+
maxAttempts: 3,
108+
dialingOrder: 'priority',
109+
timeZoneHandling: 'agent',
110+
callbackOption: true,
111+
priority: 1,
112+
teamId: 'team1',
113+
maxActiveContacts: 10,
114+
maxTimeInQueue: 600,
115+
defaultMusicInQueueMediaFileId: 'music1',
116+
timezone: 'UTC',
117+
allowedWaitTimeMusicFiles: ['music1'],
118+
musicInQueueFileType: 'mp3',
119+
outdialRetryInterval: 300,
120+
maxQueueSize: 100,
121+
enableCallback: true,
122+
enableBusyRedial: false,
123+
busyRedialDelay: 60,
124+
createdBy: 'admin',
125+
lastModified: '2024-01-01T00:00:00Z',
126+
createdTime: '2024-01-01T00:00:00Z',
127+
lastUpdatedTime: '2024-01-01T00:00:00Z',
128+
// Additional required fields
129+
active: true,
130+
monitoringPermitted: true,
131+
parkingPermitted: true,
132+
recordingPermitted: true,
133+
transferPermitted: true,
134+
queueStatisticsEnabled: true,
135+
organizationId: 'org1',
136+
mediaTypes: ['telephony'],
137+
queuePreferences: {},
138+
capabilities: [],
139+
additionalProperties: {},
140+
} as unknown as ContactServiceQueue,
88141
{
89142
id: 'queue2',
90143
name: 'Sales Queue',
91144
description: 'Sales Queue Description',
92145
queueType: 'inbound',
93146
checkAgentAvailability: true,
94147
channelType: 'telephony',
95-
} as ContactServiceQueue,
148+
skillProfileId: 'skill2',
149+
siteId: 'site1',
150+
version: 1,
151+
isActive: true,
152+
maxWaitTime: 300,
153+
serviceLevelThreshold: 20,
154+
serviceLevelType: 'percentage',
155+
maxHandlingTime: 600,
156+
abandonedThreshold: 30,
157+
distributionPolicy: 'longest_idle',
158+
routingPolicy: 'skill_based',
159+
wrapUpTime: 60,
160+
autoAnswer: false,
161+
recordingPolicy: 'always',
162+
monitoringPolicy: 'supervisor',
163+
scriptId: 'script2',
164+
surveyId: 'survey2',
165+
outdialANI: '1234567890',
166+
outdialMethod: 'progressive',
167+
dialMode: 'preview',
168+
maxAttempts: 3,
169+
dialingOrder: 'priority',
170+
timeZoneHandling: 'agent',
171+
callbackOption: true,
172+
priority: 2,
173+
teamId: 'team1',
174+
maxActiveContacts: 10,
175+
maxTimeInQueue: 600,
176+
defaultMusicInQueueMediaFileId: 'music2',
177+
timezone: 'UTC',
178+
allowedWaitTimeMusicFiles: ['music2'],
179+
musicInQueueFileType: 'mp3',
180+
outdialRetryInterval: 300,
181+
maxQueueSize: 100,
182+
enableCallback: true,
183+
enableBusyRedial: false,
184+
busyRedialDelay: 60,
185+
createdBy: 'admin',
186+
lastModified: '2024-01-01T00:00:00Z',
187+
createdTime: '2024-01-01T00:00:00Z',
188+
lastUpdatedTime: '2024-01-01T00:00:00Z',
189+
// Additional required fields
190+
active: true,
191+
monitoringPermitted: true,
192+
parkingPermitted: true,
193+
recordingPermitted: true,
194+
transferPermitted: true,
195+
queueStatisticsEnabled: true,
196+
organizationId: 'org1',
197+
mediaTypes: ['telephony'],
198+
queuePreferences: {},
199+
capabilities: [],
200+
additionalProperties: {},
201+
} as unknown as ContactServiceQueue,
96202
{
97203
id: 'queue3',
98204
name: '',
99205
description: 'Empty Name Queue',
100206
queueType: 'inbound',
101207
checkAgentAvailability: true,
102208
channelType: 'telephony',
103-
} as ContactServiceQueue,
209+
skillProfileId: 'skill3',
210+
siteId: 'site1',
211+
version: 1,
212+
isActive: true,
213+
maxWaitTime: 300,
214+
serviceLevelThreshold: 20,
215+
serviceLevelType: 'percentage',
216+
maxHandlingTime: 600,
217+
abandonedThreshold: 30,
218+
distributionPolicy: 'longest_idle',
219+
routingPolicy: 'skill_based',
220+
wrapUpTime: 60,
221+
autoAnswer: false,
222+
recordingPolicy: 'always',
223+
monitoringPolicy: 'supervisor',
224+
scriptId: 'script3',
225+
surveyId: 'survey3',
226+
outdialANI: '1234567890',
227+
outdialMethod: 'progressive',
228+
dialMode: 'preview',
229+
maxAttempts: 3,
230+
dialingOrder: 'priority',
231+
timeZoneHandling: 'agent',
232+
callbackOption: true,
233+
priority: 3,
234+
teamId: 'team1',
235+
maxActiveContacts: 10,
236+
maxTimeInQueue: 600,
237+
defaultMusicInQueueMediaFileId: 'music3',
238+
timezone: 'UTC',
239+
allowedWaitTimeMusicFiles: ['music3'],
240+
musicInQueueFileType: 'mp3',
241+
outdialRetryInterval: 300,
242+
maxQueueSize: 100,
243+
enableCallback: true,
244+
enableBusyRedial: false,
245+
busyRedialDelay: 60,
246+
createdBy: 'admin',
247+
lastModified: '2024-01-01T00:00:00Z',
248+
createdTime: '2024-01-01T00:00:00Z',
249+
lastUpdatedTime: '2024-01-01T00:00:00Z',
250+
// Additional required fields
251+
active: true,
252+
monitoringPermitted: true,
253+
parkingPermitted: true,
254+
recordingPermitted: true,
255+
transferPermitted: true,
256+
queueStatisticsEnabled: true,
257+
organizationId: 'org1',
258+
mediaTypes: ['telephony'],
259+
queuePreferences: {},
260+
capabilities: [],
261+
additionalProperties: {},
262+
} as unknown as ContactServiceQueue,
104263
{
105264
id: '',
106265
name: 'Invalid Queue',
107266
description: 'Invalid Queue Description',
108267
queueType: 'inbound',
109268
checkAgentAvailability: true,
110269
channelType: 'telephony',
111-
} as ContactServiceQueue,
270+
skillProfileId: 'skill4',
271+
siteId: 'site1',
272+
version: 1,
273+
isActive: true,
274+
maxWaitTime: 300,
275+
serviceLevelThreshold: 20,
276+
serviceLevelType: 'percentage',
277+
maxHandlingTime: 600,
278+
abandonedThreshold: 30,
279+
distributionPolicy: 'longest_idle',
280+
routingPolicy: 'skill_based',
281+
wrapUpTime: 60,
282+
autoAnswer: false,
283+
recordingPolicy: 'always',
284+
monitoringPolicy: 'supervisor',
285+
scriptId: 'script4',
286+
surveyId: 'survey4',
287+
outdialANI: '1234567890',
288+
outdialMethod: 'progressive',
289+
dialMode: 'preview',
290+
maxAttempts: 3,
291+
dialingOrder: 'priority',
292+
timeZoneHandling: 'agent',
293+
callbackOption: true,
294+
priority: 4,
295+
teamId: 'team1',
296+
maxActiveContacts: 10,
297+
maxTimeInQueue: 600,
298+
defaultMusicInQueueMediaFileId: 'music4',
299+
timezone: 'UTC',
300+
allowedWaitTimeMusicFiles: ['music4'],
301+
musicInQueueFileType: 'mp3',
302+
outdialRetryInterval: 300,
303+
maxQueueSize: 100,
304+
enableCallback: true,
305+
enableBusyRedial: false,
306+
busyRedialDelay: 60,
307+
createdBy: 'admin',
308+
lastModified: '2024-01-01T00:00:00Z',
309+
createdTime: '2024-01-01T00:00:00Z',
310+
lastUpdatedTime: '2024-01-01T00:00:00Z',
311+
// Additional required fields
312+
active: true,
313+
monitoringPermitted: true,
314+
parkingPermitted: true,
315+
recordingPermitted: true,
316+
transferPermitted: true,
317+
queueStatisticsEnabled: true,
318+
organizationId: 'org1',
319+
mediaTypes: ['telephony'],
320+
queuePreferences: {},
321+
capabilities: [],
322+
additionalProperties: {},
323+
} as unknown as ContactServiceQueue,
112324
];
113325

114326
describe('Call Control Custom Utils', () => {
@@ -808,7 +1020,7 @@ describe('Call Control Custom Utils', () => {
8081020
queueType: 'inbound',
8091021
checkAgentAvailability: true,
8101022
channelType: 'telephony',
811-
} as ContactServiceQueue)
1023+
} as unknown as ContactServiceQueue)
8121024
).toBe(true);
8131025
});
8141026

@@ -821,7 +1033,7 @@ describe('Call Control Custom Utils', () => {
8211033
queueType: 'inbound',
8221034
checkAgentAvailability: true,
8231035
channelType: 'telephony',
824-
} as ContactServiceQueue)
1036+
} as unknown as ContactServiceQueue)
8251037
).toBeFalsy();
8261038
});
8271039

@@ -834,7 +1046,7 @@ describe('Call Control Custom Utils', () => {
8341046
queueType: 'inbound',
8351047
checkAgentAvailability: true,
8361048
channelType: 'telephony',
837-
} as ContactServiceQueue)
1049+
} as unknown as ContactServiceQueue)
8381050
).toBeFalsy();
8391051
});
8401052

@@ -847,7 +1059,7 @@ describe('Call Control Custom Utils', () => {
8471059
queueType: 'inbound',
8481060
checkAgentAvailability: true,
8491061
channelType: 'telephony',
850-
} as ContactServiceQueue)
1062+
} as unknown as ContactServiceQueue)
8511063
).toBeFalsy();
8521064
});
8531065

0 commit comments

Comments
 (0)