@sawport/react-sdk 1.0.4 → 1.0.5
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 +233 -210
- package/dist/index.umd.js +2 -2
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -68269,11 +68269,14 @@ const persist = persistImpl;
|
|
|
68269
68269
|
const useUserStore = create()(
|
|
68270
68270
|
persist(
|
|
68271
68271
|
immer(
|
|
68272
|
-
devtools(
|
|
68273
|
-
|
|
68274
|
-
|
|
68275
|
-
|
|
68276
|
-
|
|
68272
|
+
devtools(
|
|
68273
|
+
(set2) => ({
|
|
68274
|
+
user: void 0,
|
|
68275
|
+
sessionToken: void 0,
|
|
68276
|
+
setChatSessionToken: (sessionToken) => set2({ sessionToken })
|
|
68277
|
+
}),
|
|
68278
|
+
{ name: "@user" }
|
|
68279
|
+
)
|
|
68277
68280
|
),
|
|
68278
68281
|
{
|
|
68279
68282
|
name: "@user",
|
|
@@ -89068,7 +89071,10 @@ const updateCalendar = (id2, params) => api("/calendars/" + id2, params, "put");
|
|
|
89068
89071
|
const schedule = (params) => api("/calendars", params, "post");
|
|
89069
89072
|
const getSlots = (params) => api("/calendars/slots", params);
|
|
89070
89073
|
const joinConversation = async (conversationId, customerId, params) => {
|
|
89071
|
-
const res = await api(
|
|
89074
|
+
const res = await api(
|
|
89075
|
+
`/calendars/join/${conversationId}/${customerId}`,
|
|
89076
|
+
params
|
|
89077
|
+
);
|
|
89072
89078
|
if (res == null ? void 0 : res.token) setChatSessionToken(res == null ? void 0 : res.token);
|
|
89073
89079
|
return res;
|
|
89074
89080
|
};
|
|
@@ -100446,6 +100452,7 @@ const useSocket = (options) => {
|
|
|
100446
100452
|
})
|
|
100447
100453
|
},
|
|
100448
100454
|
transports: ["websocket"],
|
|
100455
|
+
path: "/apis/socket.io",
|
|
100449
100456
|
...options
|
|
100450
100457
|
});
|
|
100451
100458
|
return returnSocket;
|
|
@@ -101451,7 +101458,7 @@ const Schedule = ({
|
|
|
101451
101458
|
) : /* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
101452
101459
|
Button,
|
|
101453
101460
|
{
|
|
101454
|
-
disabled:
|
|
101461
|
+
disabled: hooks().isBefore(hooks(scheduledAt).subtract(5, "minutes")) || hooks().isAfter(hooks(scheduledAt).add(duration + 10, "minutes")),
|
|
101455
101462
|
onClick: onJoin,
|
|
101456
101463
|
className: styles$2.schActionBtnJoin + " border-0 ml-2 rounded-pill mt-2",
|
|
101457
101464
|
children: "Join"
|
|
@@ -101611,89 +101618,106 @@ const getWaitPosition = async (createdAt) => api(`waits/position/${createdAt}`);
|
|
|
101611
101618
|
const useChatStore = create()(
|
|
101612
101619
|
persist(
|
|
101613
101620
|
immer(
|
|
101614
|
-
devtools(
|
|
101615
|
-
|
|
101616
|
-
|
|
101617
|
-
|
|
101618
|
-
|
|
101619
|
-
|
|
101620
|
-
|
|
101621
|
-
|
|
101622
|
-
|
|
101623
|
-
|
|
101624
|
-
|
|
101625
|
-
|
|
101626
|
-
|
|
101627
|
-
|
|
101628
|
-
|
|
101629
|
-
|
|
101630
|
-
|
|
101631
|
-
|
|
101632
|
-
|
|
101633
|
-
|
|
101621
|
+
devtools(
|
|
101622
|
+
(set2, get2) => ({
|
|
101623
|
+
popupVisible: false,
|
|
101624
|
+
chatInit: false,
|
|
101625
|
+
chatClose: false,
|
|
101626
|
+
videoToggle: false,
|
|
101627
|
+
agent: void 0,
|
|
101628
|
+
isScheduling: false,
|
|
101629
|
+
companyClosed: false,
|
|
101630
|
+
calendar: void 0,
|
|
101631
|
+
customerCount: 0,
|
|
101632
|
+
offlineMode: false,
|
|
101633
|
+
dataRef: null,
|
|
101634
|
+
scheduleReminderCanceled: false,
|
|
101635
|
+
isWidgetLaunched: false,
|
|
101636
|
+
setScheduleReminderCanceled: (scheduleReminderCanceled) => set2({ scheduleReminderCanceled }),
|
|
101637
|
+
setPopupVisible: (popupVisible) => set2({ popupVisible }),
|
|
101638
|
+
setChatInit: (chatInit) => set2({ chatInit }),
|
|
101639
|
+
setCustomer: (customer) => {
|
|
101640
|
+
var _a;
|
|
101641
|
+
if ((_a = get2().dataRef) == null ? void 0 : _a.wait) {
|
|
101642
|
+
set2({
|
|
101643
|
+
dataRef: {
|
|
101644
|
+
...get2().dataRef,
|
|
101645
|
+
customer,
|
|
101646
|
+
wait: { ...get2().dataRef.wait, customer }
|
|
101647
|
+
}
|
|
101648
|
+
});
|
|
101649
|
+
} else {
|
|
101650
|
+
set2({ dataRef: { ...get2().dataRef, customer } });
|
|
101651
|
+
}
|
|
101652
|
+
},
|
|
101653
|
+
setConnectors: (connectors) => set2({
|
|
101654
|
+
dataRef: {
|
|
101655
|
+
...get2().dataRef,
|
|
101656
|
+
wait: { ...get2().dataRef.wait, connectors }
|
|
101657
|
+
}
|
|
101658
|
+
}),
|
|
101659
|
+
setConversation: (conversation) => {
|
|
101634
101660
|
set2({
|
|
101635
|
-
dataRef: {
|
|
101661
|
+
dataRef: {
|
|
101662
|
+
...get2().dataRef,
|
|
101663
|
+
wait: { ...get2().dataRef.wait, conversation }
|
|
101664
|
+
}
|
|
101636
101665
|
});
|
|
101637
|
-
}
|
|
101638
|
-
|
|
101639
|
-
}
|
|
101640
|
-
|
|
101641
|
-
|
|
101642
|
-
|
|
101643
|
-
|
|
101644
|
-
|
|
101645
|
-
|
|
101646
|
-
|
|
101647
|
-
|
|
101648
|
-
|
|
101649
|
-
|
|
101650
|
-
|
|
101651
|
-
chatClose: true,
|
|
101652
|
-
agent: void 0,
|
|
101653
|
-
scheduleReminderCanceled: false,
|
|
101654
|
-
companyClosed,
|
|
101655
|
-
dataRef: null,
|
|
101656
|
-
...extraState
|
|
101657
|
-
};
|
|
101658
|
-
if (((_a = dataRef == null ? void 0 : dataRef.wait) == null ? void 0 : _a.status) === "waiting") {
|
|
101659
|
-
updateWait((_b = dataRef == null ? void 0 : dataRef.wait) == null ? void 0 : _b.id, { status: "missed" });
|
|
101660
|
-
}
|
|
101661
|
-
return set2(updates);
|
|
101662
|
-
},
|
|
101663
|
-
reset: (extraState = {}) => {
|
|
101664
|
-
const { companyClosed } = get2();
|
|
101665
|
-
const updates = {
|
|
101666
|
-
chatInit: false,
|
|
101667
|
-
chatClose: false,
|
|
101668
|
-
agent: void 0,
|
|
101669
|
-
scheduleReminderCanceled: false,
|
|
101670
|
-
companyClosed,
|
|
101671
|
-
dataRef: null,
|
|
101672
|
-
...extraState
|
|
101673
|
-
};
|
|
101674
|
-
return set2(updates);
|
|
101675
|
-
},
|
|
101676
|
-
setHasVerifiedFace: (hasVerifiedFace) => set2((state) => {
|
|
101677
|
-
state.dataRef.wait.conversation.hasVerifiedFace = hasVerifiedFace;
|
|
101678
|
-
}),
|
|
101679
|
-
setDataRef: (dataRef) => set2({ dataRef }),
|
|
101680
|
-
reschedule: (calendar2) => set2({ companyClosed: true, isScheduling: false, calendar: calendar2 }),
|
|
101681
|
-
setCalendar: (calendar2) => set2({ calendar: calendar2 }),
|
|
101682
|
-
setChatClose: (chatClose, isAgent) => {
|
|
101683
|
-
var _a, _b, _c;
|
|
101684
|
-
const { dataRef } = get2();
|
|
101685
|
-
if (!isAgent) {
|
|
101686
|
-
t.emit("chat-ended");
|
|
101666
|
+
},
|
|
101667
|
+
setWait: (wait) => set2({ dataRef: { ...get2().dataRef, wait } }),
|
|
101668
|
+
quickStopChat: (extraState = {}) => {
|
|
101669
|
+
var _a, _b;
|
|
101670
|
+
const { companyClosed, dataRef } = get2();
|
|
101671
|
+
const updates = {
|
|
101672
|
+
chatInit: false,
|
|
101673
|
+
chatClose: true,
|
|
101674
|
+
agent: void 0,
|
|
101675
|
+
scheduleReminderCanceled: false,
|
|
101676
|
+
companyClosed,
|
|
101677
|
+
dataRef: null,
|
|
101678
|
+
...extraState
|
|
101679
|
+
};
|
|
101687
101680
|
if (((_a = dataRef == null ? void 0 : dataRef.wait) == null ? void 0 : _a.status) === "waiting") {
|
|
101688
101681
|
updateWait((_b = dataRef == null ? void 0 : dataRef.wait) == null ? void 0 : _b.id, { status: "missed" });
|
|
101689
|
-
} else {
|
|
101690
|
-
updateWait((_c = dataRef == null ? void 0 : dataRef.wait) == null ? void 0 : _c.id, { status: "ended" });
|
|
101691
101682
|
}
|
|
101692
|
-
set2(
|
|
101693
|
-
}
|
|
101694
|
-
|
|
101695
|
-
|
|
101696
|
-
|
|
101683
|
+
return set2(updates);
|
|
101684
|
+
},
|
|
101685
|
+
reset: (extraState = {}) => {
|
|
101686
|
+
const { companyClosed } = get2();
|
|
101687
|
+
const updates = {
|
|
101688
|
+
chatInit: false,
|
|
101689
|
+
chatClose: false,
|
|
101690
|
+
agent: void 0,
|
|
101691
|
+
scheduleReminderCanceled: false,
|
|
101692
|
+
companyClosed,
|
|
101693
|
+
dataRef: null,
|
|
101694
|
+
...extraState
|
|
101695
|
+
};
|
|
101696
|
+
return set2(updates);
|
|
101697
|
+
},
|
|
101698
|
+
setHasVerifiedFace: (hasVerifiedFace) => set2((state) => {
|
|
101699
|
+
state.dataRef.wait.conversation.hasVerifiedFace = hasVerifiedFace;
|
|
101700
|
+
}),
|
|
101701
|
+
setDataRef: (dataRef) => set2({ dataRef }),
|
|
101702
|
+
reschedule: (calendar2) => set2({ companyClosed: true, isScheduling: false, calendar: calendar2 }),
|
|
101703
|
+
setCalendar: (calendar2) => set2({ calendar: calendar2 }),
|
|
101704
|
+
setChatClose: (chatClose, isAgent) => {
|
|
101705
|
+
var _a, _b, _c;
|
|
101706
|
+
const { dataRef } = get2();
|
|
101707
|
+
if (!isAgent) {
|
|
101708
|
+
t.emit("chat-ended");
|
|
101709
|
+
if (((_a = dataRef == null ? void 0 : dataRef.wait) == null ? void 0 : _a.status) === "waiting") {
|
|
101710
|
+
updateWait((_b = dataRef == null ? void 0 : dataRef.wait) == null ? void 0 : _b.id, { status: "missed" });
|
|
101711
|
+
} else {
|
|
101712
|
+
updateWait((_c = dataRef == null ? void 0 : dataRef.wait) == null ? void 0 : _c.id, { status: "ended" });
|
|
101713
|
+
}
|
|
101714
|
+
set2({ chatClose, scheduleReminderCanceled: false });
|
|
101715
|
+
}
|
|
101716
|
+
},
|
|
101717
|
+
setIsWidgetLaunched: (isWidgetLaunched) => set2({ isWidgetLaunched })
|
|
101718
|
+
}),
|
|
101719
|
+
{ name: "@chat" }
|
|
101720
|
+
)
|
|
101697
101721
|
),
|
|
101698
101722
|
{ name: "@chat" }
|
|
101699
101723
|
)
|
|
@@ -102156,22 +102180,19 @@ const Schedules = memo(function({
|
|
|
102156
102180
|
});
|
|
102157
102181
|
const join = useCallback(
|
|
102158
102182
|
async ({ conversation }) => {
|
|
102159
|
-
var _a;
|
|
102160
102183
|
try {
|
|
102161
|
-
await joinConversation(conversation == null ? void 0 : conversation.id, customer == null ? void 0 : customer.id);
|
|
102162
|
-
|
|
102163
|
-
|
|
102164
|
-
wait: {
|
|
102165
|
-
customer,
|
|
102166
|
-
conversation: { id: conversation == null ? void 0 : conversation.id },
|
|
102167
|
-
...(_a = conversation == null ? void 0 : conversation.waitLists) == null ? void 0 : _a[0]
|
|
102168
|
-
}
|
|
102169
|
-
});
|
|
102184
|
+
const { wait } = await joinConversation(conversation == null ? void 0 : conversation.id, customer == null ? void 0 : customer.id);
|
|
102185
|
+
if (wait) wait.conversation = conversation;
|
|
102186
|
+
setDataRef({ customer, wait });
|
|
102170
102187
|
setUser(customer);
|
|
102188
|
+
const connectors = wait == null ? void 0 : wait.connectors;
|
|
102171
102189
|
useChatStore.setState({
|
|
102172
102190
|
chatInit: true,
|
|
102173
102191
|
companyClosed: false,
|
|
102174
|
-
isScheduling: false
|
|
102192
|
+
isScheduling: false,
|
|
102193
|
+
chatClose: false,
|
|
102194
|
+
popupVisible: false,
|
|
102195
|
+
agent: connectors == null ? void 0 : connectors[(connectors == null ? void 0 : connectors.length) - 1].agent
|
|
102175
102196
|
});
|
|
102176
102197
|
} catch (error) {
|
|
102177
102198
|
console.log(error);
|
|
@@ -102945,7 +102966,7 @@ function ChatWidgetScreen({
|
|
|
102945
102966
|
company,
|
|
102946
102967
|
isOngoingChat
|
|
102947
102968
|
}) {
|
|
102948
|
-
var _a, _b, _c, _d;
|
|
102969
|
+
var _a, _b, _c, _d, _e, _f, _g;
|
|
102949
102970
|
const { dataRef, setChatClose, chatInit, chatClose } = useChatStore();
|
|
102950
102971
|
const { socket: socket2 } = useSocket();
|
|
102951
102972
|
const timeoutRef = useRef$1(null);
|
|
@@ -102964,7 +102985,7 @@ function ChatWidgetScreen({
|
|
|
102964
102985
|
setState
|
|
102965
102986
|
} = useRequest({
|
|
102966
102987
|
asyncRequest: getMessages,
|
|
102967
|
-
params: [{ conversation: { id: dataRef == null ? void 0 : dataRef.wait.conversation.id } }]
|
|
102988
|
+
params: [{ conversation: { id: (_a = dataRef == null ? void 0 : dataRef.wait) == null ? void 0 : _a.conversation.id } }]
|
|
102968
102989
|
});
|
|
102969
102990
|
useEffect(() => {
|
|
102970
102991
|
scrollToBottom();
|
|
@@ -102974,56 +102995,57 @@ function ChatWidgetScreen({
|
|
|
102974
102995
|
el.scrollTop = el.scrollHeight;
|
|
102975
102996
|
}, []);
|
|
102976
102997
|
const listeners = useMemo$1(
|
|
102977
|
-
() =>
|
|
102978
|
-
|
|
102979
|
-
|
|
102980
|
-
|
|
102981
|
-
|
|
102982
|
-
|
|
102983
|
-
|
|
102984
|
-
|
|
102985
|
-
|
|
102986
|
-
|
|
102987
|
-
|
|
102988
|
-
|
|
102989
|
-
(
|
|
102990
|
-
|
|
102991
|
-
|
|
102992
|
-
|
|
102993
|
-
|
|
102994
|
-
|
|
102995
|
-
|
|
102996
|
-
t.emit("agent-joined", message.user);
|
|
102997
|
-
}
|
|
102998
|
-
if (!isSender) {
|
|
102999
|
-
readConversation(dataRef == null ? void 0 : dataRef.wait.conversation.id, (_f = message.user) == null ? void 0 : _f.id);
|
|
103000
|
-
}
|
|
103001
|
-
},
|
|
103002
|
-
[`Conversation.read.${(dataRef == null ? void 0 : dataRef.wait.conversation.id) || (dataRef == null ? void 0 : dataRef.wait.conversation)}`]: async ({
|
|
103003
|
-
messageIds
|
|
103004
|
-
}) => {
|
|
103005
|
-
if (messageIds.length) {
|
|
103006
|
-
setState((state) => {
|
|
103007
|
-
state.data.data = state.data.data.map((item) => {
|
|
103008
|
-
if (messageIds.includes(item.id)) {
|
|
103009
|
-
item.message_seen_status = true;
|
|
103010
|
-
}
|
|
103011
|
-
return item;
|
|
103012
|
-
});
|
|
103013
|
-
return state;
|
|
102998
|
+
() => {
|
|
102999
|
+
var _a2, _b2, _c2, _d2;
|
|
103000
|
+
return {
|
|
103001
|
+
[`message.new.${(_a2 = dataRef == null ? void 0 : dataRef.wait) == null ? void 0 : _a2.conversation.id}`]: async ({
|
|
103002
|
+
message
|
|
103003
|
+
}) => {
|
|
103004
|
+
var _a3, _b3, _c3, _d3, _e2, _f2, _g2, _h;
|
|
103005
|
+
const sender = ((_a3 = message.user) == null ? void 0 : _a3.id) || message.user;
|
|
103006
|
+
const customer = dataRef == null ? void 0 : dataRef.customer;
|
|
103007
|
+
const isSender = ((_b3 = customer == null ? void 0 : customer.user) == null ? void 0 : _b3.id) === (((_c3 = message.user) == null ? void 0 : _c3.id) || message.user);
|
|
103008
|
+
message.isSender = isSender;
|
|
103009
|
+
if (!isSender)
|
|
103010
|
+
(_d3 = callUtilsRef.current) == null ? void 0 : _d3.playSound(
|
|
103011
|
+
messageSound,
|
|
103012
|
+
(sound) => sound.loop = false
|
|
103013
|
+
);
|
|
103014
|
+
setState((s2) => {
|
|
103015
|
+
s2.data.data.unshift(message);
|
|
103016
|
+
return s2;
|
|
103014
103017
|
});
|
|
103018
|
+
if (sender !== ((_e2 = customer == null ? void 0 : customer.user) == null ? void 0 : _e2.id)) {
|
|
103019
|
+
t.emit("agent-joined", message.user);
|
|
103020
|
+
}
|
|
103021
|
+
if (!isSender) {
|
|
103022
|
+
readConversation((_g2 = (_f2 = dataRef == null ? void 0 : dataRef.wait) == null ? void 0 : _f2.conversation) == null ? void 0 : _g2.id, (_h = message.user) == null ? void 0 : _h.id);
|
|
103023
|
+
}
|
|
103024
|
+
},
|
|
103025
|
+
[`Conversation.read.${((_b2 = dataRef == null ? void 0 : dataRef.wait) == null ? void 0 : _b2.conversation.id) || ((_c2 = dataRef == null ? void 0 : dataRef.wait) == null ? void 0 : _c2.conversation)}`]: async ({ messageIds }) => {
|
|
103026
|
+
if (messageIds.length) {
|
|
103027
|
+
setState((state) => {
|
|
103028
|
+
state.data.data = state.data.data.map((item) => {
|
|
103029
|
+
if (messageIds.includes(item.id)) {
|
|
103030
|
+
item.message_seen_status = true;
|
|
103031
|
+
}
|
|
103032
|
+
return item;
|
|
103033
|
+
});
|
|
103034
|
+
return state;
|
|
103035
|
+
});
|
|
103036
|
+
}
|
|
103037
|
+
},
|
|
103038
|
+
[`WaitList.closed.${(_d2 = dataRef == null ? void 0 : dataRef.wait) == null ? void 0 : _d2.id}`]: () => {
|
|
103039
|
+
setChatClose(true, false);
|
|
103015
103040
|
}
|
|
103016
|
-
}
|
|
103017
|
-
|
|
103018
|
-
setChatClose(true, false);
|
|
103019
|
-
}
|
|
103020
|
-
}),
|
|
103041
|
+
};
|
|
103042
|
+
},
|
|
103021
103043
|
[
|
|
103022
|
-
(
|
|
103044
|
+
(_b = dataRef == null ? void 0 : dataRef.customer) == null ? void 0 : _b.id,
|
|
103023
103045
|
t,
|
|
103024
103046
|
setChatClose,
|
|
103025
|
-
(dataRef == null ? void 0 : dataRef.wait
|
|
103026
|
-
dataRef == null ? void 0 : dataRef.wait.id,
|
|
103047
|
+
(_c = dataRef == null ? void 0 : dataRef.wait) == null ? void 0 : _c.conversation.id,
|
|
103048
|
+
(_d = dataRef == null ? void 0 : dataRef.wait) == null ? void 0 : _d.id,
|
|
103027
103049
|
setState
|
|
103028
103050
|
]
|
|
103029
103051
|
);
|
|
@@ -103032,15 +103054,15 @@ function ChatWidgetScreen({
|
|
|
103032
103054
|
if (isOngoingChat && timeoutRef.current) clearInterval(timeoutRef.current);
|
|
103033
103055
|
}, [timeoutRef, isOngoingChat]);
|
|
103034
103056
|
useEffect(() => {
|
|
103035
|
-
var _a2;
|
|
103057
|
+
var _a2, _b2;
|
|
103036
103058
|
if (socket2.connected)
|
|
103037
103059
|
socket2.emit("customer-joined-conversation", {
|
|
103038
|
-
conversation: { id: dataRef == null ? void 0 : dataRef.wait.conversation.id },
|
|
103039
|
-
customer: { id: (
|
|
103060
|
+
conversation: { id: (_a2 = dataRef == null ? void 0 : dataRef.wait) == null ? void 0 : _a2.conversation.id },
|
|
103061
|
+
customer: { id: (_b2 = dataRef == null ? void 0 : dataRef.customer) == null ? void 0 : _b2.id }
|
|
103040
103062
|
});
|
|
103041
103063
|
}, [socket2.connected]);
|
|
103042
103064
|
const endChat = async () => setChatClose(true);
|
|
103043
|
-
const verificationVisible = !((
|
|
103065
|
+
const verificationVisible = !((_f = (_e = dataRef == null ? void 0 : dataRef.wait) == null ? void 0 : _e.conversation) == null ? void 0 : _f.hasVerifiedFace) && ((_g = company == null ? void 0 : company.options) == null ? void 0 : _g.facialRecognitionEnabled);
|
|
103044
103066
|
Message.useChatSessionExpiredListener(() => {
|
|
103045
103067
|
y.info("Chat session expired", { autoClose: 2e3 });
|
|
103046
103068
|
endChat();
|
|
@@ -103078,7 +103100,7 @@ function ChatWidgetScreen({
|
|
|
103078
103100
|
] });
|
|
103079
103101
|
}
|
|
103080
103102
|
const ChatInput = memo(function({ company }) {
|
|
103081
|
-
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
103103
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i;
|
|
103082
103104
|
const {
|
|
103083
103105
|
dataRef,
|
|
103084
103106
|
scheduleReminderCanceled,
|
|
@@ -103109,12 +103131,12 @@ const ChatInput = memo(function({ company }) {
|
|
|
103109
103131
|
});
|
|
103110
103132
|
const { socket: socket2 } = useSocket();
|
|
103111
103133
|
const sendMessage = async () => {
|
|
103112
|
-
var _a2;
|
|
103134
|
+
var _a2, _b2, _c2;
|
|
103113
103135
|
if (((_a2 = stateRef.current.messageText) == null ? void 0 : _a2.length) || stateRef.current.chatFiles) {
|
|
103114
103136
|
socket2.emit("messageFromClient", {
|
|
103115
103137
|
message: stateRef.current.messageText,
|
|
103116
|
-
conversation: dataRef == null ? void 0 : dataRef.wait.conversation.id,
|
|
103117
|
-
customer: (dataRef == null ? void 0 : dataRef.customer.id) || (dataRef == null ? void 0 : dataRef.customer)
|
|
103138
|
+
conversation: (_b2 = dataRef == null ? void 0 : dataRef.wait) == null ? void 0 : _b2.conversation.id,
|
|
103139
|
+
customer: ((_c2 = dataRef == null ? void 0 : dataRef.customer) == null ? void 0 : _c2.id) || (dataRef == null ? void 0 : dataRef.customer)
|
|
103118
103140
|
});
|
|
103119
103141
|
}
|
|
103120
103142
|
document.getElementById("widget-chat-input-field").value = "";
|
|
@@ -103122,11 +103144,11 @@ const ChatInput = memo(function({ company }) {
|
|
|
103122
103144
|
setState({ chatFiles: null, messageText: "" });
|
|
103123
103145
|
};
|
|
103124
103146
|
const sendFile = useCallback(async () => {
|
|
103125
|
-
var _a2;
|
|
103147
|
+
var _a2, _b2, _c2;
|
|
103126
103148
|
try {
|
|
103127
103149
|
const data2 = new FormData();
|
|
103128
|
-
data2.append("customer", dataRef == null ? void 0 : dataRef.customer.id);
|
|
103129
|
-
data2.append("conversation", (
|
|
103150
|
+
data2.append("customer", (_a2 = dataRef == null ? void 0 : dataRef.customer) == null ? void 0 : _a2.id);
|
|
103151
|
+
data2.append("conversation", (_c2 = (_b2 = dataRef == null ? void 0 : dataRef.wait) == null ? void 0 : _b2.conversation) == null ? void 0 : _c2.id);
|
|
103130
103152
|
data2.append("message", (stateRef == null ? void 0 : stateRef.current.messageText) || "");
|
|
103131
103153
|
data2.append("attachment", stateRef == null ? void 0 : stateRef.current.chatFiles);
|
|
103132
103154
|
await createMessage(data2, {
|
|
@@ -103165,49 +103187,53 @@ const ChatInput = memo(function({ company }) {
|
|
|
103165
103187
|
}
|
|
103166
103188
|
};
|
|
103167
103189
|
const onChange = (e2) => {
|
|
103190
|
+
var _a2, _b2, _c2;
|
|
103168
103191
|
setState({ messageText: e2.target.value });
|
|
103169
103192
|
if (agentDetails == null ? void 0 : agentDetails.id)
|
|
103170
103193
|
socket2.emit("typing", {
|
|
103171
103194
|
to: agentDetails == null ? void 0 : agentDetails.id,
|
|
103172
|
-
conversation: (dataRef == null ? void 0 : dataRef.wait.conversation.id) || (dataRef == null ? void 0 : dataRef.wait.conversation),
|
|
103195
|
+
conversation: ((_b2 = (_a2 = dataRef == null ? void 0 : dataRef.wait) == null ? void 0 : _a2.conversation) == null ? void 0 : _b2.id) || ((_c2 = dataRef == null ? void 0 : dataRef.wait) == null ? void 0 : _c2.conversation),
|
|
103173
103196
|
message: e2.target.value
|
|
103174
103197
|
});
|
|
103175
103198
|
};
|
|
103176
103199
|
const listeners = useMemo$1(
|
|
103177
|
-
() =>
|
|
103178
|
-
|
|
103179
|
-
|
|
103180
|
-
|
|
103181
|
-
|
|
103182
|
-
|
|
103183
|
-
|
|
103184
|
-
|
|
103185
|
-
|
|
103186
|
-
|
|
103187
|
-
|
|
103188
|
-
|
|
103189
|
-
|
|
103190
|
-
|
|
103191
|
-
|
|
103192
|
-
|
|
103193
|
-
|
|
103194
|
-
|
|
103195
|
-
|
|
103196
|
-
|
|
103197
|
-
|
|
103198
|
-
|
|
103199
|
-
|
|
103200
|
-
|
|
103201
|
-
|
|
103202
|
-
|
|
103203
|
-
|
|
103204
|
-
|
|
103205
|
-
|
|
103200
|
+
() => {
|
|
103201
|
+
var _a2, _b2, _c2;
|
|
103202
|
+
return {
|
|
103203
|
+
[`agent.connected.${(_a2 = dataRef == null ? void 0 : dataRef.wait) == null ? void 0 : _a2.id}`]: ({ waitList }) => {
|
|
103204
|
+
const audio = new Audio(connectedSound);
|
|
103205
|
+
audio.play();
|
|
103206
|
+
setWait(waitList);
|
|
103207
|
+
},
|
|
103208
|
+
[`WaitList.transferred.${((_b2 = dataRef == null ? void 0 : dataRef.wait) == null ? void 0 : _b2.conversation.id) || ((_c2 = dataRef == null ? void 0 : dataRef.wait) == null ? void 0 : _c2.conversation)}`]: ({
|
|
103209
|
+
agent
|
|
103210
|
+
}) => {
|
|
103211
|
+
setEvent((state) => {
|
|
103212
|
+
state.transferredAgent = agent;
|
|
103213
|
+
});
|
|
103214
|
+
t.emit("agent-joined", { ...agent.user, agent });
|
|
103215
|
+
},
|
|
103216
|
+
[`typing.${(dataRef == null ? void 0 : dataRef.wait.conversation.id) || (dataRef == null ? void 0 : dataRef.wait.conversation)}`]: () => {
|
|
103217
|
+
const timeOut = setTimeout(() => {
|
|
103218
|
+
setEvent({ timeOut: true, typingEvent: false });
|
|
103219
|
+
}, 2e3);
|
|
103220
|
+
setEvent((state) => {
|
|
103221
|
+
state.typingEvent = true;
|
|
103222
|
+
if (state.timeOut) {
|
|
103223
|
+
clearTimeout(state.timeOut);
|
|
103224
|
+
}
|
|
103225
|
+
state.timeOut = timeOut;
|
|
103226
|
+
return state;
|
|
103227
|
+
});
|
|
103228
|
+
}
|
|
103229
|
+
};
|
|
103230
|
+
},
|
|
103231
|
+
[t, (dataRef == null ? void 0 : dataRef.wait.conversation.id) || (dataRef == null ? void 0 : dataRef.wait.conversation), (_g = dataRef == null ? void 0 : dataRef.wait) == null ? void 0 : _g.id]
|
|
103206
103232
|
);
|
|
103207
103233
|
useEffect(() => {
|
|
103208
103234
|
var _a2;
|
|
103209
103235
|
if (!scheduleReminderCanceled) {
|
|
103210
|
-
if (!agentConnected && ((_a2 = company == null ? void 0 : company.options) == null ? void 0 : _a2.schedulePopUpTime)) {
|
|
103236
|
+
if ((!agentConnected || !!(agentDetails == null ? void 0 : agentDetails.id)) && ((_a2 = company == null ? void 0 : company.options) == null ? void 0 : _a2.schedulePopUpTime)) {
|
|
103211
103237
|
const intervalId = setInterval(
|
|
103212
103238
|
() => setPopupVisible(true),
|
|
103213
103239
|
company.options.schedulePopUpTime
|
|
@@ -103217,7 +103243,7 @@ const ChatInput = memo(function({ company }) {
|
|
|
103217
103243
|
setPopupVisible(false);
|
|
103218
103244
|
}
|
|
103219
103245
|
}
|
|
103220
|
-
}, [agentConnected, (
|
|
103246
|
+
}, [agentConnected, agentDetails == null ? void 0 : agentDetails.id, (_h = company == null ? void 0 : company.options) == null ? void 0 : _h.schedulePopUpTime, scheduleReminderCanceled, setPopupVisible]);
|
|
103221
103247
|
const [, colors] = useToken();
|
|
103222
103248
|
useSocketListeners({ listeners });
|
|
103223
103249
|
return /* @__PURE__ */ jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment, { children: [
|
|
@@ -103266,7 +103292,7 @@ const ChatInput = memo(function({ company }) {
|
|
|
103266
103292
|
id: "widget-chat-input-field",
|
|
103267
103293
|
autoComplete: "off",
|
|
103268
103294
|
autoFocus: true,
|
|
103269
|
-
disabled: ((
|
|
103295
|
+
disabled: ((_i = document.getElementById("widget-file-upload-input")) == null ? void 0 : _i.value) !== ""
|
|
103270
103296
|
}
|
|
103271
103297
|
),
|
|
103272
103298
|
/* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
@@ -104578,19 +104604,18 @@ const VideoCall = ({ userId, conversation_id, callUtilsRef }) => {
|
|
|
104578
104604
|
const VideoCall$1 = memo(VideoCall);
|
|
104579
104605
|
const WidgetInitOnlineHeader = ({
|
|
104580
104606
|
setIsWidgetLaunched,
|
|
104581
|
-
senderObj,
|
|
104582
104607
|
callUtilsRef,
|
|
104583
104608
|
company
|
|
104584
104609
|
}) => {
|
|
104585
|
-
var _a, _b, _c, _d, _e, _f, _g
|
|
104586
|
-
const { dataRef, setHasVerifiedFace, quickStopChat, setChatClose } = useChatStore();
|
|
104610
|
+
var _a, _b, _c, _d, _e, _f, _g;
|
|
104611
|
+
const { dataRef, agent, setHasVerifiedFace, quickStopChat, setChatClose } = useChatStore();
|
|
104587
104612
|
const [dropdownVisible, setDropdownVisible] = useState$1(false);
|
|
104588
104613
|
let fileExtension;
|
|
104589
104614
|
if (company == null ? void 0 : company.marketing_media) {
|
|
104590
104615
|
fileExtension = getUrlExt(company == null ? void 0 : company.marketing_media);
|
|
104591
104616
|
}
|
|
104592
104617
|
const handleMinimize = () => setIsWidgetLaunched(false);
|
|
104593
|
-
const handleClose = () =>
|
|
104618
|
+
const handleClose = () => agent ? setChatClose(true) : quickStopChat();
|
|
104594
104619
|
const launchFacialRecognition = () => setHasVerifiedFace(false);
|
|
104595
104620
|
const onItemClick = ({ key, domEvent: e2 }) => {
|
|
104596
104621
|
e2.preventDefault();
|
|
@@ -104685,8 +104710,8 @@ const WidgetInitOnlineHeader = ({
|
|
|
104685
104710
|
/* @__PURE__ */ jsxRuntimeExports.jsx(Col, { className: "m-0 p-0", children: ((_c = dataRef == null ? void 0 : dataRef.customer) == null ? void 0 : _c.id) && /* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
104686
104711
|
VideoCall$1,
|
|
104687
104712
|
{
|
|
104688
|
-
userId: (
|
|
104689
|
-
conversation_id: (
|
|
104713
|
+
userId: (_e = (_d = dataRef == null ? void 0 : dataRef.customer) == null ? void 0 : _d.user) == null ? void 0 : _e.id,
|
|
104714
|
+
conversation_id: (_g = (_f = dataRef == null ? void 0 : dataRef.wait) == null ? void 0 : _f.conversation) == null ? void 0 : _g.id,
|
|
104690
104715
|
callUtilsRef
|
|
104691
104716
|
}
|
|
104692
104717
|
) })
|
|
@@ -110238,13 +110263,7 @@ function isWidgetOnline(workHours, userTimezone) {
|
|
|
110238
110263
|
const currentTime = now2.format("HH:mm");
|
|
110239
110264
|
return times.filter((time2) => time2.length === 2).some(([start, end]) => currentTime >= start && currentTime <= end);
|
|
110240
110265
|
}
|
|
110241
|
-
const Header = memo(function({
|
|
110242
|
-
companyIsClosed,
|
|
110243
|
-
chatInit,
|
|
110244
|
-
agent,
|
|
110245
|
-
company,
|
|
110246
|
-
callUtilsRef
|
|
110247
|
-
}) {
|
|
110266
|
+
const Header = memo(function({ companyIsClosed, chatInit, company, callUtilsRef }) {
|
|
110248
110267
|
const { setIsWidgetLaunched } = useChatStore();
|
|
110249
110268
|
return /* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
110250
110269
|
"div",
|
|
@@ -110256,7 +110275,6 @@ const Header = memo(function({
|
|
|
110256
110275
|
WidgetInitOnlineHeader,
|
|
110257
110276
|
{
|
|
110258
110277
|
setIsWidgetLaunched,
|
|
110259
|
-
senderObj: agent,
|
|
110260
110278
|
callUtilsRef,
|
|
110261
110279
|
company
|
|
110262
110280
|
}
|
|
@@ -110375,7 +110393,6 @@ const WidgetFormDisplay = memo(
|
|
|
110375
110393
|
{
|
|
110376
110394
|
companyIsClosed: companyClosed,
|
|
110377
110395
|
chatInit,
|
|
110378
|
-
agent,
|
|
110379
110396
|
company,
|
|
110380
110397
|
callUtilsRef
|
|
110381
110398
|
}
|
|
@@ -110445,12 +110462,15 @@ const ChatMode = memo(
|
|
|
110445
110462
|
const {
|
|
110446
110463
|
state: { data: data2 },
|
|
110447
110464
|
setState: _setState
|
|
110448
|
-
} = useRequest(
|
|
110449
|
-
|
|
110450
|
-
|
|
110451
|
-
|
|
110452
|
-
|
|
110453
|
-
|
|
110465
|
+
} = useRequest(
|
|
110466
|
+
{
|
|
110467
|
+
loadOnMount: !!(customer == null ? void 0 : customer.id) && !chatInit,
|
|
110468
|
+
asyncRequest: getConnectedWait,
|
|
110469
|
+
params: [{ customer: customer == null ? void 0 : customer.id }],
|
|
110470
|
+
onSuccess: (data22) => (data22 == null ? void 0 : data22[0]) && setWait(data22 == null ? void 0 : data22[0])
|
|
110471
|
+
},
|
|
110472
|
+
[chatInit]
|
|
110473
|
+
);
|
|
110454
110474
|
const [isOngoingChat, setIsOngoingChat] = useState(false);
|
|
110455
110475
|
const agent_ = useMemo$1(() => {
|
|
110456
110476
|
var _a2, _b2;
|
|
@@ -110485,12 +110505,14 @@ const ChatMode = memo(
|
|
|
110485
110505
|
const ChatScreen = memo(({ company, callUtilsRef, isOngoingChat }) => {
|
|
110486
110506
|
var _a, _b, _c;
|
|
110487
110507
|
const { dataRef, setHasVerifiedFace } = useChatStore();
|
|
110488
|
-
const hasVerifiedFace = (_b = (_a = dataRef.wait) == null ? void 0 : _a.conversation) == null ? void 0 : _b.hasVerifiedFace;
|
|
110508
|
+
const hasVerifiedFace = (_b = (_a = dataRef == null ? void 0 : dataRef.wait) == null ? void 0 : _a.conversation) == null ? void 0 : _b.hasVerifiedFace;
|
|
110489
110509
|
const facialRecognitionEnabled = (_c = company == null ? void 0 : company.options) == null ? void 0 : _c.facialRecognitionEnabled;
|
|
110490
110510
|
const onProceed = async () => {
|
|
110491
110511
|
var _a2, _b2;
|
|
110492
110512
|
try {
|
|
110493
|
-
await updateConversation((_b2 = (_a2 = dataRef.wait) == null ? void 0 : _a2.conversation) == null ? void 0 : _b2.id, {
|
|
110513
|
+
await updateConversation((_b2 = (_a2 = dataRef == null ? void 0 : dataRef.wait) == null ? void 0 : _a2.conversation) == null ? void 0 : _b2.id, {
|
|
110514
|
+
hasVerifiedFace: true
|
|
110515
|
+
});
|
|
110494
110516
|
setHasVerifiedFace(true);
|
|
110495
110517
|
} catch (error) {
|
|
110496
110518
|
y.error("Error verifying face", { autoClose: 3e3 });
|
|
@@ -110529,6 +110551,7 @@ const OngoingChat = ({
|
|
|
110529
110551
|
try {
|
|
110530
110552
|
setDataRef({
|
|
110531
110553
|
customer,
|
|
110554
|
+
// @ts-expect-error
|
|
110532
110555
|
wait: { customer, conversation: { id: conversation == null ? void 0 : conversation.id }, id: wait == null ? void 0 : wait.id }
|
|
110533
110556
|
});
|
|
110534
110557
|
setUser(customer);
|