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.js CHANGED
@@ -88,6 +88,7 @@ var END_POINT = {
88
88
  TRANSFER_CALL: `${BASE_URL}${VERSION.v1}/cti/calls/transfer?provider=convox`,
89
89
  AGENTS_LIST: `${BASE_URL}${VERSION.v1}/cti/users`,
90
90
  PROCESS_LIST: `${BASE_URL}${VERSION.v1}/cti/processes-list`,
91
+ BREAKS_LIST: `${BASE_URL}${VERSION.v1}/cti/breaks`,
91
92
  TRANSFER_TO_DETAILS: `${BASE_URL}${VERSION.v1}/cti/transfer-to-details?provider=convox`,
92
93
  SEND_NOTIFICATIONS: `${BASE_URL}${VERSION.v1}/cti/notifications/send`,
93
94
  CALL_HISTORY: `${BASE_URL}${VERSION.v1}/dashboard/call-history`,
@@ -201,7 +202,8 @@ var SDKStateManager = class {
201
202
  }
202
203
  ],
203
204
  hold: 0,
204
- mute: 0
205
+ mute: 0,
206
+ agentStatus: ""
205
207
  };
206
208
  }
207
209
  loadFromStorage() {
@@ -210,6 +212,7 @@ var SDKStateManager = class {
210
212
  const stored = (0, import_vault.getItem)(this.STORAGE_KEY);
211
213
  if (stored) {
212
214
  const parsedState = stored;
215
+ console.log("loading from storage", parsedState);
213
216
  this.state = __spreadProps(__spreadValues({}, this.state), {
214
217
  agentId: parsedState.agentId || "",
215
218
  authorization: parsedState.authorization || void 0,
@@ -249,7 +252,8 @@ var SDKStateManager = class {
249
252
  event_time: "",
250
253
  phone_number: ""
251
254
  },
252
- conferenceLine: parsedState.conferenceLine && Array.isArray(parsedState.conferenceLine) && parsedState.conferenceLine.length > 0 ? parsedState.conferenceLine : this.state.conferenceLine
255
+ conferenceLine: parsedState.conferenceLine && Array.isArray(parsedState.conferenceLine) && parsedState.conferenceLine.length > 0 ? parsedState.conferenceLine : this.state.conferenceLine,
256
+ agentStatus: parsedState.agentStatus
253
257
  });
254
258
  }
255
259
  } catch (error) {
@@ -270,7 +274,8 @@ var SDKStateManager = class {
270
274
  controlPanelPosition: this.state.controlPanelPosition,
271
275
  iframePosition: this.state.iframePosition,
272
276
  callData: this.state.callData,
273
- conferenceLine: this.state.conferenceLine
277
+ conferenceLine: this.state.conferenceLine,
278
+ agentStatus: this.state.agentStatus
274
279
  };
275
280
  (0, import_vault.setItem)(this.STORAGE_KEY, persistentState);
276
281
  } catch (error) {
@@ -387,6 +392,11 @@ var SDKStateManager = class {
387
392
  this.saveToStorage();
388
393
  this.notifyListeners();
389
394
  }
395
+ setAgentStatus(status) {
396
+ this.state.agentStatus = status;
397
+ this.saveToStorage();
398
+ this.notifyListeners();
399
+ }
390
400
  updateCallData(data) {
391
401
  this.state.callData = __spreadValues(__spreadValues({}, this.state.callData), data);
392
402
  this.saveToStorage();
@@ -656,10 +666,14 @@ var useLogout = () => {
656
666
  setSuccess(true);
657
667
  return res == null ? void 0 : res.data;
658
668
  }).catch((err) => {
659
- var _a2;
669
+ var _a2, _b, _c, _d;
660
670
  setIsError(true);
661
671
  setError(err);
662
- return (_a2 = err == null ? void 0 : err.response) == null ? void 0 : _a2.data;
672
+ 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) {
673
+ sdkStateManager.clearStorageAndReset();
674
+ (0, import_vault2.removeItem)(STORAGE_KEY);
675
+ }
676
+ return (_d = err == null ? void 0 : err.response) == null ? void 0 : _d.data;
663
677
  }).finally(() => {
664
678
  setLoading(false);
665
679
  });
@@ -1012,43 +1026,45 @@ var usePostRequest = (props = {}) => {
1012
1026
  const { showToast } = useToast();
1013
1027
  const [state, dispatch] = (0, import_react8.useReducer)(reducer, initialState);
1014
1028
  const postRequest = (0, import_react8.useCallback)(
1015
- (url, payload, config = {}) => {
1029
+ async (url, payload, config = {}) => {
1030
+ var _a2, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m;
1016
1031
  dispatch({
1017
1032
  type: "isLoading",
1018
1033
  payload: true
1019
1034
  });
1020
- axios_default.post(url, payload, config).then((res) => {
1021
- var _a2;
1022
- dispatch({
1023
- type: "isSuccess",
1024
- payload: res.data
1025
- });
1026
- onSuccess == null ? void 0 : onSuccess(res.data, payload);
1027
- if (!disabledSuccessToast) {
1028
- showToast((_a2 = res.data) == null ? void 0 : _a2.message, "success");
1035
+ try {
1036
+ try {
1037
+ const res = await axios_default.post(url, payload, config);
1038
+ dispatch({
1039
+ type: "isSuccess",
1040
+ payload: res.data
1041
+ });
1042
+ onSuccess == null ? void 0 : onSuccess(res.data, payload);
1043
+ if (!disabledSuccessToast) {
1044
+ showToast((_a2 = res.data) == null ? void 0 : _a2.message, "success");
1045
+ }
1046
+ } catch (err) {
1047
+ const error = {
1048
+ status: (_c = (_b = err.response) == null ? void 0 : _b.status) != null ? _c : 500,
1049
+ 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",
1050
+ data: (_i = (_h = err.response) == null ? void 0 : _h.data) != null ? _i : null,
1051
+ statusText: (_k = (_j = err.response) == null ? void 0 : _j.statusText) != null ? _k : "",
1052
+ code: (_l = err == null ? void 0 : err.code) != null ? _l : "",
1053
+ name: (_m = err == null ? void 0 : err.name) != null ? _m : ""
1054
+ };
1055
+ showToast(error.message, "error");
1056
+ dispatch({
1057
+ type: "isError",
1058
+ payload: error
1059
+ });
1060
+ onError == null ? void 0 : onError(error, payload);
1029
1061
  }
1030
- }).catch((err) => {
1031
- var _a2, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l;
1032
- const error = {
1033
- status: (_b = (_a2 = err.response) == null ? void 0 : _a2.status) != null ? _b : 500,
1034
- 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",
1035
- data: (_h = (_g = err.response) == null ? void 0 : _g.data) != null ? _h : null,
1036
- statusText: (_j = (_i = err.response) == null ? void 0 : _i.statusText) != null ? _j : "",
1037
- code: (_k = err == null ? void 0 : err.code) != null ? _k : "",
1038
- name: (_l = err == null ? void 0 : err.name) != null ? _l : ""
1039
- };
1040
- showToast(error.message, "error");
1041
- dispatch({
1042
- type: "isError",
1043
- payload: error
1044
- });
1045
- onError == null ? void 0 : onError(error, payload);
1046
- }).finally(() => {
1062
+ } finally {
1047
1063
  dispatch({
1048
1064
  type: "isLoading",
1049
1065
  payload: false
1050
1066
  });
1051
- });
1067
+ }
1052
1068
  },
1053
1069
  [onSuccess, onError, showToast]
1054
1070
  );
@@ -1121,7 +1137,7 @@ var styles_default = useStyles;
1121
1137
 
1122
1138
  // call-control-sdk/lib/components/dialog.tsx
1123
1139
  var import_jsx_runtime2 = require("react/jsx-runtime");
1124
- var ConferenceTableRow = ({ each }) => {
1140
+ var ConferenceTableRow = ({ each, isLineDialing }) => {
1125
1141
  var _a2, _b, _c, _d, _e, _f;
1126
1142
  const state = useSDKState();
1127
1143
  const theme = (0, import_material3.useTheme)();
@@ -1311,7 +1327,7 @@ var ConferenceTableRow = ({ each }) => {
1311
1327
  placeholder: "Phone Number",
1312
1328
  fullWidth: true,
1313
1329
  value: (each == null ? void 0 : each.phone) || "",
1314
- 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 : ""),
1330
+ 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,
1315
1331
  onChange: (e) => {
1316
1332
  onConferenceLineUpdate(each, { phone: e.target.value });
1317
1333
  }
@@ -1439,7 +1455,7 @@ var ConferenceTableRow = ({ each }) => {
1439
1455
  onClick: () => {
1440
1456
  onConferenceCallStart(each, {});
1441
1457
  },
1442
- disabled: (each == null ? void 0 : each.status) !== "IDLE" /* IDLE */,
1458
+ disabled: (each == null ? void 0 : each.status) !== "IDLE" /* IDLE */ || isLineDialing,
1443
1459
  children: conferenceCallStart ? /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
1444
1460
  import_material3.CircularProgress,
1445
1461
  {
@@ -1540,7 +1556,7 @@ var ConferenceTableRow = ({ each }) => {
1540
1556
  );
1541
1557
  };
1542
1558
  function ConferenceDialog() {
1543
- var _a2;
1559
+ var _a2, _b;
1544
1560
  const state = useSDKState();
1545
1561
  const { showToast } = useToast();
1546
1562
  const [conferenceCallEndAll, setConferenceCallEndAll] = (0, import_react9.useState)(false);
@@ -1548,12 +1564,12 @@ function ConferenceDialog() {
1548
1564
  sdkStateManager.setOpenConferenceDialog(false);
1549
1565
  };
1550
1566
  const onEndAllConferenceCalls = () => {
1551
- var _a3, _b, _c, _d;
1567
+ var _a3, _b2, _c, _d;
1552
1568
  setConferenceCallEndAll(true);
1553
1569
  const payload = {
1554
1570
  action: "EXTERNAL_CONFERENCE",
1555
1571
  operation: "ENDCONFERENCE",
1556
- userid: (_b = (_a3 = state.callData) == null ? void 0 : _a3.agent_id) != null ? _b : "",
1572
+ userid: (_b2 = (_a3 = state.callData) == null ? void 0 : _a3.agent_id) != null ? _b2 : "",
1557
1573
  process: (_d = (_c = state.callData) == null ? void 0 : _c.process_name) != null ? _d : ""
1558
1574
  };
1559
1575
  axios_default.post(END_POINT.CONFERENCE_CALL_END_ALL, payload).then((res) => {
@@ -1562,13 +1578,15 @@ function ConferenceDialog() {
1562
1578
  sdkStateManager.resetConferenceLines();
1563
1579
  handleClose();
1564
1580
  }).catch((err) => {
1565
- var _a4, _b2, _c2, _d2;
1566
- 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";
1581
+ var _a4, _b3, _c2, _d2;
1582
+ 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";
1567
1583
  showToast(message, "error");
1568
1584
  }).finally(() => {
1569
1585
  setConferenceCallEndAll(false);
1570
1586
  });
1571
1587
  };
1588
+ const isLineDialing = (_a2 = state == null ? void 0 : state.conferenceLine) == null ? void 0 : _a2.some((item) => (item == null ? void 0 : item.status) === "DIALING" /* DIALING */);
1589
+ console.log("dataaaaa", state == null ? void 0 : state.conferenceLine, isLineDialing);
1572
1590
  return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_jsx_runtime2.Fragment, { children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
1573
1591
  import_material3.Dialog,
1574
1592
  {
@@ -1588,7 +1606,7 @@ function ConferenceDialog() {
1588
1606
  },
1589
1607
  children: [
1590
1608
  /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(import_material3.Typography, { variant: "body1", children: [
1591
- (_a2 = state == null ? void 0 : state.agentId) != null ? _a2 : "",
1609
+ (_b = state == null ? void 0 : state.agentId) != null ? _b : "",
1592
1610
  " conference"
1593
1611
  ] }),
1594
1612
  /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_material3.IconButton, { onClick: handleClose, children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_icons_material.Close, {}) })
@@ -1664,7 +1682,7 @@ function ConferenceDialog() {
1664
1682
  ]
1665
1683
  }
1666
1684
  ) }),
1667
- /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_material3.TableBody, { children: state == null ? void 0 : state.conferenceLine.map((each) => /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(ConferenceTableRow, { each })) })
1685
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_material3.TableBody, { children: state == null ? void 0 : state.conferenceLine.map((each) => /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(ConferenceTableRow, { each, isLineDialing })) })
1668
1686
  ]
1669
1687
  }
1670
1688
  )
@@ -2994,6 +3012,7 @@ function CallControls({ onDataChange }) {
2994
3012
  const [openProcessorDialog, setOpenProcessorDialog] = (0, import_react11.useState)(false);
2995
3013
  const [openCallHistoryDialog, setOpenCallHistoryDialog] = (0, import_react11.useState)(false);
2996
3014
  const [processList, setProcessList] = (0, import_react11.useState)(null);
3015
+ const [breaksList, setBreaksList] = (0, import_react11.useState)(null);
2997
3016
  const [phoneNumber, setPhoneNumber] = (0, import_react11.useState)("");
2998
3017
  const [callDuration, setCallDuration] = (0, import_react11.useState)(0);
2999
3018
  const [callWrapuptime, setCallWrapuptime] = (0, import_react11.useState)(null);
@@ -3027,7 +3046,11 @@ function CallControls({ onDataChange }) {
3027
3046
  // sdkStateManager.setMuted(!state.isMuted);
3028
3047
  // },
3029
3048
  });
3030
- const [readyAgentStatus, { isLoading: agentReadyLoading }] = usePostRequest();
3049
+ const [readyAgentStatus, { isLoading: agentReadyLoading }] = usePostRequest({
3050
+ onSuccess: () => {
3051
+ sdkStateManager.setAgentStatus("");
3052
+ }
3053
+ });
3031
3054
  const [updateAgentStatus, { isLoading }] = usePostRequest();
3032
3055
  const [sendNotification] = usePostRequest();
3033
3056
  const [endCall, { isLoading: endCallLoading }] = usePostRequest({
@@ -3079,7 +3102,9 @@ function CallControls({ onDataChange }) {
3079
3102
  break_type: status,
3080
3103
  userId: state.agentId
3081
3104
  };
3082
- updateAgentStatus(END_POINT.UPDATE_AGENT_BREAK, payload);
3105
+ updateAgentStatus(END_POINT.UPDATE_AGENT_BREAK, payload).then(() => {
3106
+ sdkStateManager.setAgentStatus(status);
3107
+ });
3083
3108
  };
3084
3109
  const handleStartCall = (number) => {
3085
3110
  if (number.length !== 10) {
@@ -3213,7 +3238,7 @@ function CallControls({ onDataChange }) {
3213
3238
  if (prevTime === null || prevTime <= 1) {
3214
3239
  clearInterval(wrapUpinterval);
3215
3240
  handleEndCall({
3216
- disposition: { label: "Resolved", value: "RES" },
3241
+ disposition: { label: "Resolved", value: "AUTO_WRAPUP" },
3217
3242
  followUp: { label: "No", value: "N" },
3218
3243
  callbackDate: "",
3219
3244
  callbackHrs: "",
@@ -3279,6 +3304,14 @@ function CallControls({ onDataChange }) {
3279
3304
  }).catch((err) => {
3280
3305
  showToast(err.response.data.message, "error");
3281
3306
  });
3307
+ axios_default.get(END_POINT.BREAKS_LIST).then((res) => {
3308
+ var _a3, _b2, _c2;
3309
+ 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)) {
3310
+ setBreaksList(res.data.data);
3311
+ }
3312
+ }).catch((err) => {
3313
+ showToast(err.response.data.message, "error");
3314
+ });
3282
3315
  }
3283
3316
  }, [state.agentId]);
3284
3317
  const connectWebSocket = () => {
@@ -3832,7 +3865,7 @@ function CallControls({ onDataChange }) {
3832
3865
  ) : /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_icons_material2.CallEnd, {})
3833
3866
  }
3834
3867
  ) }),
3835
- !((_ua = state.sdkConfig) == null ? void 0 : _ua.disabledMoreOptionsButton) && (processList && (processList == null ? void 0 : processList.length) > 1) && /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_material4.Tooltip, { title: "Switch Process", children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
3868
+ !((_ua = state.sdkConfig) == null ? void 0 : _ua.disabledMoreOptionsButton) && processList && (processList == null ? void 0 : processList.length) > 1 && /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_material4.Tooltip, { title: "Switch Process", children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
3836
3869
  import_material4.Button,
3837
3870
  {
3838
3871
  variant: Boolean(moreOptionsAnchorEl) ? "contained" : "outlined",
@@ -4115,7 +4148,32 @@ function CallControls({ onDataChange }) {
4115
4148
  sx: {
4116
4149
  zIndex: 99999
4117
4150
  },
4118
- children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_material4.MenuItem, { onClick: () => handleUpdateAgentStatus("Lunch"), children: "- Break" })
4151
+ children: !breaksList || (breaksList == null ? void 0 : breaksList.length) === 0 ? /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_material4.MenuItem, { onClick: () => handleUpdateAgentStatus("Lunch"), children: "- Break" }) : breaksList == null ? void 0 : breaksList.map((item) => {
4152
+ var _a3, _b2, _c2;
4153
+ return /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(
4154
+ import_material4.MenuItem,
4155
+ {
4156
+ sx: {
4157
+ // hilight background of selected
4158
+ 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",
4159
+ 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",
4160
+ ":hover": {
4161
+ 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"
4162
+ // color:
4163
+ // state?.callData?.status === "BREAK" && state?.agentStatus === item?.type ?
4164
+ // "primary.main"
4165
+ // : "primary.main",
4166
+ }
4167
+ },
4168
+ onClick: () => handleUpdateAgentStatus(item == null ? void 0 : item.type),
4169
+ children: [
4170
+ "- ",
4171
+ item == null ? void 0 : item.type
4172
+ ]
4173
+ },
4174
+ item == null ? void 0 : item.type
4175
+ );
4176
+ })
4119
4177
  }
4120
4178
  ),
4121
4179
  /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(