call-control-sdk 4.1.0 → 5.0.0

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.mjs CHANGED
@@ -20,44 +20,40 @@ var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
20
20
  var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
21
21
 
22
22
  // call-control-sdk/lib/components/callControlPanel.tsx
23
- import { useEffect as useEffect2, useState as useState5, useCallback as useCallback3 } from "react";
24
23
  import {
25
- Paper as Paper2,
26
- IconButton as IconButton2,
27
- Typography as Typography2,
28
- Menu,
29
- Box as Box2,
30
- Tooltip as Tooltip2,
31
- Fade,
32
- useTheme,
33
- Button as Button2,
34
- Chip,
35
- TextField as TextField2,
36
- ButtonGroup,
37
- MenuItem
38
- } from "@mui/material";
39
- import {
40
- PauseCircle as PauseCircle2,
41
- PlayCircle as PlayCircle2,
42
- Mic as Mic2,
43
- MicOff as MicOff2,
24
+ ArrowDropDown,
44
25
  CallEnd as CallEnd2,
45
- Groups,
26
+ Close as Close2,
46
27
  DragIndicator,
47
- WifiCalling3,
28
+ Group,
29
+ History,
48
30
  Layers,
49
- Phone,
50
- Close as Close2,
31
+ Mic as Mic2,
32
+ MicOff as MicOff2,
33
+ Pause as Pause2,
51
34
  Pending,
52
- Upcoming,
53
- ArrowDropDown,
35
+ Phone,
36
+ PlayArrow as PlayArrow2,
54
37
  SupportAgent as SupportAgent2,
55
- Tty,
56
- TransferWithinAStation
38
+ TransferWithinAStation,
39
+ Upcoming,
40
+ WifiCalling3
57
41
  } from "@mui/icons-material";
58
-
59
- // call-control-sdk/lib/hooks/useSDKState.ts
60
- import { useState, useEffect } from "react";
42
+ import {
43
+ Box as Box2,
44
+ Button as Button2,
45
+ Chip,
46
+ Fade,
47
+ IconButton as IconButton2,
48
+ Menu,
49
+ MenuItem,
50
+ Paper as Paper2,
51
+ TextField as TextField2,
52
+ Tooltip as Tooltip2,
53
+ Typography as Typography2,
54
+ useTheme as useTheme3
55
+ } from "@mui/material";
56
+ import { useCallback as useCallback3, useEffect as useEffect3, useRef as useRef2, useState as useState5 } from "react";
61
57
 
62
58
  // call-control-sdk/lib/hooks/sdk-state.ts
63
59
  var SDKStateManager = class {
@@ -71,6 +67,7 @@ var SDKStateManager = class {
71
67
  getInitialState() {
72
68
  return {
73
69
  apiKey: null,
70
+ process: null,
74
71
  agentId: "",
75
72
  isInitialized: false,
76
73
  isHolding: false,
@@ -80,9 +77,11 @@ var SDKStateManager = class {
80
77
  controlPanelPosition: { x: 10, y: 10 },
81
78
  iframePosition: { x: 10, y: 80 },
82
79
  callData: {
83
- mobileNumber: "",
84
- callReferenceId: "",
85
- agentLoginId: ""
80
+ agent_id: "",
81
+ status: "",
82
+ type: "",
83
+ event_time: "",
84
+ phone_number: ""
86
85
  },
87
86
  conferenceLine: [
88
87
  {
@@ -92,7 +91,8 @@ var SDKStateManager = class {
92
91
  phone: "",
93
92
  isMute: false,
94
93
  isHold: false,
95
- isCallStart: false
94
+ isCallStart: false,
95
+ isMergeCall: false
96
96
  },
97
97
  {
98
98
  line: 2,
@@ -101,7 +101,8 @@ var SDKStateManager = class {
101
101
  phone: "",
102
102
  isMute: false,
103
103
  isHold: false,
104
- isCallStart: false
104
+ isCallStart: false,
105
+ isMergeCall: false
105
106
  },
106
107
  {
107
108
  line: 3,
@@ -110,7 +111,8 @@ var SDKStateManager = class {
110
111
  phone: "",
111
112
  isMute: false,
112
113
  isHold: false,
113
- isCallStart: false
114
+ isCallStart: false,
115
+ isMergeCall: false
114
116
  },
115
117
  {
116
118
  line: 4,
@@ -119,7 +121,8 @@ var SDKStateManager = class {
119
121
  phone: "",
120
122
  isMute: false,
121
123
  isHold: false,
122
- isCallStart: false
124
+ isCallStart: false,
125
+ isMergeCall: false
123
126
  },
124
127
  {
125
128
  line: 5,
@@ -128,7 +131,8 @@ var SDKStateManager = class {
128
131
  phone: "",
129
132
  isMute: false,
130
133
  isHold: false,
131
- isCallStart: false
134
+ isCallStart: false,
135
+ isMergeCall: false
132
136
  }
133
137
  ]
134
138
  };
@@ -141,6 +145,7 @@ var SDKStateManager = class {
141
145
  this.state = __spreadProps(__spreadValues({}, this.state), {
142
146
  apiKey: parsedState.apiKey || "",
143
147
  agentId: parsedState.agentId || "",
148
+ process: parsedState.process || null,
144
149
  isInitialized: parsedState.isInitialized || false,
145
150
  isHolding: parsedState.isHolding || false,
146
151
  isMuted: parsedState.isMuted || false,
@@ -156,7 +161,8 @@ var SDKStateManager = class {
156
161
  callReferenceId: "",
157
162
  agentLoginId: ""
158
163
  },
159
- conferenceLine: parsedState.conferenceLine || []
164
+ // Fix: Properly handle conferenceLine with fallback to initial state
165
+ conferenceLine: parsedState.conferenceLine && Array.isArray(parsedState.conferenceLine) && parsedState.conferenceLine.length > 0 ? parsedState.conferenceLine : this.state.conferenceLine
160
166
  });
161
167
  }
162
168
  } catch (error) {
@@ -168,6 +174,7 @@ var SDKStateManager = class {
168
174
  const persistentState = {
169
175
  apiKey: this.state.apiKey,
170
176
  agentId: this.state.agentId,
177
+ process: this.state.process,
171
178
  isInitialized: this.state.isInitialized,
172
179
  isHolding: this.state.isHolding,
173
180
  isMuted: this.state.isMuted,
@@ -223,6 +230,11 @@ var SDKStateManager = class {
223
230
  this.saveToStorage();
224
231
  this.notifyListeners();
225
232
  }
233
+ setProcess(process) {
234
+ this.state.process = process;
235
+ this.saveToStorage();
236
+ this.notifyListeners();
237
+ }
226
238
  setControlPanelPosition(position) {
227
239
  this.state.controlPanelPosition = position;
228
240
  this.saveToStorage();
@@ -249,47 +261,64 @@ var SDKStateManager = class {
249
261
  }
250
262
  updateCallData(data) {
251
263
  this.state.callData = __spreadValues(__spreadValues({}, this.state.callData), data);
264
+ this.saveToStorage();
252
265
  this.notifyListeners();
253
266
  }
254
267
  setConferenceLine(line) {
255
268
  var _a;
256
- const conferenceLineData = (_a = this.state.conferenceLine) == null ? void 0 : _a.map(
257
- (each) => {
258
- if (each.line === line.line) {
259
- return line;
260
- }
261
- return each;
269
+ if (!this.state.conferenceLine || !Array.isArray(this.state.conferenceLine)) {
270
+ console.warn("Conference line data corrupted, resetting to initial state");
271
+ this.state.conferenceLine = this.getInitialState().conferenceLine;
272
+ }
273
+ const conferenceLineData = (_a = this.state.conferenceLine) == null ? void 0 : _a.map((each) => {
274
+ if (each.line === line.line) {
275
+ return line;
262
276
  }
263
- );
277
+ return each;
278
+ });
264
279
  this.state.conferenceLine = conferenceLineData;
265
280
  this.saveToStorage();
266
281
  this.notifyListeners();
267
282
  }
283
+ resetConferenceLines() {
284
+ this.state.conferenceLine = this.getInitialState().conferenceLine;
285
+ this.saveToStorage();
286
+ this.notifyListeners();
287
+ }
288
+ clearStorageAndReset() {
289
+ try {
290
+ localStorage.removeItem(this.STORAGE_KEY);
291
+ this.state = this.getInitialState();
292
+ this.notifyListeners();
293
+ } catch (error) {
294
+ console.warn("Failed to clear localStorage:", error);
295
+ }
296
+ }
297
+ // Debug methods
298
+ debugStorage() {
299
+ try {
300
+ const stored = localStorage.getItem(this.STORAGE_KEY);
301
+ console.log("Current localStorage data:", stored);
302
+ if (stored) {
303
+ console.log("Parsed localStorage data:", JSON.parse(stored));
304
+ }
305
+ console.log("Current state:", this.state);
306
+ } catch (error) {
307
+ console.error("Error debugging storage:", error);
308
+ }
309
+ }
310
+ getConferenceLines() {
311
+ return this.state.conferenceLine || [];
312
+ }
268
313
  };
269
314
  var sdkStateManager = new SDKStateManager();
270
315
 
271
- // call-control-sdk/lib/hooks/useSDKState.ts
272
- function useSDKState() {
273
- const [state, setState] = useState(sdkStateManager.getState());
274
- useEffect(() => {
275
- const unsubscribe = sdkStateManager.subscribe(() => {
276
- setState(sdkStateManager.getState());
277
- });
278
- return unsubscribe;
279
- }, []);
280
- return state;
281
- }
282
-
283
316
  // call-control-sdk/lib/hooks/useDraggable.ts
284
- import {
285
- useState as useState2,
286
- useRef,
287
- useCallback
288
- } from "react";
317
+ import { useCallback, useRef, useState } from "react";
289
318
  function useDraggable(initialPosition, onPositionChange) {
290
- const [position, setPosition] = useState2(initialPosition);
291
- const [isDragging, setIsDragging] = useState2(false);
292
- const dragRef = useRef(null);
319
+ const [position, setPosition] = useState(initialPosition);
320
+ const [isDragging, setIsDragging] = useState(false);
321
+ const dragRef = useRef();
293
322
  const dragStart = useRef({ x: 0, y: 0 });
294
323
  const elementStart = useRef({ x: 0, y: 0 });
295
324
  const updatePosition = useCallback(
@@ -374,14 +403,22 @@ function useDraggable(initialPosition, onPositionChange) {
374
403
  };
375
404
  }
376
405
 
377
- // call-control-sdk/lib/services/request.ts
378
- import { useCallback as useCallback2, useReducer } from "react";
379
-
380
- // call-control-sdk/lib/services/axios.ts
381
- import axios from "axios";
406
+ // call-control-sdk/lib/hooks/useSDKState.ts
407
+ import { useState as useState2, useEffect } from "react";
408
+ function useSDKState() {
409
+ const [state, setState] = useState2(sdkStateManager.getState());
410
+ useEffect(() => {
411
+ const unsubscribe = sdkStateManager.subscribe(() => {
412
+ setState(sdkStateManager.getState());
413
+ });
414
+ return unsubscribe;
415
+ }, []);
416
+ return state;
417
+ }
382
418
 
383
419
  // call-control-sdk/lib/services/endPoint.ts
384
420
  var BASE_URL = "http://192.168.100.143:8095";
421
+ var WS_BASE_URL = "ws://192.168.100.143:8095";
385
422
  var VERSION = {
386
423
  v1: "/api/v1"
387
424
  };
@@ -394,15 +431,26 @@ var END_POINT = {
394
431
  MUTE_CALL: `${BASE_URL}${VERSION.v1}/cti/mute-call?provider=convox`,
395
432
  UNMUTE_CALL: `${BASE_URL}${VERSION.v1}/cti/unmute-call?provider=convox`,
396
433
  END_CALL: `${BASE_URL}${VERSION.v1}/cti/end-call?provider=convox`,
397
- LOGOUT: `${BASE_URL}${VERSION.v1}/cti//logout?provider=convox`,
434
+ LOGOUT: `${BASE_URL}${VERSION.v1}/cti/logout?provider=convox`,
398
435
  CONFERENCE_CALL: `${BASE_URL}${VERSION.v1}/cti/conference-call?provider=convox`,
399
436
  CONFERENCE_CALL_HOLD_OR_UN_HOLD: `${BASE_URL}${VERSION.v1}/cti/conference-call/hold-unhold?provider=convox`,
400
437
  CONFERENCE_CALL_MUTE_OT_UN_MUTE: `${BASE_URL}${VERSION.v1}/cti/conference-call/mute-unmute?provider=convox`,
401
438
  CONFERENCE_CALL_END: `${BASE_URL}${VERSION.v1}/cti/conference-call/hangup?provider=convox`,
402
- TRANSFER_CALL: `${BASE_URL}${VERSION.v1}/cti/transfer?provider=convox`
439
+ CONFERENCE_CALL_END_ALL: `${BASE_URL}${VERSION.v1}/cti/conference-call/hangup-all-call?provider=convox`,
440
+ TRANSFER_CALL: `${BASE_URL}${VERSION.v1}/cti/transfer?provider=convox`,
441
+ AGENTS_LIST: `${BASE_URL}${VERSION.v1}/cti/users`,
442
+ PROCESS_LIST: `${BASE_URL}${VERSION.v1}/cti/processes-list`,
443
+ TRANSFER_TO_DETAILS: `${BASE_URL}${VERSION.v1}/cti/trasnfer-to-details?provider=convox`
444
+ };
445
+ var WS_END_POINT = {
446
+ WS: `${WS_BASE_URL}${VERSION.v1}/cti/ws`
403
447
  };
404
448
 
449
+ // call-control-sdk/lib/services/request.ts
450
+ import { useCallback as useCallback2, useReducer } from "react";
451
+
405
452
  // call-control-sdk/lib/services/axios.ts
453
+ import axios from "axios";
406
454
  var token = "12345";
407
455
  var axiosInstance = axios.create({
408
456
  baseURL: BASE_URL,
@@ -532,21 +580,11 @@ var usePostRequest = (props = {}) => {
532
580
  payload: true
533
581
  });
534
582
  axios_default.post(url, payload, config).then((res) => {
535
- var _a, _b;
536
- if ((_a = res.data) == null ? void 0 : _a.success) {
537
- dispatch({
538
- type: "isSuccess",
539
- payload: res.data
540
- });
541
- onSuccess == null ? void 0 : onSuccess(res.data, payload);
542
- } else {
543
- dispatch({
544
- type: "isError",
545
- payload: res.data
546
- });
547
- showToast((_b = res.data) == null ? void 0 : _b.message, "error");
548
- onError == null ? void 0 : onError(res.data, payload);
549
- }
583
+ dispatch({
584
+ type: "isSuccess",
585
+ payload: res.data
586
+ });
587
+ onSuccess == null ? void 0 : onSuccess(res.data, payload);
550
588
  }).catch((err) => {
551
589
  var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l;
552
590
  const error = {
@@ -582,13 +620,11 @@ import {
582
620
  CallEnd,
583
621
  CallSplit,
584
622
  Close,
585
- Group,
586
- Logout,
587
623
  Mic,
588
624
  MicOff,
589
- PauseCircle,
625
+ Pause,
590
626
  PhoneDisabled,
591
- PlayCircle,
627
+ PlayArrow,
592
628
  SupportAgent
593
629
  } from "@mui/icons-material";
594
630
  import {
@@ -597,31 +633,191 @@ import {
597
633
  Dialog,
598
634
  IconButton,
599
635
  Paper,
600
- Radio,
601
- Stack,
602
636
  TextField,
603
637
  Typography,
604
638
  Autocomplete,
605
639
  Grid,
606
- Tooltip
640
+ Tooltip,
641
+ useTheme as useTheme2
607
642
  } from "@mui/material";
608
- import { useState as useState4 } from "react";
643
+ import { useEffect as useEffect2, useState as useState4 } from "react";
644
+
645
+ // call-control-sdk/lib/components/styles.ts
646
+ import { useTheme } from "@mui/material";
647
+ var useMyStyles = () => {
648
+ const theme = useTheme();
649
+ return {
650
+ disabled: {
651
+ padding: "0px",
652
+ margin: "0px",
653
+ minWidth: "40px !important",
654
+ borderRadius: "16px",
655
+ border: `1px solid rgb(206, 204, 204)`,
656
+ height: "40px",
657
+ "&:hover": {
658
+ boxShadow: " 0px 2px 2px rgba(0, 0, 0, 0.79)",
659
+ border: `1px solid ${theme.palette.primary.main}`
660
+ },
661
+ "&:active": {
662
+ bgcolor: "primary.main",
663
+ boxShadow: `inset 1px -2px 4px ${theme.palette.primary.light}`
664
+ }
665
+ },
666
+ enabled: {
667
+ padding: "0px",
668
+ margin: "0px",
669
+ minWidth: "40px !important",
670
+ borderRadius: "16px",
671
+ boxShadow: " 0px 2px 1px rgba(0, 0, 0, 0.507)",
672
+ border: `1px solid ${theme.palette.primary.main}`,
673
+ height: "40px",
674
+ "&:hover": {
675
+ boxShadow: " 0px 2px 1px rgba(0, 0, 0, 0.507)",
676
+ border: `1px solid ${theme.palette.primary.main}`
677
+ },
678
+ "&:active": {
679
+ bgcolor: "primary.main",
680
+ boxShadow: `inset 1px -2px 4px ${theme.palette.primary.light}`
681
+ }
682
+ },
683
+ outlined: {
684
+ padding: "0px",
685
+ margin: "0px",
686
+ minWidth: "40px !important",
687
+ borderRadius: "16px",
688
+ backgroundColor: theme.palette.grey[200],
689
+ boxShadow: `0px 2px 1px ${theme.palette.primary.light}`,
690
+ border: `0px solid ${theme.palette.primary.main}`,
691
+ height: "40px",
692
+ "&:hover": {
693
+ boxShadow: `0px 2px 1px ${theme.palette.primary.main}`,
694
+ border: `0px solid ${theme.palette.primary.main}`
695
+ },
696
+ "&:active": {
697
+ bgcolor: "primary.main",
698
+ boxShadow: `inset 1px -2px 4px ${theme.palette.primary.light}`
699
+ }
700
+ }
701
+ };
702
+ };
703
+ var styles_default = useMyStyles;
704
+
705
+ // call-control-sdk/lib/components/dialog.tsx
609
706
  import { Fragment, jsx as jsx2, jsxs } from "react/jsx-runtime";
610
- function ConferenceDialog({
611
- onConference,
612
- onExit,
613
- onEndAllCalls,
614
- open,
615
- setOpen
616
- }) {
707
+ function ConferenceDialog({ open, setOpen }) {
617
708
  var _a, _b;
618
709
  const state = useSDKState();
710
+ const { disabled, enabled, outlined } = styles_default();
711
+ const theme = useTheme2();
619
712
  const handleClose = () => {
620
713
  setOpen(false);
621
714
  };
622
715
  const onConferenceLineUpdate = (line, data) => {
623
716
  sdkStateManager.setConferenceLine(__spreadValues(__spreadValues({}, line), data));
624
717
  };
718
+ const onConferenceCallStart = (line, data) => {
719
+ var _a2, _b2, _c, _d;
720
+ const line_used = __spreadValues(__spreadValues({}, line), data);
721
+ const payload = {
722
+ action: "EXTERNAL_CONFERENCE",
723
+ operation: `CALL${line_used.line}`,
724
+ line_used: String(line_used.line),
725
+ thirdparty_no: line_used.phone,
726
+ userid: (_b2 = (_a2 = state.callData) == null ? void 0 : _a2.agent_id) != null ? _b2 : "",
727
+ process: (_d = (_c = state.callData) == null ? void 0 : _c.process_name) != null ? _d : ""
728
+ };
729
+ axios_default.post(END_POINT.CONFERENCE_CALL, payload).then(() => {
730
+ sdkStateManager.setConferenceLine(__spreadValues(__spreadValues({}, line), data));
731
+ });
732
+ };
733
+ const onMergeConferenceCall = (line, data) => {
734
+ var _a2, _b2, _c, _d;
735
+ const line_used = __spreadValues(__spreadValues({}, line), data);
736
+ const payload = {
737
+ action: "EXTERNAL_CONFERENCE",
738
+ operation: `CONFERENCE`,
739
+ line_used: String(line_used.line),
740
+ thirdparty_no: line_used.phone,
741
+ userid: (_b2 = (_a2 = state.callData) == null ? void 0 : _a2.agent_id) != null ? _b2 : "",
742
+ process: (_d = (_c = state.callData) == null ? void 0 : _c.process_name) != null ? _d : ""
743
+ };
744
+ axios_default.post(END_POINT.CONFERENCE_CALL, payload).then(() => {
745
+ sdkStateManager.setConferenceLine(__spreadValues(__spreadValues({}, line), data));
746
+ });
747
+ };
748
+ const onHoldOrUnHoldConferenceCall = (line, data, type) => {
749
+ var _a2, _b2, _c, _d;
750
+ const line_used = __spreadValues(__spreadValues({}, line), data);
751
+ const payload = {
752
+ action: "EXTERNAL_CONFERENCE",
753
+ operation: type,
754
+ hold_channel_no: type === "HOLDUSER" ? `hold${line_used.line}` : `unhold${line_used.line}`,
755
+ // Change the line according where u intiated firstly
756
+ userid: (_b2 = (_a2 = state.callData) == null ? void 0 : _a2.agent_id) != null ? _b2 : "",
757
+ process: (_d = (_c = state.callData) == null ? void 0 : _c.process_name) != null ? _d : ""
758
+ };
759
+ axios_default.post(END_POINT.CONFERENCE_CALL_HOLD_OR_UN_HOLD, payload).then(() => {
760
+ sdkStateManager.setConferenceLine(__spreadValues(__spreadValues({}, line), data));
761
+ });
762
+ };
763
+ const onMuteOrUnMuteConferenceCall = (line, data, type) => {
764
+ var _a2, _b2, _c, _d;
765
+ const line_used = __spreadValues(__spreadValues({}, line), data);
766
+ const payload = {
767
+ action: "EXTERNAL_CONFERENCE",
768
+ operation: type,
769
+ channel_no: type === "MUTEUSER" ? `mute${line_used.line}` : `play${line_used.line}`,
770
+ userid: (_b2 = (_a2 = state.callData) == null ? void 0 : _a2.agent_id) != null ? _b2 : "",
771
+ thirdparty_no: line_used.phone,
772
+ process: (_d = (_c = state.callData) == null ? void 0 : _c.process_name) != null ? _d : ""
773
+ };
774
+ axios_default.post(END_POINT.CONFERENCE_CALL_MUTE_OT_UN_MUTE, payload).then(() => {
775
+ sdkStateManager.setConferenceLine(__spreadValues(__spreadValues({}, line), data));
776
+ });
777
+ };
778
+ const onEndConferenceCall = (line, data) => {
779
+ var _a2, _b2, _c, _d;
780
+ const line_used = __spreadValues(__spreadValues({}, line), data);
781
+ const payload = {
782
+ action: "EXTERNAL_CONFERENCE",
783
+ operation: "HANGUP_CHANNEL",
784
+ line_used: String(line_used.line - 1),
785
+ user_type: `THIRDPARTY${line_used.line - 1}`,
786
+ thirdparty_no: line_used.phone,
787
+ userid: (_b2 = (_a2 = state.callData) == null ? void 0 : _a2.agent_id) != null ? _b2 : "",
788
+ process: (_d = (_c = state.callData) == null ? void 0 : _c.process_name) != null ? _d : ""
789
+ };
790
+ axios_default.post(END_POINT.CONFERENCE_CALL_END, payload).then(() => {
791
+ sdkStateManager.setConferenceLine(__spreadValues(__spreadValues({}, line), data));
792
+ });
793
+ };
794
+ const onEndAllConferenceCalls = () => {
795
+ var _a2, _b2, _c, _d;
796
+ const payload = {
797
+ action: "EXTERNAL_CONFERENCE",
798
+ operation: "ENDCONFERENCE",
799
+ userid: (_b2 = (_a2 = state.callData) == null ? void 0 : _a2.agent_id) != null ? _b2 : "",
800
+ process: (_d = (_c = state.callData) == null ? void 0 : _c.process_name) != null ? _d : ""
801
+ };
802
+ axios_default.post(END_POINT.CONFERENCE_CALL_END_ALL, payload).then(() => {
803
+ sdkStateManager.resetConferenceLines();
804
+ handleClose();
805
+ });
806
+ };
807
+ useEffect2(() => {
808
+ var _a2, _b2, _c, _d;
809
+ const obj = {
810
+ line: 1,
811
+ status: (_b2 = (_a2 = state.callData) == null ? void 0 : _a2.status) != null ? _b2 : "",
812
+ type: "internal",
813
+ phone: (_d = (_c = state.callData) == null ? void 0 : _c.phone_number) != null ? _d : "",
814
+ isMute: false,
815
+ isHold: false,
816
+ isMergeCall: false,
817
+ isCallStart: true
818
+ };
819
+ sdkStateManager.setConferenceLine(obj);
820
+ }, []);
625
821
  return /* @__PURE__ */ jsx2(Fragment, { children: /* @__PURE__ */ jsx2(
626
822
  Dialog,
627
823
  {
@@ -649,65 +845,12 @@ function ConferenceDialog({
649
845
  ]
650
846
  }
651
847
  ),
652
- /* @__PURE__ */ jsx2(
653
- Stack,
654
- {
655
- direction: "row",
656
- alignItems: "center",
657
- justifyContent: "flex-end",
658
- mr: 2,
659
- children: /* @__PURE__ */ jsxs(
660
- Stack,
661
- {
662
- display: "flex",
663
- direction: "row",
664
- alignItems: "center",
665
- justifyContent: "center",
666
- spacing: 1,
667
- children: [
668
- /* @__PURE__ */ jsxs(
669
- Button,
670
- {
671
- variant: "contained",
672
- color: "success",
673
- onClick: onConference,
674
- sx: {
675
- borderRadius: "10px",
676
- textTransform: "capitalize"
677
- },
678
- children: [
679
- /* @__PURE__ */ jsx2(Group, { sx: { px: 0.5 } }),
680
- "Conference"
681
- ]
682
- }
683
- ),
684
- /* @__PURE__ */ jsxs(
685
- Button,
686
- {
687
- variant: "contained",
688
- color: "error",
689
- onClick: onExit,
690
- sx: {
691
- borderRadius: "10px",
692
- textTransform: "capitalize"
693
- },
694
- children: [
695
- /* @__PURE__ */ jsx2(Logout, { sx: { px: 0.5 } }),
696
- "Exit Conference"
697
- ]
698
- }
699
- )
700
- ]
701
- }
702
- )
703
- }
704
- ),
705
848
  /* @__PURE__ */ jsx2(
706
849
  Box,
707
850
  {
708
851
  sx: {
709
852
  boxShadow: "0px 1px 2px #e7e5e5ff",
710
- padding: "6px",
853
+ padding: "2px 6px",
711
854
  margin: "0px 10px",
712
855
  borderRadius: "20px"
713
856
  },
@@ -755,36 +898,14 @@ function ConferenceDialog({
755
898
  children: (_b2 = each == null ? void 0 : each.status) != null ? _b2 : ""
756
899
  }
757
900
  ),
758
- /* @__PURE__ */ jsxs(
759
- Button,
760
- {
761
- sx: {
762
- textTransform: "capitalize"
763
- },
764
- size: "small",
765
- onClick: () => {
766
- onConferenceLineUpdate(each, { type: "internal" });
767
- },
768
- children: [
769
- /* @__PURE__ */ jsx2(Radio, { checked: (each == null ? void 0 : each.type) === "internal" }),
770
- /* @__PURE__ */ jsx2(Typography, { variant: "body2", children: "Internal" })
771
- ]
772
- }
773
- ),
774
- /* @__PURE__ */ jsxs(
901
+ /* @__PURE__ */ jsx2(
775
902
  Button,
776
903
  {
777
904
  sx: {
778
905
  textTransform: "capitalize"
779
906
  },
780
907
  size: "small",
781
- onClick: () => {
782
- onConferenceLineUpdate(each, { type: "external" });
783
- },
784
- children: [
785
- /* @__PURE__ */ jsx2(Radio, { checked: each.type === "external" }),
786
- /* @__PURE__ */ jsx2(Typography, { variant: "body2", children: "External" })
787
- ]
908
+ children: /* @__PURE__ */ jsx2(Typography, { variant: "body2", children: (each == null ? void 0 : each.line) === 1 ? "Internal" : "External" })
788
909
  }
789
910
  ),
790
911
  /* @__PURE__ */ jsx2(
@@ -793,90 +914,129 @@ function ConferenceDialog({
793
914
  size: "small",
794
915
  placeholder: "Phone Number",
795
916
  value: (each == null ? void 0 : each.phone) || "",
917
+ disabled: (each == null ? void 0 : each.line) === 1,
796
918
  onChange: (e) => {
797
919
  onConferenceLineUpdate(each, { phone: e.target.value });
798
920
  }
799
921
  }
800
922
  ),
801
923
  /* @__PURE__ */ jsx2(Tooltip, { title: "Call", children: /* @__PURE__ */ jsx2(
802
- IconButton,
924
+ Button,
803
925
  {
926
+ variant: (each == null ? void 0 : each.isCallStart) ? "outlined" : "contained",
804
927
  color: "success",
805
- sx: {
806
- bgcolor: "action.hover",
807
- "&:hover": { bgcolor: "action.selected" }
808
- },
928
+ sx: (each == null ? void 0 : each.isCallStart) ? __spreadValues({}, disabled) : __spreadProps(__spreadValues({}, enabled), {
929
+ border: `0px solid ${theme.palette.success.light}`,
930
+ "&:hover": {
931
+ bgcolor: "error.light",
932
+ boxShadow: `0px 2px 1px ${theme.palette.success.light}`,
933
+ border: `0px solid ${theme.palette.success.light}`
934
+ },
935
+ "&:active": {
936
+ bgcolor: "error.light",
937
+ boxShadow: `inset 1px -2px 4px ${theme.palette.primary.light}`
938
+ }
939
+ }),
809
940
  onClick: () => {
810
- onConferenceLineUpdate(each, {
941
+ onConferenceCallStart(each, {
811
942
  isCallStart: true,
812
- status: "ON CALL"
943
+ status: "ONCALL"
813
944
  });
814
945
  },
815
946
  disabled: each == null ? void 0 : each.isCallStart,
816
- children: /* @__PURE__ */ jsx2(Call, {})
947
+ children: /* @__PURE__ */ jsx2(
948
+ Call,
949
+ {
950
+ sx: { color: (each == null ? void 0 : each.isCallStart) ? "defalult" : "#fff" }
951
+ }
952
+ )
817
953
  }
818
954
  ) }),
819
955
  /* @__PURE__ */ jsx2(Tooltip, { title: "Merge Call", children: /* @__PURE__ */ jsx2(
820
- IconButton,
956
+ Button,
821
957
  {
822
- color: "info",
823
- sx: {
824
- bgcolor: "action.hover",
825
- "&:hover": { bgcolor: "action.selected" }
958
+ variant: (each == null ? void 0 : each.isMergeCall) ? "contained" : "outlined",
959
+ sx: (each == null ? void 0 : each.isMergeCall) && (each == null ? void 0 : each.isCallStart) ? __spreadValues({}, disabled) : (each == null ? void 0 : each.isCallStart) ? __spreadValues({}, outlined) : __spreadValues({}, disabled),
960
+ onClick: () => {
961
+ onMergeConferenceCall(each, {
962
+ isMergeCall: true,
963
+ status: "ONCALL"
964
+ });
826
965
  },
827
966
  disabled: !(each == null ? void 0 : each.isCallStart),
828
967
  children: /* @__PURE__ */ jsx2(CallSplit, {})
829
968
  }
830
969
  ) }),
831
970
  /* @__PURE__ */ jsx2(Tooltip, { title: each.isHold ? "Hold" : "Un Hold", children: /* @__PURE__ */ jsx2(
832
- IconButton,
971
+ Button,
833
972
  {
834
- color: each.isHold ? "warning" : "info",
835
- sx: {
836
- bgcolor: "action.hover",
837
- "&:hover": { bgcolor: "action.selected" }
838
- },
973
+ variant: (each == null ? void 0 : each.isHold) ? "contained" : "outlined",
974
+ sx: (each == null ? void 0 : each.isHold) && (each == null ? void 0 : each.isCallStart) ? __spreadValues({}, disabled) : (each == null ? void 0 : each.isCallStart) ? __spreadValues({}, outlined) : __spreadValues({}, disabled),
839
975
  onClick: () => {
840
976
  if (each.isHold) {
841
- onConferenceLineUpdate(each, { isHold: false });
977
+ onHoldOrUnHoldConferenceCall(
978
+ each,
979
+ { isHold: false },
980
+ "UNHOLDUSER"
981
+ );
842
982
  } else {
843
- onConferenceLineUpdate(each, { isHold: true });
983
+ onHoldOrUnHoldConferenceCall(
984
+ each,
985
+ { isHold: true },
986
+ "HOLDUSER"
987
+ );
844
988
  }
845
989
  },
846
990
  disabled: !(each == null ? void 0 : each.isCallStart),
847
- children: each.isHold ? /* @__PURE__ */ jsx2(PlayCircle, {}) : /* @__PURE__ */ jsx2(PauseCircle, {})
991
+ children: each.isHold ? /* @__PURE__ */ jsx2(PlayArrow, {}) : /* @__PURE__ */ jsx2(Pause, {})
848
992
  }
849
993
  ) }),
850
994
  /* @__PURE__ */ jsx2(Tooltip, { title: each.isMute ? "Mute" : "Un Mute", children: /* @__PURE__ */ jsx2(
851
- IconButton,
995
+ Button,
852
996
  {
853
- color: each.isMute ? "error" : "info",
854
- sx: {
855
- bgcolor: "action.hover",
856
- "&:hover": { bgcolor: "action.selected" }
857
- },
997
+ variant: (each == null ? void 0 : each.isMute) ? "contained" : "outlined",
998
+ sx: (each == null ? void 0 : each.isMute) && (each == null ? void 0 : each.isCallStart) ? __spreadValues({}, disabled) : (each == null ? void 0 : each.isCallStart) ? __spreadValues({}, outlined) : __spreadValues({}, disabled),
858
999
  onClick: () => {
859
1000
  if (each.isMute) {
860
- onConferenceLineUpdate(each, { isMute: false });
1001
+ onMuteOrUnMuteConferenceCall(
1002
+ each,
1003
+ { isMute: false },
1004
+ "PLAYUSER"
1005
+ );
861
1006
  } else {
862
- onConferenceLineUpdate(each, { isMute: true });
1007
+ onMuteOrUnMuteConferenceCall(
1008
+ each,
1009
+ { isMute: true },
1010
+ "MUTEUSER"
1011
+ );
863
1012
  }
864
1013
  },
865
1014
  disabled: !(each == null ? void 0 : each.isCallStart),
866
1015
  children: each.isMute ? /* @__PURE__ */ jsx2(MicOff, {}) : /* @__PURE__ */ jsx2(Mic, {})
867
1016
  }
868
1017
  ) }),
869
- /* @__PURE__ */ jsx2(Tooltip, { title: "End Call", children: /* @__PURE__ */ jsx2(
870
- IconButton,
1018
+ /* @__PURE__ */ jsx2(Tooltip, { title: "End Call", children: (each == null ? void 0 : each.line) !== 1 ? /* @__PURE__ */ jsx2(
1019
+ Button,
871
1020
  {
1021
+ variant: (each == null ? void 0 : each.isCallStart) ? "contained" : "outlined",
872
1022
  color: "error",
873
- sx: {
874
- bgcolor: "action.hover",
875
- "&:hover": { bgcolor: "action.selected" }
876
- },
1023
+ sx: (each == null ? void 0 : each.isCallStart) ? __spreadProps(__spreadValues({}, enabled), {
1024
+ minWidth: "60px !important",
1025
+ border: `0px solid ${theme.palette.error.light}`,
1026
+ "&:hover": {
1027
+ bgcolor: "error.light",
1028
+ boxShadow: `0px 2px 1px ${theme.palette.error.light}`,
1029
+ border: `0px solid ${theme.palette.error.light}`
1030
+ },
1031
+ "&:active": {
1032
+ bgcolor: "error.light",
1033
+ boxShadow: `inset 1px -2px 4px ${theme.palette.primary.light}`
1034
+ }
1035
+ }) : __spreadProps(__spreadValues({}, disabled), { minWidth: "60px !important" }),
877
1036
  onClick: () => {
878
- onConferenceLineUpdate(each, {
1037
+ onEndConferenceCall(each, {
879
1038
  isCallStart: false,
1039
+ isMergeCall: false,
880
1040
  isMute: false,
881
1041
  isHold: false,
882
1042
  status: "IDLE"
@@ -885,6 +1045,33 @@ function ConferenceDialog({
885
1045
  disabled: !(each == null ? void 0 : each.isCallStart),
886
1046
  children: /* @__PURE__ */ jsx2(CallEnd, {})
887
1047
  }
1048
+ ) : /* @__PURE__ */ jsx2(
1049
+ Button,
1050
+ {
1051
+ variant: (each == null ? void 0 : each.isCallStart) ? "contained" : "outlined",
1052
+ sx: __spreadProps(__spreadValues({}, disabled), {
1053
+ visibility: "hidden",
1054
+ minWidth: "60px !important"
1055
+ }),
1056
+ onClick: () => {
1057
+ onEndConferenceCall(each, {
1058
+ isCallStart: false,
1059
+ isMergeCall: false,
1060
+ isMute: false,
1061
+ isHold: false,
1062
+ status: "IDLE"
1063
+ });
1064
+ },
1065
+ disabled: !(each == null ? void 0 : each.isCallStart),
1066
+ children: /* @__PURE__ */ jsx2(Typography, { children: /* @__PURE__ */ jsx2(
1067
+ CallEnd,
1068
+ {
1069
+ sx: {
1070
+ visibility: "hidden"
1071
+ }
1072
+ }
1073
+ ) })
1074
+ }
888
1075
  ) })
889
1076
  ]
890
1077
  },
@@ -899,7 +1086,7 @@ function ConferenceDialog({
899
1086
  variant: "outlined",
900
1087
  color: "error",
901
1088
  size: "large",
902
- onClick: onEndAllCalls,
1089
+ onClick: onEndAllConferenceCalls,
903
1090
  sx: { px: 2, borderRadius: "20px", textTransform: "capitalize" },
904
1091
  children: [
905
1092
  /* @__PURE__ */ jsx2(
@@ -934,7 +1121,7 @@ function ConferenceDialog({
934
1121
  )
935
1122
  }
936
1123
  ),
937
- "End Calls"
1124
+ "End Conference"
938
1125
  ]
939
1126
  }
940
1127
  ) })
@@ -943,42 +1130,79 @@ function ConferenceDialog({
943
1130
  ) });
944
1131
  }
945
1132
  function CallTransferDialog({ open, setOpen }) {
946
- const [transferCall] = usePostRequest();
947
- const agentList = [
948
- { name: "agent_ravi", status: "IDLE" },
949
- { name: "rajesh", status: "IDLE" },
950
- { name: "sudheer", status: "IDLE" },
951
- { name: "test_user", status: "IDLE" }
952
- ];
1133
+ var _a, _b, _c, _d, _e, _f, _g, _h;
1134
+ const [transferCall] = usePostRequest({
1135
+ onSuccess: (res) => {
1136
+ console.log("res", res);
1137
+ setOpen(false);
1138
+ },
1139
+ onError: (error) => {
1140
+ console.log("error", error);
1141
+ }
1142
+ });
1143
+ const state = useSDKState();
1144
+ const [currentselecteTab, setCurrentselecteTab] = useState4("process");
1145
+ const [getIdelAgentsList, { data: idleAgentsList }] = usePostRequest();
1146
+ const [getProcessAndQueuesList, { data: processAndQueuesList }] = usePostRequest();
953
1147
  const handleClose = () => {
954
1148
  setOpen(false);
955
1149
  };
956
- const handleTransferCall = () => {
957
- const payload = {
958
- action: "CALL",
959
- endcall_type: "",
960
- mobile_number: "",
961
- userid: "",
962
- type: "",
963
- transfer_to_agent_id: "",
964
- transfer_to: "",
965
- disposition: "",
966
- set_followUp: "",
967
- callreferenceid: "",
968
- processid: "",
969
- process_name: "",
970
- refno: "",
971
- transfer_to_queue: ""
972
- };
973
- transferCall(END_POINT.TRANSFER_CALL, payload);
974
- };
975
- return /* @__PURE__ */ jsx2(Fragment, { children: /* @__PURE__ */ jsx2(
976
- Dialog,
977
- {
978
- open,
979
- "aria-labelledby": "alert-dialog-title",
1150
+ const handleTransferCall = (data, type) => {
1151
+ var _a2, _b2, _c2, _d2, _e2, _f2, _g2, _h2, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _A, _B, _C, _D, _E, _F, _G;
1152
+ console.log(data, "data34");
1153
+ if (type === "PROCESS") {
1154
+ const payload = {
1155
+ mobile_number: (_b2 = (_a2 = state.callData) == null ? void 0 : _a2.phone_number) != null ? _b2 : "",
1156
+ userid: (_d2 = (_c2 = state.callData) == null ? void 0 : _c2.agent_id) != null ? _d2 : "",
1157
+ type: "PROCESS",
1158
+ transfer_to: (_e2 = data == null ? void 0 : data.process_name) != null ? _e2 : "",
1159
+ callreferenceid: (_g2 = (_f2 = state.callData) == null ? void 0 : _f2.convox_id) != null ? _g2 : "",
1160
+ processid: String((_i = (_h2 = state.callData) == null ? void 0 : _h2.process_id) != null ? _i : ""),
1161
+ process_name: (_k = (_j = state.callData) == null ? void 0 : _j.process_name) != null ? _k : ""
1162
+ };
1163
+ transferCall(END_POINT.TRANSFER_CALL, payload);
1164
+ } else if (type === "QUEUE") {
1165
+ const payload = {
1166
+ mobile_number: (_m = (_l = state.callData) == null ? void 0 : _l.phone_number) != null ? _m : "",
1167
+ userid: (_o = (_n = state.callData) == null ? void 0 : _n.agent_id) != null ? _o : "",
1168
+ type: "QUEUE",
1169
+ transfer_to: (_p = data == null ? void 0 : data.queue_name) != null ? _p : "",
1170
+ callreferenceid: (_r = (_q = state.callData) == null ? void 0 : _q.convox_id) != null ? _r : "",
1171
+ processid: String((_t = (_s = state.callData) == null ? void 0 : _s.process_id) != null ? _t : ""),
1172
+ process_name: (_v = (_u = state.callData) == null ? void 0 : _u.process_name) != null ? _v : ""
1173
+ };
1174
+ transferCall(END_POINT.TRANSFER_CALL, payload);
1175
+ } else if (type === "AGENT") {
1176
+ const payload = {
1177
+ mobile_number: (_x = (_w = state.callData) == null ? void 0 : _w.phone_number) != null ? _x : "",
1178
+ userid: (_z = (_y = state.callData) == null ? void 0 : _y.agent_id) != null ? _z : "",
1179
+ type: "AGENT",
1180
+ transfer_to: (_A = data == null ? void 0 : data.user_id) != null ? _A : "",
1181
+ callreferenceid: (_C = (_B = state.callData) == null ? void 0 : _B.convox_id) != null ? _C : "",
1182
+ processid: String((_E = (_D = state.callData) == null ? void 0 : _D.process_id) != null ? _E : ""),
1183
+ process_name: (_G = (_F = state.callData) == null ? void 0 : _F.process_name) != null ? _G : ""
1184
+ };
1185
+ transferCall(END_POINT.TRANSFER_CALL, payload);
1186
+ }
1187
+ };
1188
+ useEffect2(() => {
1189
+ getIdelAgentsList(END_POINT.AGENTS_LIST, {
1190
+ status: "IDLE",
1191
+ active: true
1192
+ });
1193
+ getProcessAndQueuesList(END_POINT.TRANSFER_TO_DETAILS, {
1194
+ status: "ACTIVE",
1195
+ active: true
1196
+ });
1197
+ }, []);
1198
+ return /* @__PURE__ */ jsx2(Fragment, { children: /* @__PURE__ */ jsx2(
1199
+ Dialog,
1200
+ {
1201
+ open,
1202
+ "aria-labelledby": "alert-dialog-title",
980
1203
  "aria-describedby": "alert-dialog-description",
981
- maxWidth: "xs",
1204
+ fullWidth: true,
1205
+ maxWidth: "md",
982
1206
  children: /* @__PURE__ */ jsxs(Paper, { sx: { borderRadius: 2 }, children: [
983
1207
  /* @__PURE__ */ jsxs(
984
1208
  Box,
@@ -996,7 +1220,7 @@ function CallTransferDialog({ open, setOpen }) {
996
1220
  ]
997
1221
  }
998
1222
  ),
999
- /* @__PURE__ */ jsx2(
1223
+ /* @__PURE__ */ jsxs(
1000
1224
  Box,
1001
1225
  {
1002
1226
  sx: {
@@ -1005,55 +1229,254 @@ function CallTransferDialog({ open, setOpen }) {
1005
1229
  margin: "10px",
1006
1230
  borderRadius: "10px"
1007
1231
  },
1008
- children: agentList.map((line, index) => /* @__PURE__ */ jsxs(
1009
- Box,
1010
- {
1011
- sx: {
1012
- p: 1,
1013
- display: "flex",
1014
- alignItems: "center",
1015
- boxShadow: "1px 1px 4px #d3d3d3ff",
1016
- padding: "6px",
1017
- margin: "10px 0px",
1018
- borderRadius: "10px",
1019
- "&:hover": { bgcolor: "action.selected" }
1020
- },
1021
- children: [
1022
- /* @__PURE__ */ jsxs(
1023
- Typography,
1232
+ children: [
1233
+ /* @__PURE__ */ jsxs(Box, { sx: { display: "flex", gap: 1 }, children: [
1234
+ /* @__PURE__ */ jsx2(
1235
+ Button,
1236
+ {
1237
+ variant: currentselecteTab === "process" ? "contained" : "outlined",
1238
+ onClick: () => setCurrentselecteTab("process"),
1239
+ children: "Process"
1240
+ }
1241
+ ),
1242
+ /* @__PURE__ */ jsx2(
1243
+ Button,
1244
+ {
1245
+ variant: currentselecteTab === "queues" ? "contained" : "outlined",
1246
+ onClick: () => setCurrentselecteTab("queues"),
1247
+ children: "Queues"
1248
+ }
1249
+ ),
1250
+ /* @__PURE__ */ jsx2(
1251
+ Button,
1252
+ {
1253
+ variant: currentselecteTab === "agents" ? "contained" : "outlined",
1254
+ onClick: () => setCurrentselecteTab("agents"),
1255
+ children: "Agents"
1256
+ }
1257
+ )
1258
+ ] }),
1259
+ currentselecteTab === "process" && /* @__PURE__ */ jsx2(Box, { sx: { display: "flex", gap: 1 }, children: ((_b = (_a = processAndQueuesList == null ? void 0 : processAndQueuesList.data) == null ? void 0 : _a.process) == null ? void 0 : _b.length) > 0 ? (_d = (_c = processAndQueuesList == null ? void 0 : processAndQueuesList.data) == null ? void 0 : _c.process) == null ? void 0 : _d.map(
1260
+ (process, index) => /* @__PURE__ */ jsxs(
1261
+ Box,
1262
+ {
1263
+ sx: {
1264
+ p: 1,
1265
+ display: "flex",
1266
+ alignItems: "center",
1267
+ boxShadow: "1px 1px 4px #d3d3d3ff",
1268
+ padding: "6px",
1269
+ margin: "10px 0px",
1270
+ borderRadius: "10px",
1271
+ "&:hover": { bgcolor: "action.selected" }
1272
+ },
1273
+ children: [
1274
+ /* @__PURE__ */ jsxs(
1275
+ Typography,
1276
+ {
1277
+ variant: "body1",
1278
+ sx: {
1279
+ mx: 1,
1280
+ width: "200px",
1281
+ maxWidth: "250px",
1282
+ display: "flex",
1283
+ alignItems: "center"
1284
+ },
1285
+ children: [
1286
+ /* @__PURE__ */ jsx2(SupportAgent, { sx: { marginRight: "4px" } }),
1287
+ process.process_name
1288
+ ]
1289
+ }
1290
+ ),
1291
+ /* @__PURE__ */ jsx2(
1292
+ IconButton,
1293
+ {
1294
+ color: "success",
1295
+ sx: {
1296
+ bgcolor: "action.hover",
1297
+ "&:hover": { bgcolor: "action.selected" }
1298
+ },
1299
+ onClick: () => {
1300
+ handleTransferCall(process, "PROCESS");
1301
+ },
1302
+ children: /* @__PURE__ */ jsx2(Call, {})
1303
+ }
1304
+ )
1305
+ ]
1306
+ },
1307
+ index
1308
+ )
1309
+ ) : /* @__PURE__ */ jsx2(
1310
+ Typography,
1311
+ {
1312
+ variant: "body1",
1313
+ sx: {
1314
+ fontSize: "12px",
1315
+ fontWeight: "600",
1316
+ letterSpacing: "0.02em",
1317
+ textTransform: "capitalize",
1318
+ textAlign: "center",
1319
+ width: "100%",
1320
+ margin: "10px 0px",
1321
+ color: "gray"
1322
+ },
1323
+ children: "No Process Found"
1324
+ }
1325
+ ) }),
1326
+ currentselecteTab === "queues" && /* @__PURE__ */ jsx2(Box, { sx: { display: "flex", gap: 1 }, children: ((_f = (_e = processAndQueuesList == null ? void 0 : processAndQueuesList.data) == null ? void 0 : _e.queue) == null ? void 0 : _f.length) > 0 ? (_h = (_g = processAndQueuesList == null ? void 0 : processAndQueuesList.data) == null ? void 0 : _g.queue) == null ? void 0 : _h.map(
1327
+ (queue, index) => {
1328
+ var _a2, _b2, _c2, _d2, _e2, _f2;
1329
+ return /* @__PURE__ */ jsxs(
1330
+ Box,
1024
1331
  {
1025
- variant: "body1",
1026
1332
  sx: {
1027
- mx: 1,
1028
- width: "200px",
1029
- maxWidth: "250px",
1333
+ p: 1,
1030
1334
  display: "flex",
1031
- alignItems: "center"
1335
+ alignItems: "center",
1336
+ boxShadow: "1px 1px 4px #d3d3d3ff",
1337
+ padding: "6px",
1338
+ margin: "10px 0px",
1339
+ borderRadius: "10px",
1340
+ "&:hover": { bgcolor: "action.selected" }
1032
1341
  },
1033
1342
  children: [
1034
- /* @__PURE__ */ jsx2(SupportAgent, { sx: { marginRight: "4px" } }),
1035
- line.name
1343
+ /* @__PURE__ */ jsxs(
1344
+ Typography,
1345
+ {
1346
+ variant: "body1",
1347
+ sx: {
1348
+ mx: 1,
1349
+ width: "200px",
1350
+ maxWidth: "250px",
1351
+ display: "flex",
1352
+ alignItems: "center"
1353
+ },
1354
+ children: [
1355
+ /* @__PURE__ */ jsx2(SupportAgent, { sx: { marginRight: "4px" } }),
1356
+ queue.queue_name,
1357
+ ((_c2 = (_b2 = (_a2 = processAndQueuesList == null ? void 0 : processAndQueuesList.data) == null ? void 0 : _a2.process) == null ? void 0 : _b2.find(
1358
+ (process) => process.process_id === queue.process_id
1359
+ )) == null ? void 0 : _c2.process_name) ? /* @__PURE__ */ jsx2(
1360
+ Typography,
1361
+ {
1362
+ variant: "body1",
1363
+ sx: {
1364
+ fontSize: "12px",
1365
+ fontWeight: "600",
1366
+ letterSpacing: "0.02em",
1367
+ textTransform: "capitalize",
1368
+ color: "gray"
1369
+ },
1370
+ children: "(" + ((_f2 = (_e2 = (_d2 = processAndQueuesList == null ? void 0 : processAndQueuesList.data) == null ? void 0 : _d2.process) == null ? void 0 : _e2.find(
1371
+ (process) => process.process_id === queue.process_id
1372
+ )) == null ? void 0 : _f2.process_name) + ")"
1373
+ }
1374
+ ) : ""
1375
+ ]
1376
+ }
1377
+ ),
1378
+ /* @__PURE__ */ jsx2(
1379
+ IconButton,
1380
+ {
1381
+ color: "success",
1382
+ sx: {
1383
+ bgcolor: "action.hover",
1384
+ "&:hover": { bgcolor: "action.selected" }
1385
+ },
1386
+ onClick: () => {
1387
+ handleTransferCall(queue, "QUEUE");
1388
+ },
1389
+ children: /* @__PURE__ */ jsx2(Call, {})
1390
+ }
1391
+ )
1036
1392
  ]
1037
- }
1038
- ),
1039
- /* @__PURE__ */ jsx2(
1040
- IconButton,
1041
- {
1042
- color: "success",
1043
- sx: {
1044
- bgcolor: "action.hover",
1045
- "&:hover": { bgcolor: "action.selected" }
1046
- },
1047
- onClick: () => {
1048
- handleTransferCall();
1049
- },
1050
- children: /* @__PURE__ */ jsx2(Call, {})
1051
- }
1052
- )
1053
- ]
1054
- },
1055
- index
1056
- ))
1393
+ },
1394
+ index
1395
+ );
1396
+ }
1397
+ ) : /* @__PURE__ */ jsx2(
1398
+ Typography,
1399
+ {
1400
+ variant: "body1",
1401
+ sx: {
1402
+ fontSize: "12px",
1403
+ fontWeight: "600",
1404
+ letterSpacing: "0.02em",
1405
+ textTransform: "capitalize",
1406
+ textAlign: "center",
1407
+ width: "100%",
1408
+ margin: "10px 0px",
1409
+ color: "gray"
1410
+ },
1411
+ children: "No Queues Found"
1412
+ }
1413
+ ) }),
1414
+ currentselecteTab === "agents" && /* @__PURE__ */ jsx2(Box, { sx: { display: "flex", gap: 1 }, children: (idleAgentsList == null ? void 0 : idleAgentsList.length) > 0 ? idleAgentsList.map((agent, index) => /* @__PURE__ */ jsxs(
1415
+ Box,
1416
+ {
1417
+ sx: {
1418
+ p: 1,
1419
+ display: "flex",
1420
+ alignItems: "center",
1421
+ boxShadow: "1px 1px 4px #d3d3d3ff",
1422
+ padding: "6px",
1423
+ margin: "10px 0px",
1424
+ borderRadius: "10px",
1425
+ "&:hover": { bgcolor: "action.selected" }
1426
+ },
1427
+ children: [
1428
+ /* @__PURE__ */ jsxs(
1429
+ Typography,
1430
+ {
1431
+ variant: "body1",
1432
+ sx: {
1433
+ mx: 1,
1434
+ width: "200px",
1435
+ maxWidth: "250px",
1436
+ display: "flex",
1437
+ alignItems: "center"
1438
+ },
1439
+ children: [
1440
+ /* @__PURE__ */ jsx2(SupportAgent, { sx: { marginRight: "4px" } }),
1441
+ agent.name
1442
+ ]
1443
+ }
1444
+ ),
1445
+ /* @__PURE__ */ jsx2(
1446
+ IconButton,
1447
+ {
1448
+ color: "success",
1449
+ sx: {
1450
+ bgcolor: "action.hover",
1451
+ "&:hover": { bgcolor: "action.selected" }
1452
+ },
1453
+ onClick: () => {
1454
+ handleTransferCall(agent, "AGENT");
1455
+ },
1456
+ children: /* @__PURE__ */ jsx2(Call, {})
1457
+ }
1458
+ )
1459
+ ]
1460
+ },
1461
+ index
1462
+ )) : /* @__PURE__ */ jsx2(
1463
+ Typography,
1464
+ {
1465
+ variant: "body1",
1466
+ sx: {
1467
+ fontSize: "12px",
1468
+ fontWeight: "600",
1469
+ letterSpacing: "0.02em",
1470
+ textTransform: "capitalize",
1471
+ textAlign: "center",
1472
+ width: "100%",
1473
+ margin: "10px 0px",
1474
+ color: "gray"
1475
+ },
1476
+ children: "No Agents Found"
1477
+ }
1478
+ ) })
1479
+ ]
1057
1480
  }
1058
1481
  )
1059
1482
  ] })
@@ -1065,27 +1488,29 @@ function EndCallDispositionDialog({
1065
1488
  setOpen,
1066
1489
  onSubmitDisposition
1067
1490
  }) {
1491
+ var _a, _b;
1068
1492
  const [formData, setFormData] = useState4({
1069
- disposition: null,
1070
- followUp: { label: "no" },
1493
+ disposition: { label: "Resolved", value: "RES" },
1494
+ followUp: { label: "No", value: "N" },
1071
1495
  callbackDate: "",
1072
1496
  callbackHrs: "",
1073
1497
  callbackMins: ""
1074
1498
  });
1075
1499
  const dispositionOptions = [
1076
- { label: "Interested" },
1077
- { label: "Not Interested" },
1078
- { label: "Callback Later" },
1079
- { label: "Wrong Number" }
1500
+ { label: "Not Interested", value: "NI" },
1501
+ { label: "Resolved", value: "RES" }
1502
+ ];
1503
+ const followUpOptions = [
1504
+ { label: "Yes", value: "Y" },
1505
+ { label: "No", value: "N" }
1080
1506
  ];
1081
- const followUpOptions = [{ label: "yes" }, { label: "no" }];
1082
1507
  const handleChange = (field, value) => {
1083
1508
  setFormData((prev) => __spreadProps(__spreadValues({}, prev), { [field]: value }));
1084
1509
  };
1085
1510
  const handleReset = () => {
1086
1511
  setFormData({
1087
- disposition: null,
1088
- followUp: { label: "no" },
1512
+ disposition: { label: "Resolved", value: "RES" },
1513
+ followUp: { label: "No", value: "N" },
1089
1514
  callbackDate: "",
1090
1515
  callbackHrs: "",
1091
1516
  callbackMins: ""
@@ -1152,7 +1577,7 @@ function EndCallDispositionDialog({
1152
1577
  renderInput: (params) => /* @__PURE__ */ jsx2(TextField, __spreadProps(__spreadValues({}, params), { label: "Follow Up", fullWidth: true }))
1153
1578
  }
1154
1579
  ) }),
1155
- formData.followUp.label === "yes" && /* @__PURE__ */ jsxs(Fragment, { children: [
1580
+ ((_b = (_a = formData == null ? void 0 : formData.followUp) == null ? void 0 : _a.label) == null ? void 0 : _b.toLowerCase()) === "yes" && /* @__PURE__ */ jsxs(Fragment, { children: [
1156
1581
  /* @__PURE__ */ jsx2(Grid, { size: 6, children: /* @__PURE__ */ jsx2(
1157
1582
  TextField,
1158
1583
  {
@@ -1228,24 +1653,158 @@ function EndCallDispositionDialog({
1228
1653
  }
1229
1654
  ) });
1230
1655
  }
1656
+ function ProcessorListDialog({
1657
+ open,
1658
+ setOpen,
1659
+ processList = [],
1660
+ handleSelectedProcessor
1661
+ }) {
1662
+ const handleClose = () => {
1663
+ setOpen(false);
1664
+ };
1665
+ return /* @__PURE__ */ jsx2(Fragment, { children: /* @__PURE__ */ jsx2(
1666
+ Dialog,
1667
+ {
1668
+ open,
1669
+ "aria-labelledby": "alert-dialog-title",
1670
+ "aria-describedby": "alert-dialog-description",
1671
+ maxWidth: "xs",
1672
+ children: /* @__PURE__ */ jsxs(Paper, { sx: { borderRadius: 2 }, children: [
1673
+ /* @__PURE__ */ jsxs(
1674
+ Box,
1675
+ {
1676
+ sx: {
1677
+ display: "flex",
1678
+ justifyContent: "space-between",
1679
+ alignItems: "center",
1680
+ padding: "4px 16px",
1681
+ boxShadow: "0px 1px 2px #f5f5f5ff"
1682
+ },
1683
+ children: [
1684
+ /* @__PURE__ */ jsx2(Typography, { variant: "body1", children: " Process List" }),
1685
+ /* @__PURE__ */ jsx2(IconButton, { onClick: handleClose, children: /* @__PURE__ */ jsx2(Close, {}) })
1686
+ ]
1687
+ }
1688
+ ),
1689
+ /* @__PURE__ */ jsx2(
1690
+ Box,
1691
+ {
1692
+ sx: {
1693
+ boxShadow: "1px 1px 4px #d3d3d3ff",
1694
+ padding: "6px 10px",
1695
+ margin: "10px",
1696
+ borderRadius: "10px"
1697
+ },
1698
+ children: (processList == null ? void 0 : processList.length) > 0 ? processList == null ? void 0 : processList.map((process, index) => /* @__PURE__ */ jsx2(
1699
+ Box,
1700
+ {
1701
+ sx: {
1702
+ p: 1,
1703
+ display: "flex",
1704
+ alignItems: "center",
1705
+ boxShadow: "1px 1px 4px #d3d3d3ff",
1706
+ padding: "6px",
1707
+ margin: "10px 0px",
1708
+ borderRadius: "10px",
1709
+ cursor: "pointer",
1710
+ "&:hover": { bgcolor: "action.selected" }
1711
+ },
1712
+ onClick: () => {
1713
+ handleSelectedProcessor(process);
1714
+ },
1715
+ children: /* @__PURE__ */ jsxs(
1716
+ Typography,
1717
+ {
1718
+ variant: "body1",
1719
+ sx: {
1720
+ mx: 1,
1721
+ width: "200px",
1722
+ maxWidth: "250px",
1723
+ display: "flex",
1724
+ alignItems: "center"
1725
+ },
1726
+ children: [
1727
+ /* @__PURE__ */ jsx2(SupportAgent, { sx: { marginRight: "4px" } }),
1728
+ process.process_name
1729
+ ]
1730
+ }
1731
+ )
1732
+ },
1733
+ index
1734
+ )) : null
1735
+ }
1736
+ )
1737
+ ] })
1738
+ }
1739
+ ) });
1740
+ }
1741
+ function CallHistoryDialog({ open, setOpen }) {
1742
+ const handleClose = () => {
1743
+ setOpen(false);
1744
+ };
1745
+ return /* @__PURE__ */ jsx2(Fragment, { children: /* @__PURE__ */ jsx2(
1746
+ Dialog,
1747
+ {
1748
+ open,
1749
+ "aria-labelledby": "alert-dialog-title",
1750
+ "aria-describedby": "alert-dialog-description",
1751
+ fullWidth: true,
1752
+ maxWidth: "md",
1753
+ children: /* @__PURE__ */ jsxs(Paper, { sx: { borderRadius: 2 }, children: [
1754
+ /* @__PURE__ */ jsxs(
1755
+ Box,
1756
+ {
1757
+ sx: {
1758
+ display: "flex",
1759
+ justifyContent: "space-between",
1760
+ alignItems: "center",
1761
+ padding: "4px 16px",
1762
+ boxShadow: "0px 1px 2px #f5f5f5ff"
1763
+ },
1764
+ children: [
1765
+ /* @__PURE__ */ jsx2(Typography, { variant: "body1", children: " Call History" }),
1766
+ /* @__PURE__ */ jsx2(IconButton, { onClick: handleClose, children: /* @__PURE__ */ jsx2(Close, {}) })
1767
+ ]
1768
+ }
1769
+ ),
1770
+ /* @__PURE__ */ jsx2(
1771
+ Box,
1772
+ {
1773
+ sx: {
1774
+ boxShadow: "1px 1px 4px #d3d3d3ff",
1775
+ margin: "10px",
1776
+ borderRadius: "10px",
1777
+ textAlign: "center",
1778
+ fontSize: "16px",
1779
+ fontWeight: "bold"
1780
+ },
1781
+ p: 6,
1782
+ children: "Comming Soon..."
1783
+ }
1784
+ )
1785
+ ] })
1786
+ }
1787
+ ) });
1788
+ }
1231
1789
 
1232
1790
  // call-control-sdk/lib/components/callControlPanel.tsx
1233
1791
  import { Fragment as Fragment2, jsx as jsx3, jsxs as jsxs2 } from "react/jsx-runtime";
1234
1792
  function CallControlPanel({ onDataChange }) {
1235
- const theme = useTheme();
1793
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _A, _B, _C, _D, _E, _F, _G, _H, _I, _J, _K, _L, _M, _N, _O, _P, _Q, _R, _S, _T, _U, _V, _W, _X, _Y, _Z, __, _$, _aa, _ba, _ca, _da, _ea, _fa, _ga, _ha, _ia, _ja, _ka, _la;
1794
+ const theme = useTheme3();
1795
+ const { disabled, enabled, outlined } = styles_default();
1236
1796
  const state = useSDKState();
1237
1797
  const { showToast } = useToast();
1798
+ const webSocketRef = useRef2(null);
1238
1799
  const [anchorEl, setAnchorEl] = useState5(null);
1239
1800
  const [showIframe, setShowIframe] = useState5(true);
1240
- const [statusAnchorEl, setStatusAnchorEl] = useState5(
1241
- null
1242
- );
1243
- const [dialerAnchorEl, setDialerAnchorEl] = useState5(
1244
- null
1245
- );
1801
+ const [statusAnchorEl, setStatusAnchorEl] = useState5(null);
1802
+ const [dialerAnchorEl, setDialerAnchorEl] = useState5(null);
1246
1803
  const [open, setOpen] = useState5(false);
1247
1804
  const [openCallTransfer, setOpenCallTransfer] = useState5(false);
1248
1805
  const [openCallDisposition, setOpenCallDisposition] = useState5(false);
1806
+ const [openProcessorDialog, setOpenProcessorDialog] = useState5(false);
1807
+ const [openCallHistoryDialog, setOpenCallHistoryDialog] = useState5(false);
1249
1808
  const [phoneNumber, setPhoneNumber] = useState5("");
1250
1809
  const [callDuration, setCallDuration] = useState5(0);
1251
1810
  const { position, isDragging, dragRef, handleMouseDown, handleTouchStart } = useDraggable(
@@ -1262,39 +1821,46 @@ function CallControlPanel({ onDataChange }) {
1262
1821
  state.iframePosition,
1263
1822
  (newPosition) => sdkStateManager.setIframePosition(newPosition)
1264
1823
  );
1824
+ const [getProcessList, { data: processList }] = usePostRequest({
1825
+ onSuccess: (res) => {
1826
+ var _a2;
1827
+ console.log("res", res);
1828
+ if (res && res.processes && ((_a2 = res == null ? void 0 : res.processes) == null ? void 0 : _a2.length) > 1) {
1829
+ setOpenProcessorDialog(true);
1830
+ } else {
1831
+ sdkStateManager.setProcess(res == null ? void 0 : res.processes[0]);
1832
+ setOpenProcessorDialog(false);
1833
+ }
1834
+ },
1835
+ onError: () => {
1836
+ setOpenProcessorDialog(false);
1837
+ }
1838
+ });
1265
1839
  const [clickToCall] = usePostRequest();
1266
- const [holdOrUnHold] = usePostRequest();
1267
- const [muteOrUnMute] = usePostRequest();
1268
- const [readyAgentStatus] = usePostRequest();
1269
- const [updateAgentStatus] = usePostRequest();
1270
- const [endCall] = usePostRequest();
1271
- useEffect2(() => {
1272
- let interval;
1273
- if (state.callStartTime) {
1274
- interval = setInterval(() => {
1275
- const elapsed = Math.floor((Date.now() - state.callStartTime) / 1e3);
1276
- setCallDuration(elapsed);
1277
- }, 1e3);
1278
- } else {
1279
- setCallDuration(0);
1840
+ const [holdOrUnHold] = usePostRequest({
1841
+ onSuccess: () => {
1842
+ sdkStateManager.setHolding(!state.isHolding);
1843
+ },
1844
+ onError: (error) => {
1845
+ console.log("error", error);
1280
1846
  }
1281
- return () => {
1282
- if (interval) clearInterval(interval);
1283
- };
1284
- }, [state.callStartTime]);
1285
- useEffect2(() => {
1286
- if (onDataChange) {
1287
- onDataChange(state.callData);
1847
+ });
1848
+ const [muteOrUnMute] = usePostRequest({
1849
+ onSuccess: () => {
1850
+ sdkStateManager.setMuted(!state.isMuted);
1851
+ },
1852
+ onError: (error) => {
1853
+ console.log("error", error);
1288
1854
  }
1289
- }, [state.callData, onDataChange]);
1855
+ });
1856
+ const [readyAgentStatus] = usePostRequest();
1857
+ const [updateAgentStatus] = usePostRequest();
1858
+ const [endCall] = usePostRequest();
1290
1859
  const formatDuration = useCallback3((seconds) => {
1291
1860
  const mins = Math.floor(seconds / 60);
1292
1861
  const secs = seconds % 60;
1293
1862
  return `${mins.toString().padStart(2, "0")}:${secs.toString().padStart(2, "0")}`;
1294
1863
  }, []);
1295
- const handleOpenQueueCounts = (event) => {
1296
- setAnchorEl(event.currentTarget);
1297
- };
1298
1864
  const handleCloseQueueCounts = () => {
1299
1865
  setAnchorEl(null);
1300
1866
  };
@@ -1315,24 +1881,19 @@ function CallControlPanel({ onDataChange }) {
1315
1881
  const handleCloseAgentStatus = () => {
1316
1882
  setStatusAnchorEl(null);
1317
1883
  };
1318
- const handleAgentReady = (status) => {
1884
+ const handleAgentReady = () => {
1319
1885
  const payload = {
1320
1886
  action: "READYAGENT",
1321
- username: "string",
1322
- refno: "string"
1887
+ userId: state.agentId
1323
1888
  };
1324
1889
  readyAgentStatus(END_POINT.READY_AGENT, payload);
1325
- sdkStateManager.setStatus(status);
1326
1890
  };
1327
1891
  const handleUpdateAgentStatus = (status) => {
1328
- sdkStateManager.setStatus(status);
1329
1892
  setStatusAnchorEl(null);
1330
1893
  const payload = {
1331
- action: "AGENTSTATUS",
1332
- phone_number: "string",
1333
- refno: "string",
1334
- username: "string",
1335
- ticket_id: 0
1894
+ action: "AGENTBREAK",
1895
+ break_type: status,
1896
+ userId: state.agentId
1336
1897
  };
1337
1898
  updateAgentStatus(END_POINT.UPDATE_AGENT_BREAK, payload);
1338
1899
  };
@@ -1346,415 +1907,423 @@ function CallControlPanel({ onDataChange }) {
1346
1907
  const payload = {
1347
1908
  action: "CALL",
1348
1909
  phone_number: number,
1349
- refno: "string",
1350
- username: "string",
1351
- ticket_id: 0
1910
+ userId: state.agentId
1352
1911
  };
1353
1912
  clickToCall(END_POINT.CLICK_TO_CALL, payload);
1354
- sdkStateManager.startCall();
1355
1913
  }
1356
1914
  };
1357
1915
  const handleHoldToggle = () => {
1358
1916
  const payload = {
1359
1917
  action: state.isHolding ? "UNHOLD" : "HOLD",
1360
- username: "string",
1361
- refno: "string"
1918
+ userId: state.agentId
1362
1919
  };
1363
1920
  holdOrUnHold(END_POINT.HOLD_CALL, payload);
1364
- sdkStateManager.setHolding(!state.isHolding);
1365
1921
  };
1366
1922
  const handleMuteToggle = () => {
1367
1923
  const payload = {
1368
1924
  action: state.isMuted ? "UNMUTE" : "MUTE",
1369
- username: "string",
1370
- refno: "string"
1925
+ userId: state.agentId
1371
1926
  };
1372
- if (state.isMuted) {
1373
- muteOrUnMute(END_POINT.UNMUTE_CALL, payload);
1374
- } else {
1375
- muteOrUnMute(END_POINT.MUTE_CALL, payload);
1376
- }
1377
- sdkStateManager.setMuted(!state.isMuted);
1927
+ muteOrUnMute(END_POINT.MUTE_CALL, payload);
1378
1928
  };
1379
1929
  const handleEndCall = (data) => {
1380
- var _a, _b, _c, _d, _e, _f, _g;
1381
- console.log(data);
1930
+ var _a2, _b2, _c2, _d2, _e2, _f2, _g2, _h2, _i2, _j2, _k2, _l2, _m2, _n2, _o2, _p2;
1931
+ console.log("data", data);
1382
1932
  const payload = {
1383
1933
  action: "ENDCALL",
1384
- convoxid: "string",
1385
- username: "string",
1386
- processid: "101",
1387
- mobile_number: "string",
1388
- refno: "string",
1389
- disposition: (_b = (_a = data == null ? void 0 : data.disposition) == null ? void 0 : _a.label) != null ? _b : "",
1390
- set_followUp: (_d = (_c = data == null ? void 0 : data.followUp) == null ? void 0 : _c.label) != null ? _d : "",
1391
- callback_date: (_e = data == null ? void 0 : data.callbackDate) != null ? _e : "",
1392
- callback_hrs: (_f = data == null ? void 0 : data.callbackHrs) != null ? _f : "",
1393
- callback_mins: (_g = data == null ? void 0 : data.callbackMins) != null ? _g : ""
1934
+ userId: state.agentId,
1935
+ processid: (_c2 = (_b2 = (_a2 = state.process) == null ? void 0 : _a2.process_id) == null ? void 0 : _b2.toString()) != null ? _c2 : "",
1936
+ process_name: (_e2 = (_d2 = state.process) == null ? void 0 : _d2.process_name) != null ? _e2 : "",
1937
+ callreferenceid: (_g2 = (_f2 = state.callData) == null ? void 0 : _f2.convox_id) != null ? _g2 : "",
1938
+ mobile_number: (_i2 = (_h2 = state.callData) == null ? void 0 : _h2.phone_number) != null ? _i2 : "",
1939
+ disposition: (_k2 = (_j2 = data == null ? void 0 : data.disposition) == null ? void 0 : _j2.value) != null ? _k2 : "",
1940
+ set_followUp: (_m2 = (_l2 = data == null ? void 0 : data.followUp) == null ? void 0 : _l2.value) != null ? _m2 : "",
1941
+ callback_date: (_n2 = data == null ? void 0 : data.callbackDate) != null ? _n2 : "",
1942
+ callback_hrs: (_o2 = data == null ? void 0 : data.callbackHrs) != null ? _o2 : "",
1943
+ callback_mins: (_p2 = data == null ? void 0 : data.callbackMins) != null ? _p2 : "",
1944
+ endcall_type: "CLOSE"
1394
1945
  };
1395
1946
  setPhoneNumber("");
1396
1947
  endCall(END_POINT.END_CALL, payload);
1397
1948
  sdkStateManager.endCall();
1398
1949
  setOpenCallDisposition(false);
1399
1950
  };
1400
- if (!state.isInitialized) {
1401
- return null;
1951
+ useEffect3(() => {
1952
+ let interval;
1953
+ if (state.callData.status && state.callData.status === "ONCALL") {
1954
+ interval = setInterval(() => {
1955
+ const elapsed = Math.floor((Date.now() - state.callStartTime) / 1e3);
1956
+ setCallDuration(elapsed);
1957
+ }, 1e3);
1958
+ } else {
1959
+ setCallDuration(0);
1960
+ }
1961
+ return () => {
1962
+ if (interval) clearInterval(interval);
1963
+ };
1964
+ }, [state.callData.status]);
1965
+ useEffect3(() => {
1966
+ if (onDataChange) {
1967
+ onDataChange(state.callData);
1968
+ }
1969
+ }, [state.callData, onDataChange]);
1970
+ useEffect3(() => {
1971
+ if (state.agentId) {
1972
+ getProcessList(END_POINT.PROCESS_LIST, {
1973
+ userId: state.agentId,
1974
+ action: "GETAGENTPROCESSLIST",
1975
+ refno: "1234221233"
1976
+ });
1977
+ } else {
1978
+ console.log("No agentId available, skipping API call");
1979
+ }
1980
+ }, [state.agentId]);
1981
+ useEffect3(() => {
1982
+ if (state.agentId) {
1983
+ webSocketRef.current = new WebSocket(`${WS_END_POINT.WS}?agent_id=${state.agentId}`);
1984
+ webSocketRef.current.onopen = () => {
1985
+ console.log("WebSocket connection established");
1986
+ };
1987
+ webSocketRef.current.onmessage = (event) => {
1988
+ try {
1989
+ const data = JSON.parse(event.data);
1990
+ console.log("parsedJSON:", data);
1991
+ sdkStateManager.updateCallData(data);
1992
+ if (data.status === "ONCALL") {
1993
+ sdkStateManager.startCall();
1994
+ }
1995
+ if (data.status === "WRAPUP") {
1996
+ sdkStateManager.endCall();
1997
+ }
1998
+ } catch (e) {
1999
+ console.log("Raw message:", event.data);
2000
+ }
2001
+ };
2002
+ webSocketRef.current.onclose = () => {
2003
+ console.log("WebSocket connection closed");
2004
+ };
2005
+ webSocketRef.current.onerror = (error) => {
2006
+ console.error("WebSocket error:", error);
2007
+ };
2008
+ }
2009
+ return () => {
2010
+ var _a2;
2011
+ (_a2 = webSocketRef.current) == null ? void 0 : _a2.close();
2012
+ };
2013
+ }, [state.agentId]);
2014
+ if (!state.isInitialized || !state.process) {
2015
+ return /* @__PURE__ */ jsx3(Box2, { children: Boolean(openProcessorDialog) && /* @__PURE__ */ jsx3(
2016
+ ProcessorListDialog,
2017
+ {
2018
+ processList: processList == null ? void 0 : processList.processes,
2019
+ open: openProcessorDialog,
2020
+ setOpen: setOpenProcessorDialog,
2021
+ handleSelectedProcessor: (data) => {
2022
+ sdkStateManager.setProcess(data);
2023
+ }
2024
+ }
2025
+ ) });
1402
2026
  }
1403
2027
  return /* @__PURE__ */ jsxs2(Fragment2, { children: [
1404
- /* @__PURE__ */ jsx3(Fade, { in: true, timeout: 300, children: /* @__PURE__ */ jsx3(
1405
- Paper2,
2028
+ /* @__PURE__ */ jsx3(
2029
+ Fade,
1406
2030
  {
1407
- ref: dragRef,
1408
- elevation: isDragging ? 4 : 1,
1409
- sx: {
1410
- position: "fixed",
1411
- left: position.x,
1412
- top: position.y,
1413
- p: 1,
1414
- borderRadius: 3,
1415
- bgcolor: "background.paper",
1416
- zIndex: 99999,
1417
- transition: theme.transitions.create(["box-shadow", "transform"], {
1418
- duration: theme.transitions.duration.short
1419
- }),
1420
- minWidth: 320,
1421
- userSelect: "none"
1422
- },
1423
- children: /* @__PURE__ */ jsxs2(
1424
- Box2,
2031
+ in: true,
2032
+ timeout: 300,
2033
+ children: /* @__PURE__ */ jsx3(
2034
+ Paper2,
1425
2035
  {
2036
+ ref: dragRef,
2037
+ elevation: isDragging ? 4 : 1,
1426
2038
  sx: {
1427
- display: "flex",
1428
- alignItems: "center"
2039
+ position: "fixed",
2040
+ left: position.x,
2041
+ top: position.y,
2042
+ p: 0.5,
2043
+ borderRadius: 3,
2044
+ bgcolor: "background.paper",
2045
+ zIndex: 99999,
2046
+ transition: theme.transitions.create(["box-shadow", "transform"], {
2047
+ duration: theme.transitions.duration.short
2048
+ }),
2049
+ userSelect: "none"
1429
2050
  },
1430
- children: [
1431
- /* @__PURE__ */ jsxs2(
1432
- Box2,
1433
- {
1434
- sx: {
1435
- display: "flex",
1436
- justifyContent: "space-between",
1437
- alignItems: "center"
1438
- },
1439
- children: [
1440
- /* @__PURE__ */ jsxs2(
1441
- Typography2,
1442
- {
1443
- variant: "h6",
1444
- sx: {
1445
- color: state.status === "on call" ? "success.main" : "text.secondary",
1446
- marginRight: "8px",
1447
- display: "flex",
1448
- justifyContent: "space-between",
1449
- alignItems: "center"
1450
- },
1451
- children: [
1452
- /* @__PURE__ */ jsxs2(
1453
- IconButton2,
1454
- {
1455
- component: "div",
1456
- sx: {
1457
- cursor: "all-scroll"
1458
- },
1459
- onMouseDown: handleMouseDown,
1460
- onTouchStart: handleTouchStart,
1461
- children: [
1462
- /* @__PURE__ */ jsx3(DragIndicator, {}),
1463
- " "
1464
- ]
1465
- }
1466
- ),
1467
- /* @__PURE__ */ jsx3(
1468
- Box2,
1469
- {
1470
- sx: {
1471
- marginRight: "10px"
1472
- },
1473
- children: /* @__PURE__ */ jsx3(Tooltip2, { title: "Dial", children: /* @__PURE__ */ jsx3(
1474
- IconButton2,
1475
- {
1476
- onClick: (e) => {
1477
- if (state.status !== "on call" && state.status !== "break") {
1478
- handleOpenDialer(e);
1479
- }
1480
- },
1481
- sx: {
1482
- bgcolor: "action.hover",
1483
- "&:hover": {
1484
- bgcolor: "warning"
1485
- }
1486
- },
1487
- children: /* @__PURE__ */ jsx3(
1488
- WifiCalling3,
1489
- {
1490
- sx: {
1491
- color: state.status === "on call" || state.status === "break" ? "action.selected" : "success.main"
1492
- }
2051
+ children: /* @__PURE__ */ jsxs2(
2052
+ Box2,
2053
+ {
2054
+ sx: {
2055
+ display: "flex",
2056
+ alignItems: "center"
2057
+ },
2058
+ children: [
2059
+ /* @__PURE__ */ jsxs2(
2060
+ Box2,
2061
+ {
2062
+ sx: {
2063
+ display: "flex",
2064
+ justifyContent: "space-between",
2065
+ alignItems: "center"
2066
+ },
2067
+ children: [
2068
+ /* @__PURE__ */ jsxs2(
2069
+ IconButton2,
2070
+ {
2071
+ component: "div",
2072
+ size: "small",
2073
+ sx: {
2074
+ cursor: "all-scroll"
2075
+ },
2076
+ onMouseDown: handleMouseDown,
2077
+ onTouchStart: handleTouchStart,
2078
+ children: [
2079
+ /* @__PURE__ */ jsx3(DragIndicator, {}),
2080
+ " "
2081
+ ]
2082
+ }
2083
+ ),
2084
+ /* @__PURE__ */ jsx3(
2085
+ Box2,
2086
+ {
2087
+ sx: {
2088
+ marginRight: "10px"
2089
+ },
2090
+ children: /* @__PURE__ */ jsx3(Tooltip2, { title: "Dial", children: /* @__PURE__ */ jsx3(
2091
+ IconButton2,
2092
+ {
2093
+ size: "small",
2094
+ onClick: (e) => {
2095
+ var _a2, _b2, _c2, _d2, _e2, _f2, _g2, _h2;
2096
+ if (((_b2 = (_a2 = state.callData) == null ? void 0 : _a2.status) == null ? void 0 : _b2.toUpperCase()) !== "ONCALL" && ((_d2 = (_c2 = state.callData) == null ? void 0 : _c2.status) == null ? void 0 : _d2.toUpperCase()) !== "BREAK" && ((_f2 = (_e2 = state.callData) == null ? void 0 : _e2.status) == null ? void 0 : _f2.toUpperCase()) !== "RINGING" && ((_h2 = (_g2 = state.callData) == null ? void 0 : _g2.status) == null ? void 0 : _h2.toUpperCase()) !== "WRAPUP") {
2097
+ handleOpenDialer(e);
2098
+ }
2099
+ },
2100
+ sx: {
2101
+ bgcolor: "action.hover",
2102
+ "&:hover": {
2103
+ bgcolor: "warning"
2104
+ }
2105
+ },
2106
+ children: /* @__PURE__ */ jsx3(
2107
+ WifiCalling3,
2108
+ {
2109
+ sx: {
2110
+ color: ((_b = (_a = state.callData) == null ? void 0 : _a.status) == null ? void 0 : _b.toUpperCase()) === "ONCALL" || ((_d = (_c = state.callData) == null ? void 0 : _c.status) == null ? void 0 : _d.toUpperCase()) === "BREAK" || ((_f = (_e = state.callData) == null ? void 0 : _e.status) == null ? void 0 : _f.toUpperCase()) === "RINGING" || ((_h = (_g = state.callData) == null ? void 0 : _g.status) == null ? void 0 : _h.toUpperCase()) === "WRAPUP" ? "action.selected" : "success.main"
1493
2111
  }
1494
- )
1495
- }
1496
- ) })
1497
- }
1498
- ),
1499
- formatDuration(callDuration)
1500
- ]
1501
- }
1502
- ),
1503
- /* @__PURE__ */ jsxs2(
1504
- ButtonGroup,
1505
- {
1506
- disableElevation: true,
1507
- variant: "contained",
1508
- "aria-label": "Disabled button group",
1509
- sx: {
1510
- marginRight: "10px"
1511
- },
1512
- children: [
1513
- /* @__PURE__ */ jsx3(
1514
- Button2,
1515
- {
1516
- sx: {
1517
- fontWeight: "bold",
1518
- borderRadius: "16px",
1519
- display: "flex",
1520
- alignItems: "center",
1521
- justifyContent: "space-between"
1522
- },
1523
- variant: "outlined",
1524
- children: /* @__PURE__ */ jsx3(
1525
- Typography2,
1526
- {
1527
- width: 70,
1528
- variant: "body2",
1529
- sx: {
1530
- fontWeight: "bold"
1531
- },
1532
- children: state.status.toUpperCase()
1533
- }
1534
- )
1535
- }
1536
- ),
1537
- /* @__PURE__ */ jsxs2(
1538
- Button2,
1539
- {
1540
- sx: {
1541
- borderRadius: "16px",
1542
- width: 20
1543
- },
1544
- variant: "outlined",
1545
- onClick: handleOpenAgentStatus,
1546
- disabled: Boolean(state.callStartTime),
1547
- children: [
1548
- /* @__PURE__ */ jsx3(ArrowDropDown, {}),
1549
- " "
1550
- ]
1551
- }
1552
- )
1553
- ]
1554
- }
1555
- )
1556
- ]
1557
- }
1558
- ),
1559
- /* @__PURE__ */ jsxs2(
1560
- Box2,
1561
- {
1562
- sx: {
1563
- display: "flex",
1564
- gap: 1,
1565
- justifyContent: "center",
1566
- alignItems: "center"
1567
- },
1568
- children: [
1569
- state.status === "break" && /* @__PURE__ */ jsx3(Tooltip2, { title: "Agent Ready", children: /* @__PURE__ */ jsx3(
1570
- IconButton2,
1571
- {
1572
- onClick: (e) => {
1573
- e.stopPropagation();
1574
- handleAgentReady("idle");
1575
- },
1576
- color: "default",
1577
- sx: {
1578
- bgcolor: "error.dark",
1579
- "&:hover": {
1580
- bgcolor: "error.light"
2112
+ }
2113
+ )
2114
+ }
2115
+ ) })
1581
2116
  }
1582
- },
1583
- children: /* @__PURE__ */ jsx3(
1584
- SupportAgent2,
2117
+ ),
2118
+ /* @__PURE__ */ jsx3(
2119
+ Typography2,
1585
2120
  {
1586
2121
  sx: {
1587
- color: "white"
1588
- }
2122
+ color: "success.main",
2123
+ width: "40px",
2124
+ marginRight: "10px"
2125
+ },
2126
+ children: formatDuration(callDuration)
2127
+ }
2128
+ ),
2129
+ /* @__PURE__ */ jsx3(
2130
+ Typography2,
2131
+ {
2132
+ variant: "body2",
2133
+ sx: {
2134
+ fontWeight: "bold"
2135
+ },
2136
+ children: (_k = (_j = (_i = state.callData) == null ? void 0 : _i.status) == null ? void 0 : _j.toUpperCase()) != null ? _k : "N/A"
2137
+ }
2138
+ ),
2139
+ /* @__PURE__ */ jsxs2(
2140
+ Button2,
2141
+ {
2142
+ size: "small",
2143
+ variant: "text",
2144
+ onClick: handleOpenAgentStatus,
2145
+ disabled: Boolean(state.callStartTime),
2146
+ children: [
2147
+ /* @__PURE__ */ jsx3(ArrowDropDown, {}),
2148
+ " "
2149
+ ]
1589
2150
  }
1590
2151
  )
1591
- }
1592
- ) }),
1593
- state.status === "wrap up" && /* @__PURE__ */ jsx3(Tooltip2, { title: "Redial", children: /* @__PURE__ */ jsx3(
1594
- IconButton2,
1595
- {
1596
- onClick: (e) => {
1597
- e.stopPropagation();
1598
- },
1599
- color: "default",
1600
- sx: {
1601
- bgcolor: "action.hover",
1602
- "&:hover": {
1603
- bgcolor: "warning"
2152
+ ]
2153
+ }
2154
+ ),
2155
+ /* @__PURE__ */ jsxs2(
2156
+ Box2,
2157
+ {
2158
+ sx: {
2159
+ display: "flex",
2160
+ gap: 1,
2161
+ justifyContent: "center",
2162
+ alignItems: "center"
2163
+ },
2164
+ children: [
2165
+ /* @__PURE__ */ jsx3(Tooltip2, { title: "Agent Ready", children: /* @__PURE__ */ jsx3(
2166
+ Button2,
2167
+ {
2168
+ variant: ((_m = (_l = state.callData) == null ? void 0 : _l.status) == null ? void 0 : _m.toUpperCase()) === "BREAK" || ((_o = (_n = state.callData) == null ? void 0 : _n.status) == null ? void 0 : _o.toUpperCase()) === "MISSED" ? "outlined" : "contained",
2169
+ onClick: (e) => {
2170
+ var _a2, _b2, _c2, _d2;
2171
+ if (((_b2 = (_a2 = state.callData) == null ? void 0 : _a2.status) == null ? void 0 : _b2.toUpperCase()) === "BREAK" || ((_d2 = (_c2 = state.callData) == null ? void 0 : _c2.status) == null ? void 0 : _d2.toUpperCase()) === "MISSED") {
2172
+ e.stopPropagation();
2173
+ handleAgentReady();
2174
+ }
2175
+ },
2176
+ classes: {
2177
+ root: ((_q = (_p = state.callData) == null ? void 0 : _p.status) == null ? void 0 : _q.toUpperCase()) === "BREAK" || ((_s = (_r = state.callData) == null ? void 0 : _r.status) == null ? void 0 : _s.toUpperCase()) === "MISSED" ? "outlined" : "enabled"
2178
+ },
2179
+ sx: __spreadValues({}, ((_u = (_t = state.callData) == null ? void 0 : _t.status) == null ? void 0 : _u.toUpperCase()) === "BREAK" || ((_w = (_v = state.callData) == null ? void 0 : _v.status) == null ? void 0 : _w.toUpperCase()) === "MISSED" ? outlined : enabled),
2180
+ children: /* @__PURE__ */ jsx3(SupportAgent2, {})
1604
2181
  }
1605
- },
1606
- children: /* @__PURE__ */ jsx3(Tty, {})
1607
- }
1608
- ) }),
1609
- state.status === "on call" && /* @__PURE__ */ jsx3(Tooltip2, { title: state.isHolding ? "Resume" : "Hold", children: /* @__PURE__ */ jsx3(
1610
- IconButton2,
1611
- {
1612
- onClick: (e) => {
1613
- e.stopPropagation();
1614
- handleHoldToggle();
1615
- },
1616
- color: state.isHolding ? "warning" : "default",
1617
- sx: {
1618
- bgcolor: state.isHolding ? "warning.info" : "action.hover"
1619
- },
1620
- children: state.isHolding ? /* @__PURE__ */ jsx3(PlayCircle2, {}) : /* @__PURE__ */ jsx3(PauseCircle2, {})
1621
- }
1622
- ) }),
1623
- state.status === "on call" && /* @__PURE__ */ jsx3(Tooltip2, { title: state.isMuted ? "Unmute" : "Mute", children: /* @__PURE__ */ jsx3(
1624
- IconButton2,
1625
- {
1626
- onClick: (e) => {
1627
- e.stopPropagation();
1628
- handleMuteToggle();
1629
- },
1630
- color: state.isMuted ? "error" : "default",
1631
- sx: {
1632
- bgcolor: state.isMuted ? "error.info" : "action.hover"
1633
- },
1634
- children: state.isMuted ? /* @__PURE__ */ jsx3(MicOff2, {}) : /* @__PURE__ */ jsx3(Mic2, {})
1635
- }
1636
- ) }),
1637
- state.status !== "on call" && /* @__PURE__ */ jsx3(Tooltip2, { title: "Queue", children: /* @__PURE__ */ jsx3(
1638
- IconButton2,
1639
- {
1640
- onClick: (e) => {
1641
- e.stopPropagation();
1642
- handleOpenQueueCounts(e);
1643
- },
1644
- color: "default",
1645
- sx: {
1646
- bgcolor: "action.hover",
1647
- "&:hover": {
1648
- bgcolor: "warning"
2182
+ ) }),
2183
+ /* @__PURE__ */ jsx3(Tooltip2, { title: state.isHolding ? "Resume" : "Hold", children: /* @__PURE__ */ jsx3(
2184
+ Button2,
2185
+ {
2186
+ variant: state.isHolding && ((_y = (_x = state.callData) == null ? void 0 : _x.status) == null ? void 0 : _y.toUpperCase()) === "ONCALL" ? "contained" : "outlined",
2187
+ onClick: (e) => {
2188
+ e.stopPropagation();
2189
+ handleHoldToggle();
2190
+ },
2191
+ sx: state.isHolding && ((_A = (_z = state.callData) == null ? void 0 : _z.status) == null ? void 0 : _A.toUpperCase()) === "ONCALL" ? __spreadValues({}, enabled) : ((_C = (_B = state.callData) == null ? void 0 : _B.status) == null ? void 0 : _C.toUpperCase()) === "ONCALL" ? __spreadValues({}, outlined) : __spreadValues({}, disabled),
2192
+ disabled: ((_E = (_D = state.callData) == null ? void 0 : _D.status) == null ? void 0 : _E.toUpperCase()) !== "ONCALL" && !state.isHolding,
2193
+ children: state.isHolding ? /* @__PURE__ */ jsx3(PlayArrow2, {}) : /* @__PURE__ */ jsx3(Pause2, {})
1649
2194
  }
1650
- },
1651
- children: /* @__PURE__ */ jsx3(Layers, {})
1652
- }
1653
- ) }),
1654
- state.status === "on call" && /* @__PURE__ */ jsx3(Tooltip2, { title: "Conference Call", children: /* @__PURE__ */ jsx3(
1655
- IconButton2,
1656
- {
1657
- onClick: (e) => {
1658
- e.stopPropagation();
1659
- setOpenCallTransfer(true);
1660
- },
1661
- color: "default",
1662
- sx: {
1663
- bgcolor: "action.hover",
1664
- "&:hover": {
1665
- bgcolor: "warning"
2195
+ ) }),
2196
+ /* @__PURE__ */ jsx3(Tooltip2, { title: state.isMuted ? "Unmute" : "Mute", children: /* @__PURE__ */ jsx3(
2197
+ Button2,
2198
+ {
2199
+ variant: state.isMuted && ((_G = (_F = state.callData) == null ? void 0 : _F.status) == null ? void 0 : _G.toUpperCase()) === "ONCALL" ? "contained" : "outlined",
2200
+ onClick: (e) => {
2201
+ e.stopPropagation();
2202
+ handleMuteToggle();
2203
+ },
2204
+ sx: state.isMuted && ((_I = (_H = state.callData) == null ? void 0 : _H.status) == null ? void 0 : _I.toUpperCase()) === "ONCALL" ? __spreadValues({}, enabled) : ((_K = (_J = state.callData) == null ? void 0 : _J.status) == null ? void 0 : _K.toUpperCase()) === "ONCALL" ? __spreadValues({}, outlined) : __spreadValues({}, disabled),
2205
+ disabled: ((_M = (_L = state.callData) == null ? void 0 : _L.status) == null ? void 0 : _M.toUpperCase()) !== "ONCALL" && !state.isMuted,
2206
+ children: state.isMuted ? /* @__PURE__ */ jsx3(MicOff2, {}) : /* @__PURE__ */ jsx3(Mic2, {})
1666
2207
  }
1667
- },
1668
- children: /* @__PURE__ */ jsx3(TransferWithinAStation, {})
1669
- }
1670
- ) }),
1671
- state.status === "on call" && /* @__PURE__ */ jsx3(Tooltip2, { title: "Conference Call", children: /* @__PURE__ */ jsx3(
1672
- IconButton2,
1673
- {
1674
- onClick: (e) => {
1675
- e.stopPropagation();
1676
- setOpen(true);
1677
- },
1678
- color: "default",
1679
- sx: {
1680
- bgcolor: "action.hover",
1681
- "&:hover": {
1682
- bgcolor: "warning"
2208
+ ) }),
2209
+ /* @__PURE__ */ jsx3(Tooltip2, { title: "Transfer Call", children: /* @__PURE__ */ jsx3(
2210
+ Button2,
2211
+ {
2212
+ variant: openCallTransfer ? "contained" : "outlined",
2213
+ onClick: (e) => {
2214
+ var _a2, _b2;
2215
+ if (((_b2 = (_a2 = state.callData) == null ? void 0 : _a2.status) == null ? void 0 : _b2.toUpperCase()) === "ONCALL") {
2216
+ e.stopPropagation();
2217
+ setOpenCallTransfer(true);
2218
+ }
2219
+ },
2220
+ sx: openCallTransfer ? __spreadValues({}, enabled) : ((_O = (_N = state.callData) == null ? void 0 : _N.status) == null ? void 0 : _O.toUpperCase()) === "ONCALL" ? __spreadValues({}, outlined) : __spreadValues({}, disabled),
2221
+ disabled: ((_Q = (_P = state.callData) == null ? void 0 : _P.status) == null ? void 0 : _Q.toUpperCase()) !== "ONCALL",
2222
+ children: /* @__PURE__ */ jsx3(TransferWithinAStation, {})
1683
2223
  }
1684
- },
1685
- children: /* @__PURE__ */ jsx3(Groups, {})
1686
- }
1687
- ) }),
1688
- state.status === "on call" && /* @__PURE__ */ jsx3(
1689
- Tooltip2,
1690
- {
1691
- title: state.status === "on call" ? "End Call" : "Start Call",
1692
- children: /* @__PURE__ */ jsx3(
1693
- IconButton2,
2224
+ ) }),
2225
+ /* @__PURE__ */ jsx3(Tooltip2, { title: "Conference Call", children: /* @__PURE__ */ jsx3(
2226
+ Button2,
2227
+ {
2228
+ variant: open ? "contained" : "outlined",
2229
+ onClick: (e) => {
2230
+ var _a2, _b2;
2231
+ if (((_b2 = (_a2 = state.callData) == null ? void 0 : _a2.status) == null ? void 0 : _b2.toUpperCase()) === "ONCALL") {
2232
+ e.stopPropagation();
2233
+ setOpen(true);
2234
+ }
2235
+ },
2236
+ sx: open ? __spreadValues({}, enabled) : ((_S = (_R = state.callData) == null ? void 0 : _R.status) == null ? void 0 : _S.toUpperCase()) === "ONCALL" ? __spreadValues({}, outlined) : __spreadValues({}, disabled),
2237
+ disabled: ((_U = (_T = state.callData) == null ? void 0 : _T.status) == null ? void 0 : _U.toUpperCase()) !== "ONCALL",
2238
+ children: /* @__PURE__ */ jsx3(Group, {})
2239
+ }
2240
+ ) }),
2241
+ /* @__PURE__ */ jsx3(Tooltip2, { title: "Call History", children: /* @__PURE__ */ jsx3(
2242
+ Button2,
1694
2243
  {
2244
+ variant: openCallHistoryDialog ? "contained" : "outlined",
1695
2245
  onClick: (e) => {
1696
2246
  e.stopPropagation();
1697
- setOpenCallDisposition(true);
2247
+ setOpenCallHistoryDialog(true);
1698
2248
  },
1699
- color: "error",
1700
- sx: {
1701
- bgcolor: state.status === "on call" ? "error.main" : "gray",
1702
- color: "white",
1703
- "&:hover": {
1704
- bgcolor: state.status === "on call" ? "error.light" : "gray"
2249
+ sx: openCallHistoryDialog ? __spreadValues({}, enabled) : __spreadValues({}, outlined),
2250
+ children: /* @__PURE__ */ jsx3(History, {})
2251
+ }
2252
+ ) }),
2253
+ /* @__PURE__ */ jsx3(Tooltip2, { title: "End Call", children: /* @__PURE__ */ jsx3(
2254
+ Button2,
2255
+ {
2256
+ variant: ((_W = (_V = state.callData) == null ? void 0 : _V.status) == null ? void 0 : _W.toUpperCase()) === "ONCALL" || ((_Y = (_X = state.callData) == null ? void 0 : _X.status) == null ? void 0 : _Y.toUpperCase()) === "RINGING" || ((__ = (_Z = state.callData) == null ? void 0 : _Z.status) == null ? void 0 : __.toUpperCase()) === "WRAPUP" ? "contained" : "outlined",
2257
+ onClick: (e) => {
2258
+ var _a2, _b2, _c2, _d2, _e2, _f2;
2259
+ if (((_b2 = (_a2 = state.callData) == null ? void 0 : _a2.status) == null ? void 0 : _b2.toUpperCase()) === "ONCALL" || ((_d2 = (_c2 = state.callData) == null ? void 0 : _c2.status) == null ? void 0 : _d2.toUpperCase()) === "RINGING" || ((_f2 = (_e2 = state.callData) == null ? void 0 : _e2.status) == null ? void 0 : _f2.toUpperCase()) === "WRAPUP") {
2260
+ e.stopPropagation();
2261
+ setOpenCallDisposition(true);
1705
2262
  }
1706
2263
  },
2264
+ sx: ((_aa = (_$ = state.callData) == null ? void 0 : _$.status) == null ? void 0 : _aa.toUpperCase()) === "ONCALL" || ((_ca = (_ba = state.callData) == null ? void 0 : _ba.status) == null ? void 0 : _ca.toUpperCase()) === "RINGING" || ((_ea = (_da = state.callData) == null ? void 0 : _da.status) == null ? void 0 : _ea.toUpperCase()) === "WRAPUP" ? __spreadProps(__spreadValues({}, enabled), {
2265
+ borderRight: "1px",
2266
+ backgroundColor: "error.main",
2267
+ minWidth: "60px !important",
2268
+ boxShadow: " 0px 2px 1px #5f3f3f",
2269
+ border: `1px solid ${theme.palette.error.light}`,
2270
+ height: "40px",
2271
+ "&:hover": {
2272
+ bgcolor: "error.light",
2273
+ boxShadow: " 0px 2px 1px #5f3f3f",
2274
+ border: `0px solid ${theme.palette.error.light}`
2275
+ },
2276
+ "&:active": {
2277
+ bgcolor: "error.light",
2278
+ boxShadow: `inset 1px -2px 4px ${theme.palette.primary.light}`
2279
+ }
2280
+ }) : __spreadProps(__spreadValues({}, disabled), {
2281
+ minWidth: "60px !important"
2282
+ }),
2283
+ disabled: ((_ga = (_fa = state.callData) == null ? void 0 : _fa.status) == null ? void 0 : _ga.toUpperCase()) !== "ONCALL" && ((_ia = (_ha = state.callData) == null ? void 0 : _ha.status) == null ? void 0 : _ia.toUpperCase()) !== "RINGING" && ((_ka = (_ja = state.callData) == null ? void 0 : _ja.status) == null ? void 0 : _ka.toUpperCase()) !== "WRAPUP",
1707
2284
  children: /* @__PURE__ */ jsx3(CallEnd2, {})
1708
2285
  }
1709
- )
1710
- }
1711
- )
1712
- ]
1713
- }
1714
- )
1715
- ]
2286
+ ) })
2287
+ ]
2288
+ }
2289
+ )
2290
+ ]
2291
+ }
2292
+ )
1716
2293
  }
1717
2294
  )
1718
2295
  }
1719
- ) }),
1720
- Boolean(showIframe) && /* @__PURE__ */ jsx3(Fade, { in: true, timeout: 300, children: /* @__PURE__ */ jsx3(
1721
- Paper2,
2296
+ ),
2297
+ /* @__PURE__ */ jsx3(
2298
+ Fade,
1722
2299
  {
1723
- ref: iframeDragRef,
1724
- elevation: iframeIsDragging ? 4 : 1,
1725
- sx: {
1726
- position: "fixed",
1727
- left: iframePosition.x,
1728
- top: iframePosition.y,
1729
- p: 1,
1730
- height: "auto",
1731
- borderRadius: 2,
1732
- bgcolor: "background.paper",
1733
- zIndex: 99999,
1734
- transition: theme.transitions.create(
1735
- ["box-shadow", "transform"],
1736
- {
1737
- duration: theme.transitions.duration.short
1738
- }
1739
- ),
1740
- userSelect: "none"
1741
- },
2300
+ in: true,
2301
+ timeout: 300,
1742
2302
  children: /* @__PURE__ */ jsxs2(
1743
- Box2,
2303
+ Paper2,
1744
2304
  {
2305
+ ref: iframeDragRef,
2306
+ elevation: iframeIsDragging ? 4 : 1,
1745
2307
  sx: {
1746
- display: "flex",
1747
- alignItems: "center",
1748
- justifyContent: "center",
1749
- flexDirection: "column"
2308
+ position: "fixed",
2309
+ left: iframePosition.x,
2310
+ top: iframePosition.y,
2311
+ p: 1,
2312
+ height: "auto",
2313
+ borderRadius: 2,
2314
+ bgcolor: "background.paper",
2315
+ zIndex: 99999,
2316
+ transition: theme.transitions.create(["box-shadow", "transform"], {
2317
+ duration: theme.transitions.duration.short
2318
+ }),
2319
+ visibility: showIframe ? "visible" : "hidden",
2320
+ userSelect: "none"
1750
2321
  },
1751
2322
  children: [
1752
2323
  /* @__PURE__ */ jsxs2(
1753
2324
  Box2,
1754
2325
  {
1755
2326
  sx: {
1756
- width: "100%",
1757
- height: "auto",
1758
2327
  display: "flex",
1759
2328
  alignItems: "center",
1760
2329
  justifyContent: "space-between",
@@ -1779,16 +2348,17 @@ function CallControlPanel({ onDataChange }) {
1779
2348
  /* @__PURE__ */ jsx3(
1780
2349
  "iframe",
1781
2350
  {
1782
- src: "https://h68.deepijatel.in/ConVoxCCS/iframe?agent_id=test&process_id=101",
1783
- height: 300,
1784
- width: 300
2351
+ src: `https://h68.deepijatel.in/ConVoxCCS/iframe?agent_id=${state.agentId}&process_id=${(_la = state.process) == null ? void 0 : _la.process_id}`,
2352
+ height: 380,
2353
+ width: 420,
2354
+ allow: "camera; microphone; autoplay"
1785
2355
  }
1786
2356
  )
1787
2357
  ]
1788
2358
  }
1789
2359
  )
1790
2360
  }
1791
- ) }),
2361
+ ),
1792
2362
  /* @__PURE__ */ jsx3(
1793
2363
  Menu,
1794
2364
  {
@@ -1847,8 +2417,8 @@ function CallControlPanel({ onDataChange }) {
1847
2417
  zIndex: 99999
1848
2418
  },
1849
2419
  children: [
1850
- /* @__PURE__ */ jsx3(MenuItem, { onClick: () => handleUpdateAgentStatus("break"), children: "- Lunch Break" }),
1851
- /* @__PURE__ */ jsx3(MenuItem, { onClick: () => handleUpdateAgentStatus("break"), children: "- Tea Break" })
2420
+ /* @__PURE__ */ jsx3(MenuItem, { onClick: () => handleUpdateAgentStatus("Lunch"), children: "- Lunch" }),
2421
+ /* @__PURE__ */ jsx3(MenuItem, { onClick: () => handleUpdateAgentStatus("Tea"), children: "- Tea" })
1852
2422
  ]
1853
2423
  }
1854
2424
  ),
@@ -1917,10 +2487,7 @@ function CallControlPanel({ onDataChange }) {
1917
2487
  ConferenceDialog,
1918
2488
  {
1919
2489
  open,
1920
- setOpen,
1921
- onConference: () => console.log("Conference"),
1922
- onExit: () => console.log("Exit"),
1923
- onEndAllCalls: () => console.log("End All Calls")
2490
+ setOpen
1924
2491
  }
1925
2492
  ),
1926
2493
  Boolean(openCallTransfer) && /* @__PURE__ */ jsx3(
@@ -1937,6 +2504,13 @@ function CallControlPanel({ onDataChange }) {
1937
2504
  setOpen: setOpenCallDisposition,
1938
2505
  onSubmitDisposition: handleEndCall
1939
2506
  }
2507
+ ),
2508
+ Boolean(openCallHistoryDialog) && /* @__PURE__ */ jsx3(
2509
+ CallHistoryDialog,
2510
+ {
2511
+ open: openCallHistoryDialog,
2512
+ setOpen: setOpenCallHistoryDialog
2513
+ }
1940
2514
  )
1941
2515
  ] });
1942
2516
  }
@@ -2346,22 +2920,53 @@ if (typeof window !== "undefined") {
2346
2920
  window.EventTracker = eventTracker;
2347
2921
  }
2348
2922
 
2923
+ // call-control-sdk/lib/hooks/useLogout.ts
2924
+ import { useCallback as useCallback4 } from "react";
2925
+ var useLogout = (options = {}) => {
2926
+ const { onSuccess, onError, onComplete } = options;
2927
+ const state = useSDKState();
2928
+ const [logOutAgent, logoutState] = usePostRequest({
2929
+ onSuccess: (response) => {
2930
+ onSuccess == null ? void 0 : onSuccess(response);
2931
+ onComplete == null ? void 0 : onComplete();
2932
+ sdkStateManager.clearStorageAndReset();
2933
+ localStorage.clear();
2934
+ },
2935
+ onError: (error) => {
2936
+ onError == null ? void 0 : onError(error);
2937
+ onComplete == null ? void 0 : onComplete();
2938
+ }
2939
+ });
2940
+ const handleLogout = useCallback4(() => {
2941
+ const payload = {
2942
+ action: "LOGOUTUSER",
2943
+ userId: state.agentId || ""
2944
+ };
2945
+ logOutAgent(END_POINT.LOGOUT, payload);
2946
+ }, [logOutAgent]);
2947
+ return {
2948
+ logout: handleLogout,
2949
+ isLoading: logoutState.isLoading,
2950
+ isSuccess: logoutState.isSuccess,
2951
+ isError: logoutState.isError,
2952
+ error: logoutState.error,
2953
+ data: logoutState.data
2954
+ };
2955
+ };
2956
+ var useLogout_default = useLogout;
2957
+
2349
2958
  // call-control-sdk/index.ts
2350
- function initSDK({
2351
- apiKey,
2352
- tenantId,
2353
- agentId,
2354
- baseUrl
2355
- }) {
2959
+ function initSDK({ apiKey, tenantId, agentId }) {
2356
2960
  sdkStateManager.initialize(apiKey, agentId);
2357
2961
  eventTracker.init({
2358
2962
  apiKey,
2359
2963
  tenantId,
2360
2964
  agentId,
2361
- baseUrl
2965
+ baseUrl: BASE_URL
2362
2966
  });
2363
2967
  }
2364
2968
  export {
2365
2969
  CallControlPanel,
2366
- initSDK
2970
+ initSDK,
2971
+ useLogout_default as useLogout
2367
2972
  };