@axos-web-dev/shared-components 1.0.77-patch.42 → 1.0.77-patch.44
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.
|
@@ -51,8 +51,8 @@ import "../Carousel/index.js";
|
|
|
51
51
|
/* empty css */
|
|
52
52
|
import "../Chatbot/store/chat.js";
|
|
53
53
|
import "../Chatbot/authenticate.js";
|
|
54
|
-
import "../Chatbot/Chatbot.css.ts.vanilla.css.js";
|
|
55
54
|
import "react-use";
|
|
55
|
+
import "../Chatbot/Chatbot.css.ts.vanilla.css.js";
|
|
56
56
|
/* empty css */
|
|
57
57
|
import "../Chatbot/store/messages.js";
|
|
58
58
|
/* empty css */
|
package/dist/Chatbot/Chatbot.js
CHANGED
|
@@ -6,7 +6,7 @@ import { chatbotUFB, chatbotAXB } from "./Chatbot.css.js";
|
|
|
6
6
|
import { ChatWindow } from "./ChatWindow.js";
|
|
7
7
|
import { useOpenChat } from "./store/chat.js";
|
|
8
8
|
import { useMessages } from "./store/messages.js";
|
|
9
|
-
import { useRef, useState } from "react";
|
|
9
|
+
import { useRef, useState, useEffect } from "react";
|
|
10
10
|
import { useMount, useUnmount } from "react-use";
|
|
11
11
|
const Chatbot = ({
|
|
12
12
|
project = "axos",
|
|
@@ -24,6 +24,8 @@ const Chatbot = ({
|
|
|
24
24
|
const agent_virtual = useRef(null);
|
|
25
25
|
const [status, setStatus] = useState("idle");
|
|
26
26
|
const [hasStarted, setHasStarted] = useState(false);
|
|
27
|
+
const [menusLoaded, setMenusLoaded] = useState(false);
|
|
28
|
+
const [pendingStart, setPendingStart] = useState(false);
|
|
27
29
|
const brandMap = /* @__PURE__ */ new Map([
|
|
28
30
|
["axos", 1],
|
|
29
31
|
["ufb", 3]
|
|
@@ -50,6 +52,11 @@ const Chatbot = ({
|
|
|
50
52
|
};
|
|
51
53
|
const onReadyHandler = async () => {
|
|
52
54
|
console.log("Chat client is ready");
|
|
55
|
+
if (clientRef.current) {
|
|
56
|
+
menuRef.current = await clientRef.current.getMenus();
|
|
57
|
+
setMenusLoaded(true);
|
|
58
|
+
console.log("menus:", menuRef.current);
|
|
59
|
+
}
|
|
53
60
|
};
|
|
54
61
|
const onAuthenticatedHandler = async () => {
|
|
55
62
|
console.log("Chat client is authenticated");
|
|
@@ -135,8 +142,6 @@ const Chatbot = ({
|
|
|
135
142
|
client?.on("authenticated", onAuthenticatedHandler);
|
|
136
143
|
isMountedRef.current = true;
|
|
137
144
|
clientRef.current = client;
|
|
138
|
-
menuRef.current = await client.getMenus();
|
|
139
|
-
console.log("menus:", menuRef.current);
|
|
140
145
|
registerEventHandlers();
|
|
141
146
|
return;
|
|
142
147
|
};
|
|
@@ -146,7 +151,7 @@ const Chatbot = ({
|
|
|
146
151
|
if (!client) return;
|
|
147
152
|
if (!menuRef.current || !menuRef.current.menus) {
|
|
148
153
|
let waited = 0;
|
|
149
|
-
while ((!menuRef.current || !menuRef.current.menus) && waited <
|
|
154
|
+
while ((!menuRef.current || !menuRef.current.menus) && waited < 5e3) {
|
|
150
155
|
await new Promise((res) => setTimeout(res, 100));
|
|
151
156
|
waited += 100;
|
|
152
157
|
}
|
|
@@ -182,6 +187,10 @@ const Chatbot = ({
|
|
|
182
187
|
const handleClick = async () => {
|
|
183
188
|
toggle();
|
|
184
189
|
if (hasStarted) return;
|
|
190
|
+
if (!menusLoaded) {
|
|
191
|
+
setPendingStart(true);
|
|
192
|
+
return;
|
|
193
|
+
}
|
|
185
194
|
if (!hasOpenedOnce) {
|
|
186
195
|
await startChat();
|
|
187
196
|
setHasStarted(true);
|
|
@@ -215,6 +224,13 @@ const Chatbot = ({
|
|
|
215
224
|
isMountedRef.current = false;
|
|
216
225
|
hasLoadedBefore.current = true;
|
|
217
226
|
});
|
|
227
|
+
useEffect(() => {
|
|
228
|
+
if (menusLoaded && pendingStart && !hasStarted) {
|
|
229
|
+
startChat();
|
|
230
|
+
setHasStarted(true);
|
|
231
|
+
setPendingStart(false);
|
|
232
|
+
}
|
|
233
|
+
}, [menusLoaded, pendingStart, hasStarted]);
|
|
218
234
|
return /* @__PURE__ */ jsxs("div", { className: project === "ufb" ? chatbotUFB : chatbotAXB, children: [
|
|
219
235
|
/* @__PURE__ */ jsx(Bubble, { onClick: handleClick }),
|
|
220
236
|
/* @__PURE__ */ jsx(
|
package/dist/Forms/SuccesForm.js
CHANGED
|
@@ -60,8 +60,8 @@ import "../Carousel/index.js";
|
|
|
60
60
|
/* empty css */
|
|
61
61
|
import "../Chatbot/store/chat.js";
|
|
62
62
|
import "../Chatbot/authenticate.js";
|
|
63
|
-
import "../Chatbot/Chatbot.css.ts.vanilla.css.js";
|
|
64
63
|
import "react-use";
|
|
64
|
+
import "../Chatbot/Chatbot.css.ts.vanilla.css.js";
|
|
65
65
|
/* empty css */
|
|
66
66
|
import "../Chatbot/store/messages.js";
|
|
67
67
|
/* empty css */
|
package/package.json
CHANGED