@sawport/react-sdk 0.1.0-alpha.57 → 0.1.0-alpha.58
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 +48 -19
- package/dist/index.umd.js +12 -12
- package/dist/style.css +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -72003,16 +72003,22 @@ function ChatWidgetScreen({
|
|
|
72003
72003
|
}
|
|
72004
72004
|
}, []);
|
|
72005
72005
|
react.exports.useEffect(() => {
|
|
72006
|
-
|
|
72007
|
-
|
|
72006
|
+
let timer;
|
|
72007
|
+
if (timeoutTriggered && !agentDetails) {
|
|
72008
|
+
if (timer)
|
|
72009
|
+
clearTimeout(timer);
|
|
72010
|
+
return;
|
|
72011
|
+
} else if (popupTime && !agentDetails || !timeoutTriggered) {
|
|
72012
|
+
clearTimeout(timer);
|
|
72013
|
+
timer = setTimeout(() => {
|
|
72008
72014
|
setPopupVisible(true);
|
|
72009
72015
|
setTimeoutTriggered(true);
|
|
72010
72016
|
}, popupTime);
|
|
72011
|
-
return () => {
|
|
72012
|
-
clearTimeout(timer);
|
|
72013
|
-
};
|
|
72014
72017
|
}
|
|
72015
|
-
|
|
72018
|
+
return () => {
|
|
72019
|
+
clearTimeout(timer);
|
|
72020
|
+
};
|
|
72021
|
+
}, [popupTime, agentDetails, timeoutTriggered]);
|
|
72016
72022
|
return /* @__PURE__ */ jsx(Fragment, {
|
|
72017
72023
|
children: offlineMode ? /* @__PURE__ */ jsx(Offline, {
|
|
72018
72024
|
companyUser,
|
|
@@ -72991,8 +72997,10 @@ function useVideoCalling({ userId, conversation_id }) {
|
|
|
72991
72997
|
const playSound = react.exports.useCallback(
|
|
72992
72998
|
(src2, callOn) => {
|
|
72993
72999
|
sound.src = src2;
|
|
72994
|
-
|
|
72995
|
-
|
|
73000
|
+
sound.addEventListener("canplaythrough", () => {
|
|
73001
|
+
callOn && callOn(sound);
|
|
73002
|
+
sound.play();
|
|
73003
|
+
});
|
|
72996
73004
|
},
|
|
72997
73005
|
[sound]
|
|
72998
73006
|
);
|
|
@@ -73001,6 +73009,7 @@ function useVideoCalling({ userId, conversation_id }) {
|
|
|
73001
73009
|
const stopSound = react.exports.useCallback(() => {
|
|
73002
73010
|
sound.pause();
|
|
73003
73011
|
sound.srcObject = null;
|
|
73012
|
+
sound.src = null;
|
|
73004
73013
|
}, [sound]);
|
|
73005
73014
|
const getMediaStream = react.exports.useCallback(() => {
|
|
73006
73015
|
try {
|
|
@@ -74210,11 +74219,15 @@ const WidgetFormDisplay = react.exports.memo(({
|
|
|
74210
74219
|
}
|
|
74211
74220
|
}, [socket2.connected, chatInit, customer == null ? void 0 : customer.id]);
|
|
74212
74221
|
const quickStopChat = react.exports.useCallback(() => {
|
|
74222
|
+
var _a2, _b2;
|
|
74213
74223
|
setState({
|
|
74214
74224
|
chatInit: false,
|
|
74215
74225
|
chatClose: true,
|
|
74216
74226
|
companyClosed: companyIsClosed
|
|
74217
74227
|
});
|
|
74228
|
+
updateWait((_b2 = (_a2 = dataRef.current) == null ? void 0 : _a2.wait) == null ? void 0 : _b2.id, {
|
|
74229
|
+
status: "missed"
|
|
74230
|
+
});
|
|
74218
74231
|
dataRef.current = null;
|
|
74219
74232
|
}, [companyIsClosed, dataRef]);
|
|
74220
74233
|
const setChatClose = (chatClose2, isAgent) => {
|
|
@@ -74357,7 +74370,7 @@ const ChatMode = react.exports.memo(({
|
|
|
74357
74370
|
calendar: calendar2,
|
|
74358
74371
|
quickStopChat
|
|
74359
74372
|
}) => {
|
|
74360
|
-
var _a, _b
|
|
74373
|
+
var _a, _b;
|
|
74361
74374
|
const {
|
|
74362
74375
|
state: {
|
|
74363
74376
|
data: data2
|
|
@@ -74376,14 +74389,15 @@ const ChatMode = react.exports.memo(({
|
|
|
74376
74389
|
return (_b2 = connectors == null ? void 0 : connectors[(connectors == null ? void 0 : connectors.length) - 1]) == null ? void 0 : _b2.agent;
|
|
74377
74390
|
}, [data2]);
|
|
74378
74391
|
return !chatInit ? (data2 == null ? void 0 : data2.length) ? /* @__PURE__ */ jsx(OngoingChat, {
|
|
74379
|
-
|
|
74380
|
-
|
|
74392
|
+
wait: data2 == null ? void 0 : data2[0],
|
|
74393
|
+
conversation: (_a = data2 == null ? void 0 : data2[0]) == null ? void 0 : _a.conversation,
|
|
74381
74394
|
agent: agent_,
|
|
74382
74395
|
setState: _setState,
|
|
74383
74396
|
customer,
|
|
74384
74397
|
dataRef,
|
|
74385
74398
|
setParentState: setState,
|
|
74386
|
-
setIsOngoingChat
|
|
74399
|
+
setIsOngoingChat,
|
|
74400
|
+
chatSession: (_b = company == null ? void 0 : company.options) == null ? void 0 : _b.chatSession
|
|
74387
74401
|
}) : /* @__PURE__ */ jsx(WidgetInitForm$1, {
|
|
74388
74402
|
company_id,
|
|
74389
74403
|
companyUser,
|
|
@@ -74409,20 +74423,21 @@ const ChatMode = react.exports.memo(({
|
|
|
74409
74423
|
});
|
|
74410
74424
|
const OngoingChat = ({
|
|
74411
74425
|
setState,
|
|
74412
|
-
|
|
74426
|
+
wait,
|
|
74413
74427
|
dataRef,
|
|
74414
74428
|
customer,
|
|
74415
|
-
|
|
74429
|
+
conversation,
|
|
74416
74430
|
setParentState,
|
|
74417
74431
|
agent,
|
|
74418
|
-
setIsOngoingChat
|
|
74432
|
+
setIsOngoingChat,
|
|
74433
|
+
chatSession
|
|
74419
74434
|
}) => {
|
|
74420
74435
|
const {
|
|
74421
74436
|
socket: socket2
|
|
74422
74437
|
} = useSocket();
|
|
74423
74438
|
const endChat = () => {
|
|
74424
74439
|
t$3.emit("chat-ended");
|
|
74425
|
-
updateWait(
|
|
74440
|
+
updateWait(wait == null ? void 0 : wait.id, {
|
|
74426
74441
|
status: "ended"
|
|
74427
74442
|
});
|
|
74428
74443
|
setState({
|
|
@@ -74441,9 +74456,9 @@ const OngoingChat = ({
|
|
|
74441
74456
|
wait: {
|
|
74442
74457
|
customer,
|
|
74443
74458
|
conversation: {
|
|
74444
|
-
id:
|
|
74459
|
+
id: conversation == null ? void 0 : conversation.id
|
|
74445
74460
|
},
|
|
74446
|
-
id:
|
|
74461
|
+
id: wait == null ? void 0 : wait.id
|
|
74447
74462
|
}
|
|
74448
74463
|
};
|
|
74449
74464
|
const updates = {
|
|
@@ -74459,7 +74474,7 @@ const OngoingChat = ({
|
|
|
74459
74474
|
setIsOngoingChat(true);
|
|
74460
74475
|
socket2.emit("customer-joined-conversation", {
|
|
74461
74476
|
conversation: {
|
|
74462
|
-
id:
|
|
74477
|
+
id: conversation == null ? void 0 : conversation.id
|
|
74463
74478
|
},
|
|
74464
74479
|
customer: {
|
|
74465
74480
|
id: customer == null ? void 0 : customer.id
|
|
@@ -74469,6 +74484,20 @@ const OngoingChat = ({
|
|
|
74469
74484
|
console.log(error);
|
|
74470
74485
|
}
|
|
74471
74486
|
};
|
|
74487
|
+
react.exports.useEffect(() => {
|
|
74488
|
+
if ((wait == null ? void 0 : wait.status) === "connected" && (conversation == null ? void 0 : conversation.offlineAt) && chatSession) {
|
|
74489
|
+
const currentTimestamp = new Date().getTime();
|
|
74490
|
+
const offlineAt = new Date(`${conversation == null ? void 0 : conversation.offlineAt}`).getTime();
|
|
74491
|
+
const timeDifferenceInMilliseconds = currentTimestamp - offlineAt;
|
|
74492
|
+
const timeDifferenceInMinutes = Math.floor(timeDifferenceInMilliseconds / (1e3 * 60));
|
|
74493
|
+
if (timeDifferenceInMinutes >= chatSession) {
|
|
74494
|
+
toast.info("Time expired for going off chat", {
|
|
74495
|
+
autoClose: 2e3
|
|
74496
|
+
});
|
|
74497
|
+
endChat();
|
|
74498
|
+
}
|
|
74499
|
+
}
|
|
74500
|
+
}, []);
|
|
74472
74501
|
return /* @__PURE__ */ jsxs("div", {
|
|
74473
74502
|
className: "p-4 d-flex flex-column align-items-center justify-content-center",
|
|
74474
74503
|
children: [/* @__PURE__ */ jsx("h3", {
|