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.js +94 -38
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +94 -38
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
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
|
-
|
|
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
|
-
|
|
1021
|
-
|
|
1022
|
-
|
|
1023
|
-
|
|
1024
|
-
|
|
1025
|
-
|
|
1026
|
-
|
|
1027
|
-
|
|
1028
|
-
|
|
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
|
-
}
|
|
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
|
);
|
|
@@ -2994,6 +3010,7 @@ function CallControls({ onDataChange }) {
|
|
|
2994
3010
|
const [openProcessorDialog, setOpenProcessorDialog] = (0, import_react11.useState)(false);
|
|
2995
3011
|
const [openCallHistoryDialog, setOpenCallHistoryDialog] = (0, import_react11.useState)(false);
|
|
2996
3012
|
const [processList, setProcessList] = (0, import_react11.useState)(null);
|
|
3013
|
+
const [breaksList, setBreaksList] = (0, import_react11.useState)(null);
|
|
2997
3014
|
const [phoneNumber, setPhoneNumber] = (0, import_react11.useState)("");
|
|
2998
3015
|
const [callDuration, setCallDuration] = (0, import_react11.useState)(0);
|
|
2999
3016
|
const [callWrapuptime, setCallWrapuptime] = (0, import_react11.useState)(null);
|
|
@@ -3027,7 +3044,11 @@ function CallControls({ onDataChange }) {
|
|
|
3027
3044
|
// sdkStateManager.setMuted(!state.isMuted);
|
|
3028
3045
|
// },
|
|
3029
3046
|
});
|
|
3030
|
-
const [readyAgentStatus, { isLoading: agentReadyLoading }] = usePostRequest(
|
|
3047
|
+
const [readyAgentStatus, { isLoading: agentReadyLoading }] = usePostRequest({
|
|
3048
|
+
onSuccess: () => {
|
|
3049
|
+
sdkStateManager.setAgentStatus("");
|
|
3050
|
+
}
|
|
3051
|
+
});
|
|
3031
3052
|
const [updateAgentStatus, { isLoading }] = usePostRequest();
|
|
3032
3053
|
const [sendNotification] = usePostRequest();
|
|
3033
3054
|
const [endCall, { isLoading: endCallLoading }] = usePostRequest({
|
|
@@ -3079,7 +3100,9 @@ function CallControls({ onDataChange }) {
|
|
|
3079
3100
|
break_type: status,
|
|
3080
3101
|
userId: state.agentId
|
|
3081
3102
|
};
|
|
3082
|
-
updateAgentStatus(END_POINT.UPDATE_AGENT_BREAK, payload)
|
|
3103
|
+
updateAgentStatus(END_POINT.UPDATE_AGENT_BREAK, payload).then(() => {
|
|
3104
|
+
sdkStateManager.setAgentStatus(status);
|
|
3105
|
+
});
|
|
3083
3106
|
};
|
|
3084
3107
|
const handleStartCall = (number) => {
|
|
3085
3108
|
if (number.length !== 10) {
|
|
@@ -3213,7 +3236,7 @@ function CallControls({ onDataChange }) {
|
|
|
3213
3236
|
if (prevTime === null || prevTime <= 1) {
|
|
3214
3237
|
clearInterval(wrapUpinterval);
|
|
3215
3238
|
handleEndCall({
|
|
3216
|
-
disposition: { label: "Resolved", value: "
|
|
3239
|
+
disposition: { label: "Resolved", value: "AUTO_WRAPUP" },
|
|
3217
3240
|
followUp: { label: "No", value: "N" },
|
|
3218
3241
|
callbackDate: "",
|
|
3219
3242
|
callbackHrs: "",
|
|
@@ -3279,6 +3302,14 @@ function CallControls({ onDataChange }) {
|
|
|
3279
3302
|
}).catch((err) => {
|
|
3280
3303
|
showToast(err.response.data.message, "error");
|
|
3281
3304
|
});
|
|
3305
|
+
axios_default.get(END_POINT.BREAKS_LIST).then((res) => {
|
|
3306
|
+
var _a3, _b2, _c2;
|
|
3307
|
+
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)) {
|
|
3308
|
+
setBreaksList(res.data.data);
|
|
3309
|
+
}
|
|
3310
|
+
}).catch((err) => {
|
|
3311
|
+
showToast(err.response.data.message, "error");
|
|
3312
|
+
});
|
|
3282
3313
|
}
|
|
3283
3314
|
}, [state.agentId]);
|
|
3284
3315
|
const connectWebSocket = () => {
|
|
@@ -3832,7 +3863,7 @@ function CallControls({ onDataChange }) {
|
|
|
3832
3863
|
) : /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_icons_material2.CallEnd, {})
|
|
3833
3864
|
}
|
|
3834
3865
|
) }),
|
|
3835
|
-
!((_ua = state.sdkConfig) == null ? void 0 : _ua.disabledMoreOptionsButton) &&
|
|
3866
|
+
!((_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
3867
|
import_material4.Button,
|
|
3837
3868
|
{
|
|
3838
3869
|
variant: Boolean(moreOptionsAnchorEl) ? "contained" : "outlined",
|
|
@@ -4115,7 +4146,32 @@ function CallControls({ onDataChange }) {
|
|
|
4115
4146
|
sx: {
|
|
4116
4147
|
zIndex: 99999
|
|
4117
4148
|
},
|
|
4118
|
-
children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_material4.MenuItem, { onClick: () => handleUpdateAgentStatus("Lunch"), children: "- Break" })
|
|
4149
|
+
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) => {
|
|
4150
|
+
var _a3, _b2, _c2;
|
|
4151
|
+
return /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(
|
|
4152
|
+
import_material4.MenuItem,
|
|
4153
|
+
{
|
|
4154
|
+
sx: {
|
|
4155
|
+
// hilight background of selected
|
|
4156
|
+
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",
|
|
4157
|
+
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",
|
|
4158
|
+
":hover": {
|
|
4159
|
+
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"
|
|
4160
|
+
// color:
|
|
4161
|
+
// state?.callData?.status === "BREAK" && state?.agentStatus === item?.type ?
|
|
4162
|
+
// "primary.main"
|
|
4163
|
+
// : "primary.main",
|
|
4164
|
+
}
|
|
4165
|
+
},
|
|
4166
|
+
onClick: () => handleUpdateAgentStatus(item == null ? void 0 : item.type),
|
|
4167
|
+
children: [
|
|
4168
|
+
"- ",
|
|
4169
|
+
item == null ? void 0 : item.type
|
|
4170
|
+
]
|
|
4171
|
+
},
|
|
4172
|
+
item == null ? void 0 : item.type
|
|
4173
|
+
);
|
|
4174
|
+
})
|
|
4119
4175
|
}
|
|
4120
4176
|
),
|
|
4121
4177
|
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|