@axos-web-dev/shared-components 2.0.0-queryparams.2 → 2.1.0
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/README.md +111 -111
- package/dist/ATMLocator/ATMLocator.js +11 -6
- package/dist/Auth/ErrorAlert.js +13 -8
- package/dist/Auth/SignInPassword.js +1 -0
- package/dist/Avatar/Avatar.module.js +7 -7
- package/dist/Blockquote/Blockquote.module.js +3 -3
- package/dist/BulletItem/BulletItem.js +1 -0
- package/dist/Button/Button.js +14 -26
- package/dist/Calculators/AnnualFeeCalculator/index.js +2 -1
- package/dist/Calculators/ApyCalculator/index.js +1 -3
- package/dist/Calculators/AxosOneCalculator/index.js +6 -7
- package/dist/Calculators/BalanceAPYCalculator/index.js +1 -0
- package/dist/Calculators/BuyDownCalculator/index.js +1 -0
- package/dist/Calculators/Calculator.js +12 -7
- package/dist/Calculators/MarginTradingCalculator/index.js +2 -119
- package/dist/Calculators/MarineLoanMonthlyPaymentCalculator/index.js +2 -1
- package/dist/Calculators/MaxLoanCalculator/index.js +2 -1
- package/dist/Calculators/MonthlyPaymentCalculator/index.js +2 -1
- package/dist/Calculators/MonthlyPaymentLVFCalculator/index.js +1 -0
- package/dist/Calculators/SummitApyCalculator/index.js +2 -3
- package/dist/Calculators/calculator.css.d.ts +21 -1
- package/dist/Calculators/calculator.css.js +3 -3
- package/dist/Carousel/index.js +11 -6
- package/dist/Chatbot/AnimatedGradientBorder.css.d.ts +5 -0
- package/dist/Chatbot/AnimatedGradientBorder.css.js +13 -3
- package/dist/Chatbot/Bubble.css.js +2 -1
- package/dist/Chatbot/Bubble.d.ts +1 -0
- package/dist/Chatbot/Bubble.js +3 -12
- package/dist/Chatbot/Chat.js +17 -7
- package/dist/Chatbot/ChatWindow.css.d.ts +4 -0
- package/dist/Chatbot/ChatWindow.css.js +39 -31
- package/dist/Chatbot/ChatWindow.js +163 -95
- package/dist/Chatbot/Chatbot.d.ts +10 -2
- package/dist/Chatbot/Chatbot.js +148 -80
- package/dist/Chatbot/ChatbotMessage.d.ts +1 -0
- package/dist/Chatbot/ChatbotMessage.js +214 -160
- package/dist/Chatbot/index.js +5 -1
- package/dist/Chatbot/store/chat.d.ts +5 -0
- package/dist/Chatbot/store/chat.js +10 -2
- package/dist/Chatbot/useHeadlessChat.js +1 -2
- package/dist/Chevron/index.js +12 -18
- package/dist/Comparison/Comparison.js +11 -6
- package/dist/ExecutiveBio/ExecutiveBio.js +9 -4
- package/dist/ExecutiveBio/ExecutiveBioSet.js +1 -0
- package/dist/FaqAccordion/index.js +11 -6
- package/dist/FdicCallout/FdicCallout.module.js +2 -2
- package/dist/FooterSiteMap/AxosBank/FooterSiteMap.js +208 -91
- package/dist/Forms/ApplicationStart.js +1 -0
- package/dist/Forms/ApplyNow.js +10 -5
- package/dist/Forms/BoatMooringLocation.d.ts +6 -1
- package/dist/Forms/BoatMooringLocation.js +146 -8
- package/dist/Forms/ClearingForm.js +1 -0
- package/dist/Forms/CommercialDeposits.js +1 -0
- package/dist/Forms/CommercialDepositsNoLendingOption.js +1 -0
- package/dist/Forms/CommercialLending.js +1 -0
- package/dist/Forms/CommercialPremiumFinance.js +1 -0
- package/dist/Forms/ConstructionLendingDynamic.js +1 -0
- package/dist/Forms/ContactCompany.js +1 -0
- package/dist/Forms/ContactCompanyTitle.js +1 -0
- package/dist/Forms/ContactUs.js +1 -0
- package/dist/Forms/ContactUsAAS.js +1 -0
- package/dist/Forms/ContactUsBusiness.js +11 -6
- package/dist/Forms/ContactUsBusinessNameEmail.js +11 -6
- package/dist/Forms/ContactUsLVF.js +1 -0
- package/dist/Forms/ContactUsNMLSId.js +11 -6
- package/dist/Forms/CpraRequest.js +3 -100
- package/dist/Forms/CraPublicFile.js +11 -6
- package/dist/Forms/DealerServices.js +1 -0
- package/dist/Forms/EmailOnly.js +11 -6
- package/dist/Forms/EmailUs.js +41 -34
- package/dist/Forms/FormEnums.js +2 -2
- package/dist/Forms/Forms.css.d.ts +3 -0
- package/dist/Forms/Forms.css.js +39 -39
- package/dist/Forms/HoneyPot/index.js +1 -0
- package/dist/Forms/MortgageRate/MortgageRateForm.js +12 -7
- package/dist/Forms/MortgageRate/MortgageRateWatch.js +11 -6
- package/dist/Forms/MortgageWarehouseLending.js +11 -6
- package/dist/Forms/QuickPricer/QuickPricerForm.js +1 -0
- package/dist/Forms/ScheduleCall.js +1 -0
- package/dist/Forms/ScheduleCallPremier.js +1 -0
- package/dist/Forms/SuccesForm.js +13 -8
- package/dist/Forms/VendorQuestionnaire.js +1 -0
- package/dist/Forms/index.js +1 -0
- package/dist/HeroBanner/HeroBanner.css.d.ts +1 -0
- package/dist/HeroBanner/HeroBanner.css.js +19 -16
- package/dist/HeroBanner/HeroBanner.d.ts +1 -1
- package/dist/HeroBanner/HeroBanner.interface.d.ts +4 -1
- package/dist/HeroBanner/HeroBanner.js +26 -160
- package/dist/HeroBanner/HeroVideoPoster.d.ts +5 -0
- package/dist/HeroBanner/HeroVideoPoster.js +24 -0
- package/dist/HeroBanner/LargeBanner.css.d.ts +110 -0
- package/dist/HeroBanner/LargeBanner.css.js +22 -8
- package/dist/HeroBanner/LargeHeroBanner.d.ts +5 -0
- package/dist/HeroBanner/LargeHeroBanner.js +228 -0
- package/dist/HeroBanner/index.js +3 -2
- package/dist/Hyperlink/index.js +13 -20
- package/dist/ImageLink/ImageLink.js +10 -5
- package/dist/ImageLink/ImageLinkSet.js +10 -5
- package/dist/ImageLink/index.js +10 -5
- package/dist/Insight/Featured/CategorySelector.js +10 -5
- package/dist/Insight/Featured/Featured.js +11 -6
- package/dist/Insight/Featured/Header.js +11 -6
- package/dist/Interstitial/Interstitial.module.js +10 -10
- package/dist/LoadingIndicator/index.js +1 -0
- package/dist/Modal/Modal.js +10 -5
- package/dist/Modal/contextApi/store.d.ts +2 -16
- package/dist/Modal/contextApi/store.js +6 -37
- package/dist/NavigationMenu/AxosALTS/NavBar.module.js +23 -23
- package/dist/NavigationMenu/AxosALTS/NavData.d.ts +1 -7
- package/dist/NavigationMenu/AxosALTS/NavData.js +137 -6
- package/dist/NavigationMenu/AxosALTS/index.js +16 -14
- package/dist/NavigationMenu/AxosAdvisor/NavBar.module.js +52 -52
- package/dist/NavigationMenu/AxosAdvisor/SubNavBar.js +1 -0
- package/dist/NavigationMenu/AxosAdvisor/index.js +1 -0
- package/dist/NavigationMenu/AxosAdvisorServices/NavBar.module.js +53 -53
- package/dist/NavigationMenu/AxosAdvisorServices/SubNavBar.js +1 -0
- package/dist/NavigationMenu/AxosAdvisorServices/index.js +1 -0
- package/dist/NavigationMenu/AxosBank/MobileMenu/MobileMenu.js +4 -128
- package/dist/NavigationMenu/AxosBank/MobileMenu/MobileMenu.module.js +27 -27
- package/dist/NavigationMenu/AxosBank/MobileMenu/MobileNavData.d.ts +15 -13
- package/dist/NavigationMenu/AxosBank/MobileMenu/MobileNavData.js +368 -196
- package/dist/NavigationMenu/AxosBank/NavBar.module.js +39 -39
- package/dist/NavigationMenu/AxosBank/NavData.d.ts +2 -39
- package/dist/NavigationMenu/AxosBank/NavData.js +166 -34
- package/dist/NavigationMenu/AxosBank/SubNavBar.js +486 -429
- package/dist/NavigationMenu/AxosBank/index.js +74 -20
- package/dist/NavigationMenu/AxosClearing/NavBar.module.js +37 -37
- package/dist/NavigationMenu/AxosClearing/index.js +1 -0
- package/dist/NavigationMenu/AxosFiduciary/NavBar.module.js +41 -41
- package/dist/NavigationMenu/LaVictoire/NavBar.module.js +37 -37
- package/dist/NavigationMenu/LaVictoire/NavData.d.ts +2 -13
- package/dist/NavigationMenu/LaVictoire/NavData.js +146 -14
- package/dist/NavigationMenu/LaVictoire/SubNavBar.js +1 -4
- package/dist/NavigationMenu/LaVictoire/index.js +44 -19
- package/dist/NavigationMenu/Navbar.js +9 -8
- package/dist/NavigationMenu/SignInNavButton.js +27 -19
- package/dist/SetContainer/SetContainer.css.d.ts +1 -0
- package/dist/SetContainer/SetContainer.css.js +5 -3
- package/dist/SetContainer/SetContainer.js +18 -7
- package/dist/SetContainer/index.js +2 -1
- package/dist/SocialMediaBar/iconsRepository.d.ts +14 -44
- package/dist/SocialMediaBar/iconsRepository.js +41 -32
- package/dist/SocialMediaBar/index.js +1 -3
- package/dist/Tab/Tab.js +1 -0
- package/dist/Table/Table.css.d.ts +21 -1
- package/dist/Table/Table.css.js +18 -18
- package/dist/Table/Table.d.ts +1 -1
- package/dist/Table/Table.js +6 -3
- package/dist/VideoTile/VideoTile.js +9 -4
- package/dist/VideoWrapper/index.js +9 -4
- package/dist/WalnutIframe/wrapper.module.js +3 -3
- package/dist/assets/Avatar/Avatar.css +59 -59
- package/dist/assets/Blockquote/Blockquote.css +72 -72
- package/dist/assets/Calculators/AxosOneCalculator/BalanceAPYCalculator.css +2 -2
- package/dist/assets/Calculators/calculator.css +25 -15
- package/dist/assets/Chatbot/AnimatedGradientBorder.css +99 -12
- package/dist/assets/Chatbot/Bubble.css +21 -6
- package/dist/assets/Chatbot/ChatWindow.css +127 -90
- package/dist/assets/Comparison/Comparison.css +2 -2
- package/dist/assets/DownloadTile/DownloadTile.css +7 -0
- package/dist/assets/ExecutiveBio/ExecutiveBio.css +0 -2
- package/dist/assets/FdicCallout/FdicCallout.css +48 -48
- package/dist/assets/Forms/Forms.css +94 -91
- package/dist/assets/HeroBanner/HeroBanner.css +82 -65
- package/dist/assets/HeroBanner/LargeBanner.css +126 -59
- package/dist/assets/ImageBillboard/ImageBillboard.css +1 -1
- package/dist/assets/Interstitial/Interstitial.css +142 -142
- package/dist/assets/NavigationMenu/AxosALTS/NavBar.css +264 -264
- package/dist/assets/NavigationMenu/AxosAdvisor/NavBar.css +609 -609
- package/dist/assets/NavigationMenu/AxosAdvisorServices/NavBar.css +630 -630
- package/dist/assets/NavigationMenu/AxosBank/MobileMenu/MobileMenu.css +353 -353
- package/dist/assets/NavigationMenu/AxosBank/NavBar.css +445 -445
- package/dist/assets/NavigationMenu/AxosClearing/NavBar.css +484 -484
- package/dist/assets/NavigationMenu/AxosFiduciary/NavBar.css +427 -427
- package/dist/assets/NavigationMenu/LaVictoire/NavBar.css +429 -429
- package/dist/assets/SetContainer/SetContainer.css +25 -15
- package/dist/assets/Table/Table.css +90 -75
- package/dist/assets/TextBlock/TextBlock.css +7 -0
- package/dist/assets/VideoTile/VideoTile.css +6 -0
- package/dist/assets/WalnutIframe/wrapper.css +48 -48
- package/dist/assets/globals.css +9 -9
- package/dist/assets/notification.mp3.js +4 -0
- package/dist/assets/themes/axos.css +8 -7
- package/dist/assets/themes/premier.css +9 -8
- package/dist/assets/themes/ufb.css +9 -8
- package/dist/assets/themes/victorie.css +9 -8
- package/dist/assets/utils/optimizeImage/optimizeImage.css +47 -47
- package/dist/main.js +11 -11
- package/dist/themes/axos.css.d.ts +1 -0
- package/dist/themes/axos.css.js +1 -1
- package/dist/utils/allowedAxosDomains.d.ts +2 -5
- package/dist/utils/allowedAxosDomains.js +46 -50
- package/dist/utils/appendQueryParams.js +53 -16
- package/dist/utils/getPosition.d.ts +1 -0
- package/dist/utils/getPosition.js +17 -0
- package/dist/utils/index.d.ts +0 -1
- package/dist/utils/index.js +1 -7
- package/dist/utils/optimizeImage/optimizeImage.module.js +3 -3
- package/dist/utils/validateExternalLinks.d.ts +1 -1
- package/dist/utils/validateExternalLinks.js +2 -2
- package/dist/utils/variant.types.d.ts +1 -0
- package/package.json +148 -149
- package/dist/Chatbot/authenticate.d.ts +0 -3
- package/dist/Chatbot/authenticate.js +0 -16
- package/dist/utils/samePageNavigation.d.ts +0 -3
- package/dist/utils/samePageNavigation.js +0 -23
- package/dist/utils/samePageQueryParamsNavigation.d.ts +0 -4
- package/dist/utils/samePageQueryParamsNavigation.js +0 -63
package/dist/Chatbot/Chatbot.js
CHANGED
|
@@ -1,18 +1,28 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { jsxs, jsx } from "react/jsx-runtime";
|
|
3
|
-
import {
|
|
3
|
+
import { useRef, useState, useEffect } from "react";
|
|
4
|
+
import { useLocation, useMount, useUnmount } from "react-use";
|
|
5
|
+
import notificationSound from "../assets/notification.mp3.js";
|
|
4
6
|
import { Bubble } from "./Bubble.js";
|
|
5
|
-
import {
|
|
7
|
+
import { chatbotAXB, chatbotUFB } from "./Chatbot.css.js";
|
|
6
8
|
import { ChatWindow } from "./ChatWindow.js";
|
|
7
9
|
import { useOpenChat } from "./store/chat.js";
|
|
8
10
|
import { useMessages } from "./store/messages.js";
|
|
9
|
-
|
|
10
|
-
|
|
11
|
+
if (typeof window !== "undefined") {
|
|
12
|
+
const OriginalAudio = window.Audio;
|
|
13
|
+
class PatchedAudio extends OriginalAudio {
|
|
14
|
+
constructor(src) {
|
|
15
|
+
const newSrc = src === "https://websdk.ujet.co/v3/ping.mp3" ? notificationSound : src;
|
|
16
|
+
super(newSrc);
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
window.Audio = PatchedAudio;
|
|
20
|
+
}
|
|
11
21
|
const Chatbot = ({
|
|
12
22
|
project = "axos",
|
|
13
23
|
projectEnv = "dev",
|
|
14
24
|
menuOption = "Support Virtual Agent",
|
|
15
|
-
|
|
25
|
+
config
|
|
16
26
|
}) => {
|
|
17
27
|
const {
|
|
18
28
|
hasOpenedOnce,
|
|
@@ -22,19 +32,23 @@ const Chatbot = ({
|
|
|
22
32
|
hasEscalated,
|
|
23
33
|
endEscalation,
|
|
24
34
|
unblockInput,
|
|
25
|
-
blockInput
|
|
35
|
+
blockInput,
|
|
36
|
+
hasStarted,
|
|
37
|
+
setChatStarted,
|
|
38
|
+
resetChatStarted,
|
|
39
|
+
setChatStatus,
|
|
40
|
+
displayThankyouMessage
|
|
26
41
|
} = useOpenChat();
|
|
42
|
+
const location = useLocation();
|
|
27
43
|
const { addMessage, addMessages, clearMessages, messages } = useMessages();
|
|
28
44
|
const clientRef = useRef(null);
|
|
29
45
|
const menuRef = useRef(null);
|
|
30
46
|
const isMountedRef = useRef(false);
|
|
31
|
-
const hasLoadedBefore = useRef(true);
|
|
32
47
|
const chatRef = useRef(null);
|
|
48
|
+
const chatLoading = useRef(false);
|
|
33
49
|
const agent_virtual = useRef(null);
|
|
34
50
|
const [status, setStatus] = useState("idle");
|
|
35
|
-
const [hasStarted, setHasStarted] = useState(false);
|
|
36
51
|
const [menusLoaded, setMenusLoaded] = useState(false);
|
|
37
|
-
const [pendingStart, setPendingStart] = useState(false);
|
|
38
52
|
const [isTyping, setIsTyping] = useState(false);
|
|
39
53
|
const [scalationStarted, setScalationStarted] = useState(false);
|
|
40
54
|
useEffect(() => {
|
|
@@ -80,6 +94,10 @@ const Chatbot = ({
|
|
|
80
94
|
env: {
|
|
81
95
|
label: "env",
|
|
82
96
|
value: projectEnv === "uat" ? "dev" : projectEnv
|
|
97
|
+
},
|
|
98
|
+
url: {
|
|
99
|
+
label: "url",
|
|
100
|
+
value: location.href
|
|
83
101
|
}
|
|
84
102
|
}
|
|
85
103
|
};
|
|
@@ -89,6 +107,9 @@ const Chatbot = ({
|
|
|
89
107
|
menuRef.current = await clientRef.current.getMenus();
|
|
90
108
|
setMenusLoaded(true);
|
|
91
109
|
console.log("menus:", menuRef.current);
|
|
110
|
+
if (menuRef.current !== null) {
|
|
111
|
+
await startChat("onReady");
|
|
112
|
+
}
|
|
92
113
|
}
|
|
93
114
|
};
|
|
94
115
|
const onAuthenticatedHandler = async () => {
|
|
@@ -219,20 +240,24 @@ const Chatbot = ({
|
|
|
219
240
|
clientRef.current?.off("chat.connected", onChatConnectedHandler);
|
|
220
241
|
};
|
|
221
242
|
const createClient = async () => {
|
|
222
|
-
const { Client
|
|
223
|
-
if (projectEnv !== "prod" || debug) {
|
|
224
|
-
Logger.addHandler(consoleLoggerHandler);
|
|
225
|
-
}
|
|
243
|
+
const { Client } = await import("@ujet/websdk-headless");
|
|
226
244
|
if (clientRef.current) return;
|
|
227
245
|
const client = new Client({
|
|
228
|
-
companyId:
|
|
229
|
-
tenant:
|
|
230
|
-
host:
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
246
|
+
companyId: config.companyId,
|
|
247
|
+
tenant: config.tenantName,
|
|
248
|
+
host: config.host,
|
|
249
|
+
authenticate: async () => {
|
|
250
|
+
const res = await fetch(config.authUrl, {
|
|
251
|
+
method: "GET",
|
|
252
|
+
headers: {
|
|
253
|
+
"Content-Type": "application/json"
|
|
254
|
+
}
|
|
255
|
+
});
|
|
256
|
+
const data = await res.json();
|
|
257
|
+
return {
|
|
258
|
+
token: data.token
|
|
259
|
+
};
|
|
260
|
+
}
|
|
236
261
|
});
|
|
237
262
|
client?.on("ready", onReadyHandler);
|
|
238
263
|
client?.on("authenticated", onAuthenticatedHandler);
|
|
@@ -241,35 +266,55 @@ const Chatbot = ({
|
|
|
241
266
|
registerEventHandlers();
|
|
242
267
|
return;
|
|
243
268
|
};
|
|
244
|
-
const startChat = async () => {
|
|
245
|
-
console.log("Starting chat");
|
|
269
|
+
const startChat = async (source) => {
|
|
246
270
|
const client = clientRef.current;
|
|
247
|
-
if (!client)
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
271
|
+
if (!client) {
|
|
272
|
+
console.log(`no client detected`);
|
|
273
|
+
return;
|
|
274
|
+
}
|
|
275
|
+
if (hasStarted) {
|
|
276
|
+
console.log(`has started is ${hasStarted}`);
|
|
277
|
+
return;
|
|
278
|
+
}
|
|
279
|
+
if (chatLoading.current) {
|
|
280
|
+
console.log(`startChat skipped [${source}] — already in progress`);
|
|
281
|
+
return;
|
|
258
282
|
}
|
|
283
|
+
setChatStatus("connected");
|
|
259
284
|
try {
|
|
285
|
+
console.log(`Starting chat [${source}]`, chatRef.current);
|
|
286
|
+
chatLoading.current = true;
|
|
287
|
+
if (!menuRef.current || !menuRef.current.menus) {
|
|
288
|
+
let waited = 0;
|
|
289
|
+
while ((!menuRef.current || !menuRef.current.menus) && waited < 5e3) {
|
|
290
|
+
await new Promise((res) => setTimeout(res, 100));
|
|
291
|
+
waited += 100;
|
|
292
|
+
}
|
|
293
|
+
if (!menuRef.current || !menuRef.current.menus) {
|
|
294
|
+
console.error("Menu not loaded, cannot start chat");
|
|
295
|
+
return;
|
|
296
|
+
}
|
|
297
|
+
}
|
|
298
|
+
console.log("menus: ->", menuRef.current);
|
|
260
299
|
const ongoingChat = await client.loadOngoingChat();
|
|
300
|
+
console.log("theres a ongoing chat?: -->", ongoingChat);
|
|
261
301
|
if (ongoingChat) {
|
|
262
302
|
console.log("Ongoing chat found:", ongoingChat);
|
|
263
303
|
console.log("Resuming chat:", ongoingChat.id);
|
|
264
|
-
chatRef.current =
|
|
304
|
+
chatRef.current = ongoingChat;
|
|
265
305
|
agent_virtual.current = ongoingChat.agent;
|
|
266
306
|
return;
|
|
267
307
|
}
|
|
308
|
+
console.log("not ongoing chat ");
|
|
309
|
+
console.log(!!ongoingChat);
|
|
268
310
|
const foundMenu = menuRef.current.menus.find(
|
|
269
311
|
(menu) => menu.name === menuOption
|
|
270
312
|
);
|
|
271
313
|
const menuId = foundMenu && foundMenu.id;
|
|
272
314
|
console.log("Creating new chat with menu ID:", menuId);
|
|
315
|
+
if (!foundMenu) {
|
|
316
|
+
throw new Error("Menu not found: " + menuOption);
|
|
317
|
+
}
|
|
273
318
|
const newChat = await client.createChat(menuId, { custom_data });
|
|
274
319
|
if (newChat !== null) {
|
|
275
320
|
chatRef.current = newChat;
|
|
@@ -278,22 +323,30 @@ const Chatbot = ({
|
|
|
278
323
|
}
|
|
279
324
|
} catch (err) {
|
|
280
325
|
console.error("Error creating chat:", err);
|
|
326
|
+
} finally {
|
|
327
|
+
chatLoading.current = false;
|
|
328
|
+
setChatStarted();
|
|
281
329
|
}
|
|
282
330
|
};
|
|
283
331
|
const handleClick = async () => {
|
|
284
332
|
toggle();
|
|
285
333
|
if (hasStarted) return;
|
|
286
|
-
if (!menusLoaded) {
|
|
287
|
-
setPendingStart(true);
|
|
288
|
-
return;
|
|
289
|
-
}
|
|
290
334
|
if (!hasOpenedOnce) {
|
|
291
|
-
await startChat();
|
|
292
|
-
|
|
335
|
+
await startChat("bubbleClick");
|
|
336
|
+
setChatStarted();
|
|
293
337
|
}
|
|
294
338
|
};
|
|
295
339
|
const onSendMessage = async (msg) => {
|
|
296
|
-
|
|
340
|
+
const clientChatId = clientRef.current?.chat?.id;
|
|
341
|
+
const refChatId = chatRef.current?.id;
|
|
342
|
+
console.log(
|
|
343
|
+
"Sending message:",
|
|
344
|
+
msg,
|
|
345
|
+
"| client.chat.id:",
|
|
346
|
+
clientChatId,
|
|
347
|
+
"| chatRef.id:",
|
|
348
|
+
refChatId
|
|
349
|
+
);
|
|
297
350
|
try {
|
|
298
351
|
await clientRef.current?.sendTextMessage(msg);
|
|
299
352
|
} catch (error) {
|
|
@@ -305,21 +358,33 @@ const Chatbot = ({
|
|
|
305
358
|
}
|
|
306
359
|
};
|
|
307
360
|
const onEndChat = async () => {
|
|
308
|
-
console.log(
|
|
361
|
+
console.log(`Ending chat [end chat]`);
|
|
309
362
|
if (chatRef.current) {
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
363
|
+
try {
|
|
364
|
+
clientRef.current?.finishChat().then(() => {
|
|
365
|
+
console.log(`Chat finished`);
|
|
366
|
+
chatRef.current?.destroy().then(() => {
|
|
367
|
+
console.log(`Chat destroyed`);
|
|
368
|
+
clearMessages();
|
|
369
|
+
chatRef.current = null;
|
|
370
|
+
resetChatStarted();
|
|
371
|
+
console.log("Chat ended");
|
|
372
|
+
endEscalation?.();
|
|
373
|
+
}).finally(() => {
|
|
374
|
+
setChatStatus("ending");
|
|
375
|
+
displayThankyouMessage();
|
|
376
|
+
});
|
|
377
|
+
});
|
|
378
|
+
} catch (error) {
|
|
379
|
+
console.log(error, "from onEndChat");
|
|
380
|
+
}
|
|
381
|
+
return;
|
|
317
382
|
}
|
|
318
383
|
};
|
|
319
384
|
const onEndAndStartNewChat = async () => {
|
|
320
385
|
console.log("Ending current chat and starting a new one");
|
|
321
386
|
await onEndChat();
|
|
322
|
-
await startChat();
|
|
387
|
+
await startChat("endAndStartNew");
|
|
323
388
|
};
|
|
324
389
|
useMount(async () => {
|
|
325
390
|
console.log("Chatbot mounted");
|
|
@@ -327,19 +392,12 @@ const Chatbot = ({
|
|
|
327
392
|
isMountedRef.current = true;
|
|
328
393
|
await createClient();
|
|
329
394
|
});
|
|
330
|
-
useEffect(() => {
|
|
331
|
-
if (menusLoaded && pendingStart && !hasStarted) {
|
|
332
|
-
startChat();
|
|
333
|
-
setPendingStart(false);
|
|
334
|
-
}
|
|
335
|
-
}, [menusLoaded, pendingStart, hasStarted]);
|
|
336
395
|
useUnmount(() => {
|
|
337
396
|
console.log("Chatbot unmounted");
|
|
338
397
|
deregisterEventHandlers();
|
|
339
|
-
|
|
340
|
-
hasLoadedBefore.current = true;
|
|
398
|
+
chatLoading.current = false;
|
|
341
399
|
reset();
|
|
342
|
-
|
|
400
|
+
resetChatStarted();
|
|
343
401
|
setStatus("idle");
|
|
344
402
|
clearMessages();
|
|
345
403
|
endEscalation?.();
|
|
@@ -350,9 +408,13 @@ const Chatbot = ({
|
|
|
350
408
|
const onClose = () => {
|
|
351
409
|
toggle();
|
|
352
410
|
};
|
|
353
|
-
const
|
|
411
|
+
const newChatSession = async () => {
|
|
412
|
+
console.log("create new session");
|
|
413
|
+
};
|
|
414
|
+
const onCloseAfterThankYou = async () => {
|
|
354
415
|
reset();
|
|
355
|
-
|
|
416
|
+
resetChatStarted();
|
|
417
|
+
newChatSession();
|
|
356
418
|
};
|
|
357
419
|
const onPreviewTyping = async (msg) => {
|
|
358
420
|
console.log("Preview typing message:", msg);
|
|
@@ -365,24 +427,30 @@ const Chatbot = ({
|
|
|
365
427
|
console.error("Error sending preview message:", error);
|
|
366
428
|
}
|
|
367
429
|
};
|
|
368
|
-
return menusLoaded && /* @__PURE__ */ jsxs(
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
430
|
+
return menusLoaded && /* @__PURE__ */ jsxs(
|
|
431
|
+
"div",
|
|
432
|
+
{
|
|
433
|
+
className: ["axos", "Axos"].includes(project) ? chatbotAXB : chatbotUFB,
|
|
434
|
+
children: [
|
|
435
|
+
/* @__PURE__ */ jsx(Bubble, { onClick: handleClick, project }),
|
|
436
|
+
/* @__PURE__ */ jsx(
|
|
437
|
+
ChatWindow,
|
|
438
|
+
{
|
|
439
|
+
status,
|
|
440
|
+
virtualAgent: agent_virtual.current,
|
|
441
|
+
messages,
|
|
442
|
+
onSend: onSendMessage,
|
|
443
|
+
endChat: onEndChat,
|
|
444
|
+
onClose,
|
|
445
|
+
onNewChat: onEndAndStartNewChat,
|
|
446
|
+
onCloseAfterThankYou,
|
|
447
|
+
previewTyping: onPreviewTyping,
|
|
448
|
+
isTyping
|
|
449
|
+
}
|
|
450
|
+
)
|
|
451
|
+
]
|
|
452
|
+
}
|
|
453
|
+
);
|
|
386
454
|
};
|
|
387
455
|
export {
|
|
388
456
|
Chatbot
|
|
@@ -12,6 +12,7 @@ interface ChatbotMessageProps {
|
|
|
12
12
|
onCancelEndChat?: () => void;
|
|
13
13
|
onSend?: (content: string) => void;
|
|
14
14
|
onEndChat?: () => void;
|
|
15
|
+
inputRef: React.RefObject<HTMLTextAreaElement | null>;
|
|
15
16
|
}
|
|
16
17
|
export declare const ChatbotMessage: FC<ChatbotMessageProps>;
|
|
17
18
|
export {};
|