call-control-sdk 6.5.5-uat.2 → 6.5.5-uat.4

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
@@ -47,6 +47,7 @@ var END_POINT = {
47
47
  TRANSFER_CALL: `${BASE_URL}${VERSION.v1}/cti/calls/transfer?provider=convox`,
48
48
  AGENTS_LIST: `${BASE_URL}${VERSION.v1}/cti/users`,
49
49
  PROCESS_LIST: `${BASE_URL}${VERSION.v1}/cti/processes-list`,
50
+ BREAKS_LIST: `${BASE_URL}${VERSION.v1}/cti/breaks`,
50
51
  TRANSFER_TO_DETAILS: `${BASE_URL}${VERSION.v1}/cti/transfer-to-details?provider=convox`,
51
52
  SEND_NOTIFICATIONS: `${BASE_URL}${VERSION.v1}/cti/notifications/send`,
52
53
  CALL_HISTORY: `${BASE_URL}${VERSION.v1}/dashboard/call-history`,
@@ -160,7 +161,8 @@ var SDKStateManager = class {
160
161
  }
161
162
  ],
162
163
  hold: 0,
163
- mute: 0
164
+ mute: 0,
165
+ agentStatus: ""
164
166
  };
165
167
  }
166
168
  loadFromStorage() {
@@ -169,6 +171,7 @@ var SDKStateManager = class {
169
171
  const stored = getItem(this.STORAGE_KEY);
170
172
  if (stored) {
171
173
  const parsedState = stored;
174
+ console.log("loading from storage", parsedState);
172
175
  this.state = __spreadProps(__spreadValues({}, this.state), {
173
176
  agentId: parsedState.agentId || "",
174
177
  authorization: parsedState.authorization || void 0,
@@ -208,7 +211,8 @@ var SDKStateManager = class {
208
211
  event_time: "",
209
212
  phone_number: ""
210
213
  },
211
- conferenceLine: parsedState.conferenceLine && Array.isArray(parsedState.conferenceLine) && parsedState.conferenceLine.length > 0 ? parsedState.conferenceLine : this.state.conferenceLine
214
+ conferenceLine: parsedState.conferenceLine && Array.isArray(parsedState.conferenceLine) && parsedState.conferenceLine.length > 0 ? parsedState.conferenceLine : this.state.conferenceLine,
215
+ agentStatus: parsedState.agentStatus
212
216
  });
213
217
  }
214
218
  } catch (error) {
@@ -229,7 +233,8 @@ var SDKStateManager = class {
229
233
  controlPanelPosition: this.state.controlPanelPosition,
230
234
  iframePosition: this.state.iframePosition,
231
235
  callData: this.state.callData,
232
- conferenceLine: this.state.conferenceLine
236
+ conferenceLine: this.state.conferenceLine,
237
+ agentStatus: this.state.agentStatus
233
238
  };
234
239
  setItem(this.STORAGE_KEY, persistentState);
235
240
  } catch (error) {
@@ -346,6 +351,11 @@ var SDKStateManager = class {
346
351
  this.saveToStorage();
347
352
  this.notifyListeners();
348
353
  }
354
+ setAgentStatus(status) {
355
+ this.state.agentStatus = status;
356
+ this.saveToStorage();
357
+ this.notifyListeners();
358
+ }
349
359
  updateCallData(data) {
350
360
  this.state.callData = __spreadValues(__spreadValues({}, this.state.callData), data);
351
361
  this.saveToStorage();
@@ -615,10 +625,14 @@ var useLogout = () => {
615
625
  setSuccess(true);
616
626
  return res == null ? void 0 : res.data;
617
627
  }).catch((err) => {
618
- var _a2;
628
+ var _a2, _b, _c, _d;
619
629
  setIsError(true);
620
630
  setError(err);
621
- return (_a2 = err == null ? void 0 : err.response) == null ? void 0 : _a2.data;
631
+ if ((_c = (_b = (_a2 = err == null ? void 0 : err.response) == null ? void 0 : _a2.data) == null ? void 0 : _b.data) == null ? void 0 : _c.clearAgentData) {
632
+ sdkStateManager.clearStorageAndReset();
633
+ removeItem2(STORAGE_KEY);
634
+ }
635
+ return (_d = err == null ? void 0 : err.response) == null ? void 0 : _d.data;
622
636
  }).finally(() => {
623
637
  setLoading(false);
624
638
  });
@@ -1037,43 +1051,45 @@ var usePostRequest = (props = {}) => {
1037
1051
  const { showToast } = useToast();
1038
1052
  const [state, dispatch] = useReducer(reducer, initialState);
1039
1053
  const postRequest = useCallback4(
1040
- (url, payload, config = {}) => {
1054
+ async (url, payload, config = {}) => {
1055
+ var _a2, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m;
1041
1056
  dispatch({
1042
1057
  type: "isLoading",
1043
1058
  payload: true
1044
1059
  });
1045
- axios_default.post(url, payload, config).then((res) => {
1046
- var _a2;
1047
- dispatch({
1048
- type: "isSuccess",
1049
- payload: res.data
1050
- });
1051
- onSuccess == null ? void 0 : onSuccess(res.data, payload);
1052
- if (!disabledSuccessToast) {
1053
- showToast((_a2 = res.data) == null ? void 0 : _a2.message, "success");
1060
+ try {
1061
+ try {
1062
+ const res = await axios_default.post(url, payload, config);
1063
+ dispatch({
1064
+ type: "isSuccess",
1065
+ payload: res.data
1066
+ });
1067
+ onSuccess == null ? void 0 : onSuccess(res.data, payload);
1068
+ if (!disabledSuccessToast) {
1069
+ showToast((_a2 = res.data) == null ? void 0 : _a2.message, "success");
1070
+ }
1071
+ } catch (err) {
1072
+ const error = {
1073
+ status: (_c = (_b = err.response) == null ? void 0 : _b.status) != null ? _c : 500,
1074
+ message: ((_e = (_d = err.response) == null ? void 0 : _d.data) == null ? void 0 : _e.detail) || ((_g = (_f = err.response) == null ? void 0 : _f.data) == null ? void 0 : _g.message) || err.message || "An unknown error occurred",
1075
+ data: (_i = (_h = err.response) == null ? void 0 : _h.data) != null ? _i : null,
1076
+ statusText: (_k = (_j = err.response) == null ? void 0 : _j.statusText) != null ? _k : "",
1077
+ code: (_l = err == null ? void 0 : err.code) != null ? _l : "",
1078
+ name: (_m = err == null ? void 0 : err.name) != null ? _m : ""
1079
+ };
1080
+ showToast(error.message, "error");
1081
+ dispatch({
1082
+ type: "isError",
1083
+ payload: error
1084
+ });
1085
+ onError == null ? void 0 : onError(error, payload);
1054
1086
  }
1055
- }).catch((err) => {
1056
- var _a2, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l;
1057
- const error = {
1058
- status: (_b = (_a2 = err.response) == null ? void 0 : _a2.status) != null ? _b : 500,
1059
- message: ((_d = (_c = err.response) == null ? void 0 : _c.data) == null ? void 0 : _d.detail) || ((_f = (_e = err.response) == null ? void 0 : _e.data) == null ? void 0 : _f.message) || err.message || "An unknown error occurred",
1060
- data: (_h = (_g = err.response) == null ? void 0 : _g.data) != null ? _h : null,
1061
- statusText: (_j = (_i = err.response) == null ? void 0 : _i.statusText) != null ? _j : "",
1062
- code: (_k = err == null ? void 0 : err.code) != null ? _k : "",
1063
- name: (_l = err == null ? void 0 : err.name) != null ? _l : ""
1064
- };
1065
- showToast(error.message, "error");
1066
- dispatch({
1067
- type: "isError",
1068
- payload: error
1069
- });
1070
- onError == null ? void 0 : onError(error, payload);
1071
- }).finally(() => {
1087
+ } finally {
1072
1088
  dispatch({
1073
1089
  type: "isLoading",
1074
1090
  payload: false
1075
1091
  });
1076
- });
1092
+ }
1077
1093
  },
1078
1094
  [onSuccess, onError, showToast]
1079
1095
  );
@@ -1146,7 +1162,7 @@ var styles_default = useStyles;
1146
1162
 
1147
1163
  // call-control-sdk/lib/components/dialog.tsx
1148
1164
  import { Fragment, jsx as jsx2, jsxs as jsxs2 } from "react/jsx-runtime";
1149
- var ConferenceTableRow = ({ each }) => {
1165
+ var ConferenceTableRow = ({ each, isLineDialing }) => {
1150
1166
  var _a2, _b, _c, _d, _e, _f;
1151
1167
  const state = useSDKState();
1152
1168
  const theme = useTheme2();
@@ -1336,7 +1352,7 @@ var ConferenceTableRow = ({ each }) => {
1336
1352
  placeholder: "Phone Number",
1337
1353
  fullWidth: true,
1338
1354
  value: (each == null ? void 0 : each.phone) || "",
1339
- disabled: (each == null ? void 0 : each.line) === 1 || ["ONCALL" /* ONCALL */, "DISCONNECTED" /* DISCONNECTED */, "CONFERENCE" /* CONFERENCE */, "HOLD" /* HOLD */, "MUTE" /* MUTE */, "DIALING" /* DIALING */, "RINGING" /* RINGING */].includes((_f = each == null ? void 0 : each.status) != null ? _f : ""),
1355
+ disabled: (each == null ? void 0 : each.line) === 1 || ["ONCALL" /* ONCALL */, "DISCONNECTED" /* DISCONNECTED */, "CONFERENCE" /* CONFERENCE */, "HOLD" /* HOLD */, "MUTE" /* MUTE */, "DIALING" /* DIALING */, "RINGING" /* RINGING */].includes((_f = each == null ? void 0 : each.status) != null ? _f : "") || isLineDialing,
1340
1356
  onChange: (e) => {
1341
1357
  onConferenceLineUpdate(each, { phone: e.target.value });
1342
1358
  }
@@ -1464,7 +1480,7 @@ var ConferenceTableRow = ({ each }) => {
1464
1480
  onClick: () => {
1465
1481
  onConferenceCallStart(each, {});
1466
1482
  },
1467
- disabled: (each == null ? void 0 : each.status) !== "IDLE" /* IDLE */,
1483
+ disabled: (each == null ? void 0 : each.status) !== "IDLE" /* IDLE */ || isLineDialing,
1468
1484
  children: conferenceCallStart ? /* @__PURE__ */ jsx2(
1469
1485
  CircularProgress,
1470
1486
  {
@@ -1565,7 +1581,7 @@ var ConferenceTableRow = ({ each }) => {
1565
1581
  );
1566
1582
  };
1567
1583
  function ConferenceDialog() {
1568
- var _a2;
1584
+ var _a2, _b;
1569
1585
  const state = useSDKState();
1570
1586
  const { showToast } = useToast();
1571
1587
  const [conferenceCallEndAll, setConferenceCallEndAll] = useState8(false);
@@ -1573,12 +1589,12 @@ function ConferenceDialog() {
1573
1589
  sdkStateManager.setOpenConferenceDialog(false);
1574
1590
  };
1575
1591
  const onEndAllConferenceCalls = () => {
1576
- var _a3, _b, _c, _d;
1592
+ var _a3, _b2, _c, _d;
1577
1593
  setConferenceCallEndAll(true);
1578
1594
  const payload = {
1579
1595
  action: "EXTERNAL_CONFERENCE",
1580
1596
  operation: "ENDCONFERENCE",
1581
- userid: (_b = (_a3 = state.callData) == null ? void 0 : _a3.agent_id) != null ? _b : "",
1597
+ userid: (_b2 = (_a3 = state.callData) == null ? void 0 : _a3.agent_id) != null ? _b2 : "",
1582
1598
  process: (_d = (_c = state.callData) == null ? void 0 : _c.process_name) != null ? _d : ""
1583
1599
  };
1584
1600
  axios_default.post(END_POINT.CONFERENCE_CALL_END_ALL, payload).then((res) => {
@@ -1587,13 +1603,15 @@ function ConferenceDialog() {
1587
1603
  sdkStateManager.resetConferenceLines();
1588
1604
  handleClose();
1589
1605
  }).catch((err) => {
1590
- var _a4, _b2, _c2, _d2;
1591
- const message = ((_b2 = (_a4 = err.response) == null ? void 0 : _a4.data) == null ? void 0 : _b2.detail) || ((_d2 = (_c2 = err.response) == null ? void 0 : _c2.data) == null ? void 0 : _d2.message) || err.message || "An unknown error occurred";
1606
+ var _a4, _b3, _c2, _d2;
1607
+ const message = ((_b3 = (_a4 = err.response) == null ? void 0 : _a4.data) == null ? void 0 : _b3.detail) || ((_d2 = (_c2 = err.response) == null ? void 0 : _c2.data) == null ? void 0 : _d2.message) || err.message || "An unknown error occurred";
1592
1608
  showToast(message, "error");
1593
1609
  }).finally(() => {
1594
1610
  setConferenceCallEndAll(false);
1595
1611
  });
1596
1612
  };
1613
+ const isLineDialing = (_a2 = state == null ? void 0 : state.conferenceLine) == null ? void 0 : _a2.some((item) => (item == null ? void 0 : item.status) === "DIALING" /* DIALING */);
1614
+ console.log("dataaaaa", state == null ? void 0 : state.conferenceLine, isLineDialing);
1597
1615
  return /* @__PURE__ */ jsx2(Fragment, { children: /* @__PURE__ */ jsx2(
1598
1616
  Dialog,
1599
1617
  {
@@ -1613,7 +1631,7 @@ function ConferenceDialog() {
1613
1631
  },
1614
1632
  children: [
1615
1633
  /* @__PURE__ */ jsxs2(Typography, { variant: "body1", children: [
1616
- (_a2 = state == null ? void 0 : state.agentId) != null ? _a2 : "",
1634
+ (_b = state == null ? void 0 : state.agentId) != null ? _b : "",
1617
1635
  " conference"
1618
1636
  ] }),
1619
1637
  /* @__PURE__ */ jsx2(IconButton, { onClick: handleClose, children: /* @__PURE__ */ jsx2(Close, {}) })
@@ -1689,7 +1707,7 @@ function ConferenceDialog() {
1689
1707
  ]
1690
1708
  }
1691
1709
  ) }),
1692
- /* @__PURE__ */ jsx2(TableBody, { children: state == null ? void 0 : state.conferenceLine.map((each) => /* @__PURE__ */ jsx2(ConferenceTableRow, { each })) })
1710
+ /* @__PURE__ */ jsx2(TableBody, { children: state == null ? void 0 : state.conferenceLine.map((each) => /* @__PURE__ */ jsx2(ConferenceTableRow, { each, isLineDialing })) })
1693
1711
  ]
1694
1712
  }
1695
1713
  )
@@ -3019,6 +3037,7 @@ function CallControls({ onDataChange }) {
3019
3037
  const [openProcessorDialog, setOpenProcessorDialog] = useState10(false);
3020
3038
  const [openCallHistoryDialog, setOpenCallHistoryDialog] = useState10(false);
3021
3039
  const [processList, setProcessList] = useState10(null);
3040
+ const [breaksList, setBreaksList] = useState10(null);
3022
3041
  const [phoneNumber, setPhoneNumber] = useState10("");
3023
3042
  const [callDuration, setCallDuration] = useState10(0);
3024
3043
  const [callWrapuptime, setCallWrapuptime] = useState10(null);
@@ -3052,7 +3071,11 @@ function CallControls({ onDataChange }) {
3052
3071
  // sdkStateManager.setMuted(!state.isMuted);
3053
3072
  // },
3054
3073
  });
3055
- const [readyAgentStatus, { isLoading: agentReadyLoading }] = usePostRequest();
3074
+ const [readyAgentStatus, { isLoading: agentReadyLoading }] = usePostRequest({
3075
+ onSuccess: () => {
3076
+ sdkStateManager.setAgentStatus("");
3077
+ }
3078
+ });
3056
3079
  const [updateAgentStatus, { isLoading }] = usePostRequest();
3057
3080
  const [sendNotification] = usePostRequest();
3058
3081
  const [endCall, { isLoading: endCallLoading }] = usePostRequest({
@@ -3104,7 +3127,9 @@ function CallControls({ onDataChange }) {
3104
3127
  break_type: status,
3105
3128
  userId: state.agentId
3106
3129
  };
3107
- updateAgentStatus(END_POINT.UPDATE_AGENT_BREAK, payload);
3130
+ updateAgentStatus(END_POINT.UPDATE_AGENT_BREAK, payload).then(() => {
3131
+ sdkStateManager.setAgentStatus(status);
3132
+ });
3108
3133
  };
3109
3134
  const handleStartCall = (number) => {
3110
3135
  if (number.length !== 10) {
@@ -3238,7 +3263,7 @@ function CallControls({ onDataChange }) {
3238
3263
  if (prevTime === null || prevTime <= 1) {
3239
3264
  clearInterval(wrapUpinterval);
3240
3265
  handleEndCall({
3241
- disposition: { label: "Resolved", value: "RES" },
3266
+ disposition: { label: "Resolved", value: "AUTO_WRAPUP" },
3242
3267
  followUp: { label: "No", value: "N" },
3243
3268
  callbackDate: "",
3244
3269
  callbackHrs: "",
@@ -3304,6 +3329,14 @@ function CallControls({ onDataChange }) {
3304
3329
  }).catch((err) => {
3305
3330
  showToast(err.response.data.message, "error");
3306
3331
  });
3332
+ axios_default.get(END_POINT.BREAKS_LIST).then((res) => {
3333
+ var _a3, _b2, _c2;
3334
+ if (res && ((_a3 = res.data) == null ? void 0 : _a3.data) && ((_c2 = (_b2 = res == null ? void 0 : res.data) == null ? void 0 : _b2.data) == null ? void 0 : _c2.length)) {
3335
+ setBreaksList(res.data.data);
3336
+ }
3337
+ }).catch((err) => {
3338
+ showToast(err.response.data.message, "error");
3339
+ });
3307
3340
  }
3308
3341
  }, [state.agentId]);
3309
3342
  const connectWebSocket = () => {
@@ -3857,7 +3890,7 @@ function CallControls({ onDataChange }) {
3857
3890
  ) : /* @__PURE__ */ jsx3(CallEnd2, {})
3858
3891
  }
3859
3892
  ) }),
3860
- !((_ua = state.sdkConfig) == null ? void 0 : _ua.disabledMoreOptionsButton) && (processList && (processList == null ? void 0 : processList.length) > 1) && /* @__PURE__ */ jsx3(Tooltip2, { title: "Switch Process", children: /* @__PURE__ */ jsx3(
3893
+ !((_ua = state.sdkConfig) == null ? void 0 : _ua.disabledMoreOptionsButton) && processList && (processList == null ? void 0 : processList.length) > 1 && /* @__PURE__ */ jsx3(Tooltip2, { title: "Switch Process", children: /* @__PURE__ */ jsx3(
3861
3894
  Button2,
3862
3895
  {
3863
3896
  variant: Boolean(moreOptionsAnchorEl) ? "contained" : "outlined",
@@ -4140,7 +4173,32 @@ function CallControls({ onDataChange }) {
4140
4173
  sx: {
4141
4174
  zIndex: 99999
4142
4175
  },
4143
- children: /* @__PURE__ */ jsx3(MenuItem, { onClick: () => handleUpdateAgentStatus("Lunch"), children: "- Break" })
4176
+ children: !breaksList || (breaksList == null ? void 0 : breaksList.length) === 0 ? /* @__PURE__ */ jsx3(MenuItem, { onClick: () => handleUpdateAgentStatus("Lunch"), children: "- Break" }) : breaksList == null ? void 0 : breaksList.map((item) => {
4177
+ var _a3, _b2, _c2;
4178
+ return /* @__PURE__ */ jsxs3(
4179
+ MenuItem,
4180
+ {
4181
+ sx: {
4182
+ // hilight background of selected
4183
+ backgroundColor: ((_a3 = state == null ? void 0 : state.callData) == null ? void 0 : _a3.status) === "BREAK" && (state == null ? void 0 : state.agentStatus) === (item == null ? void 0 : item.type) ? "primary.main" : "transparent",
4184
+ color: ((_b2 = state == null ? void 0 : state.callData) == null ? void 0 : _b2.status) === "BREAK" && (state == null ? void 0 : state.agentStatus) === (item == null ? void 0 : item.type) ? "white" : "primary.main",
4185
+ ":hover": {
4186
+ backgroundColor: ((_c2 = state == null ? void 0 : state.callData) == null ? void 0 : _c2.status) === "BREAK" && (state == null ? void 0 : state.agentStatus) === (item == null ? void 0 : item.type) ? "primary.dark" : "selected.hover"
4187
+ // color:
4188
+ // state?.callData?.status === "BREAK" && state?.agentStatus === item?.type ?
4189
+ // "primary.main"
4190
+ // : "primary.main",
4191
+ }
4192
+ },
4193
+ onClick: () => handleUpdateAgentStatus(item == null ? void 0 : item.type),
4194
+ children: [
4195
+ "- ",
4196
+ item == null ? void 0 : item.type
4197
+ ]
4198
+ },
4199
+ item == null ? void 0 : item.type
4200
+ );
4201
+ })
4144
4202
  }
4145
4203
  ),
4146
4204
  /* @__PURE__ */ jsx3(