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

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
  );
@@ -3019,6 +3035,7 @@ function CallControls({ onDataChange }) {
3019
3035
  const [openProcessorDialog, setOpenProcessorDialog] = useState10(false);
3020
3036
  const [openCallHistoryDialog, setOpenCallHistoryDialog] = useState10(false);
3021
3037
  const [processList, setProcessList] = useState10(null);
3038
+ const [breaksList, setBreaksList] = useState10(null);
3022
3039
  const [phoneNumber, setPhoneNumber] = useState10("");
3023
3040
  const [callDuration, setCallDuration] = useState10(0);
3024
3041
  const [callWrapuptime, setCallWrapuptime] = useState10(null);
@@ -3052,7 +3069,11 @@ function CallControls({ onDataChange }) {
3052
3069
  // sdkStateManager.setMuted(!state.isMuted);
3053
3070
  // },
3054
3071
  });
3055
- const [readyAgentStatus, { isLoading: agentReadyLoading }] = usePostRequest();
3072
+ const [readyAgentStatus, { isLoading: agentReadyLoading }] = usePostRequest({
3073
+ onSuccess: () => {
3074
+ sdkStateManager.setAgentStatus("");
3075
+ }
3076
+ });
3056
3077
  const [updateAgentStatus, { isLoading }] = usePostRequest();
3057
3078
  const [sendNotification] = usePostRequest();
3058
3079
  const [endCall, { isLoading: endCallLoading }] = usePostRequest({
@@ -3104,7 +3125,9 @@ function CallControls({ onDataChange }) {
3104
3125
  break_type: status,
3105
3126
  userId: state.agentId
3106
3127
  };
3107
- updateAgentStatus(END_POINT.UPDATE_AGENT_BREAK, payload);
3128
+ updateAgentStatus(END_POINT.UPDATE_AGENT_BREAK, payload).then(() => {
3129
+ sdkStateManager.setAgentStatus(status);
3130
+ });
3108
3131
  };
3109
3132
  const handleStartCall = (number) => {
3110
3133
  if (number.length !== 10) {
@@ -3238,7 +3261,7 @@ function CallControls({ onDataChange }) {
3238
3261
  if (prevTime === null || prevTime <= 1) {
3239
3262
  clearInterval(wrapUpinterval);
3240
3263
  handleEndCall({
3241
- disposition: { label: "Resolved", value: "RES" },
3264
+ disposition: { label: "Resolved", value: "AUTO_WRAPUP" },
3242
3265
  followUp: { label: "No", value: "N" },
3243
3266
  callbackDate: "",
3244
3267
  callbackHrs: "",
@@ -3304,6 +3327,14 @@ function CallControls({ onDataChange }) {
3304
3327
  }).catch((err) => {
3305
3328
  showToast(err.response.data.message, "error");
3306
3329
  });
3330
+ axios_default.get(END_POINT.BREAKS_LIST).then((res) => {
3331
+ var _a3, _b2, _c2;
3332
+ 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)) {
3333
+ setBreaksList(res.data.data);
3334
+ }
3335
+ }).catch((err) => {
3336
+ showToast(err.response.data.message, "error");
3337
+ });
3307
3338
  }
3308
3339
  }, [state.agentId]);
3309
3340
  const connectWebSocket = () => {
@@ -3857,7 +3888,7 @@ function CallControls({ onDataChange }) {
3857
3888
  ) : /* @__PURE__ */ jsx3(CallEnd2, {})
3858
3889
  }
3859
3890
  ) }),
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(
3891
+ !((_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
3892
  Button2,
3862
3893
  {
3863
3894
  variant: Boolean(moreOptionsAnchorEl) ? "contained" : "outlined",
@@ -4140,7 +4171,32 @@ function CallControls({ onDataChange }) {
4140
4171
  sx: {
4141
4172
  zIndex: 99999
4142
4173
  },
4143
- children: /* @__PURE__ */ jsx3(MenuItem, { onClick: () => handleUpdateAgentStatus("Lunch"), children: "- Break" })
4174
+ children: !breaksList || (breaksList == null ? void 0 : breaksList.length) === 0 ? /* @__PURE__ */ jsx3(MenuItem, { onClick: () => handleUpdateAgentStatus("Lunch"), children: "- Break" }) : breaksList == null ? void 0 : breaksList.map((item) => {
4175
+ var _a3, _b2, _c2;
4176
+ return /* @__PURE__ */ jsxs3(
4177
+ MenuItem,
4178
+ {
4179
+ sx: {
4180
+ // hilight background of selected
4181
+ 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",
4182
+ 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",
4183
+ ":hover": {
4184
+ 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"
4185
+ // color:
4186
+ // state?.callData?.status === "BREAK" && state?.agentStatus === item?.type ?
4187
+ // "primary.main"
4188
+ // : "primary.main",
4189
+ }
4190
+ },
4191
+ onClick: () => handleUpdateAgentStatus(item == null ? void 0 : item.type),
4192
+ children: [
4193
+ "- ",
4194
+ item == null ? void 0 : item.type
4195
+ ]
4196
+ },
4197
+ item == null ? void 0 : item.type
4198
+ );
4199
+ })
4144
4200
  }
4145
4201
  ),
4146
4202
  /* @__PURE__ */ jsx3(