@axos-web-dev/shared-components 2.2.9 → 2.2.11
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/ATMLocator/ATMLocator.js +2 -2
- package/dist/Auth/ErrorAlert.js +3 -3
- package/dist/Button/Button.js +2 -2
- package/dist/Calculators/Calculator.js +3 -3
- package/dist/Calculators/MarginTradingCalculator/index.js +2 -2
- package/dist/Carousel/index.js +2 -2
- package/dist/Chatbot/Bubble.js +3 -12
- package/dist/Chatbot/ChatWindow.css.d.ts +0 -6
- package/dist/Chatbot/ChatWindow.css.js +35 -48
- package/dist/Chatbot/ChatWindow.js +76 -135
- package/dist/Chatbot/Chatbot.css.js +1 -0
- package/dist/Chatbot/Chatbot.js +23 -54
- package/dist/Chatbot/ChatbotMessage.js +159 -184
- package/dist/Chatbot/EllipsisAnimation.js +6 -0
- package/dist/Chatbot/index.js +1 -7
- package/dist/Chevron/index.js +2 -2
- package/dist/Comparison/Comparison.js +2 -2
- package/dist/ExecutiveBio/ExecutiveBio.js +2 -2
- package/dist/FaqAccordion/index.js +2 -2
- package/dist/FooterSiteMap/AxosBank/FooterSiteMap.js +2 -2
- package/dist/Forms/ApplyNow.js +2 -2
- package/dist/Forms/ContactUsBusiness.js +2 -2
- package/dist/Forms/ContactUsBusinessNameEmail.js +2 -2
- package/dist/Forms/ContactUsNMLSId.js +2 -2
- package/dist/Forms/CpraRequest.js +2 -2
- package/dist/Forms/CraPublicFile.js +2 -2
- package/dist/Forms/EmailOnly.js +2 -2
- package/dist/Forms/MortgageRate/MortgageRateForm.js +2 -2
- package/dist/Forms/MortgageRate/MortgageRateWatch.js +2 -2
- package/dist/Forms/MortgageWarehouseLending.js +2 -2
- package/dist/Forms/SuccesForm.js +3 -3
- package/dist/Hyperlink/index.js +2 -2
- package/dist/ImageLink/ImageLink.js +2 -2
- package/dist/ImageLink/ImageLinkSet.js +2 -2
- package/dist/ImageLink/index.js +2 -2
- package/dist/Insight/Featured/CategorySelector.js +2 -2
- package/dist/Insight/Featured/Featured.js +2 -2
- package/dist/Insight/Featured/Header.js +2 -2
- package/dist/Modal/Modal.js +2 -2
- package/dist/Modal/contextApi/store.js +1 -0
- package/dist/NavigationMenu/AxosALTS/index.js +2 -2
- package/dist/NavigationMenu/AxosBank/MobileMenu/MobileMenu.js +2 -2
- package/dist/NavigationMenu/AxosBank/SubNavBar.js +2 -2
- package/dist/NavigationMenu/AxosBank/index.js +2 -2
- package/dist/NavigationMenu/LaVictoire/index.js +2 -2
- package/dist/NavigationMenu/Navbar.js +2 -2
- package/dist/NavigationMenu/SignInNavButton.js +2 -2
- package/dist/SetContainer/SetContainer.js +2 -2
- package/dist/SocialMediaBar/iconsRepository.js +2 -2
- package/dist/VideoTile/VideoTile.js +2 -2
- package/dist/VideoWrapper/index.js +2 -2
- package/dist/assets/Chatbot/Bubble.css +7 -26
- package/dist/assets/Chatbot/ChatWindow.css +74 -155
- package/dist/assets/Chatbot/Chatbot.css +3 -0
- package/dist/main.js +1 -7
- package/package.json +1 -1
- package/dist/Chatbot/Chatbot.css.ts.vanilla.css.js +0 -1
|
@@ -1,17 +1,16 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { jsxs, jsx, Fragment } from "react/jsx-runtime";
|
|
3
|
-
import { LoadingIndicator } from "../LoadingIndicator/index.js";
|
|
4
3
|
import { vars } from "../themes/axos.css.js";
|
|
5
4
|
import '../assets/themes/victorie.css';import '../assets/themes/ufb.css';import '../assets/themes/premier.css';import '../assets/themes/axos.css';/* empty css */
|
|
6
5
|
/* empty css */
|
|
7
6
|
/* empty css */
|
|
8
7
|
/* empty css */
|
|
9
8
|
import clsx from "clsx";
|
|
10
|
-
import React, { useRef,
|
|
9
|
+
import React, { useRef, useEffect } from "react";
|
|
11
10
|
import { useNetworkState, useMount } from "react-use";
|
|
12
|
-
import {
|
|
11
|
+
import { gradientFocus } from "./AnimatedGradientBorder.css.js";
|
|
13
12
|
import { ChatbotMessage } from "./ChatbotMessage.js";
|
|
14
|
-
import { windowBarStyle, left_bar_section, chat_title, button_bar, chatbotMenuItem, chatbotMenu, chatEndDialogOverlay, chatFinishDialog, chatEndCircle, endChatButtonStyle, noAnswerButton, arrowFill, button_reset, buttonss_section, chatNetworkStatus, shimmerText, messagesContainerStyle,
|
|
13
|
+
import { windowBarStyle, left_bar_section, chat_title, button_bar, chatbotMenuItem, chatbotMenu, chatEndDialogOverlay, chatFinishDialog, chatEndCircle, endChatButtonStyle, noAnswerButton, arrowFill, button_reset, buttonss_section, chatNetworkStatus, shimmerText, messagesContainerStyle, inputStyle, autoResize, sendButtonStyle, windowStyle, windowOpenStyle, windowExpandedStyle } from "./ChatWindow.css.js";
|
|
15
14
|
import { EllipsisIcon } from "./EllipsisIcon.js";
|
|
16
15
|
import { ExpandChatToggle } from "./ExpandChatToggle.js";
|
|
17
16
|
import { useOpenChat } from "./store/chat.js";
|
|
@@ -41,13 +40,12 @@ const ChatWindow = ({
|
|
|
41
40
|
}) => {
|
|
42
41
|
const {
|
|
43
42
|
showThankyouMessage,
|
|
43
|
+
displayThankyouMessage,
|
|
44
44
|
toggleThankyouMessage,
|
|
45
45
|
hasEscalated,
|
|
46
46
|
isBlockedInput,
|
|
47
47
|
isOpen,
|
|
48
48
|
hasOpenedOnce,
|
|
49
|
-
chatStatus,
|
|
50
|
-
setChatStatus,
|
|
51
49
|
isWindowExpanded,
|
|
52
50
|
toggleWindowExpanded
|
|
53
51
|
} = useOpenChat();
|
|
@@ -58,7 +56,6 @@ const ChatWindow = ({
|
|
|
58
56
|
const [input, setInput] = React.useState("");
|
|
59
57
|
const messagesEndRef = useRef(null);
|
|
60
58
|
const inputRef = useRef(null);
|
|
61
|
-
const [focused, setFocused] = useState(false);
|
|
62
59
|
useEffect(() => {
|
|
63
60
|
messagesEndRef.current?.scrollIntoView({ behavior: "smooth" });
|
|
64
61
|
}, [messages]);
|
|
@@ -89,6 +86,9 @@ const ChatWindow = ({
|
|
|
89
86
|
useEffect(() => {
|
|
90
87
|
autoResizeTextarea();
|
|
91
88
|
}, [input]);
|
|
89
|
+
const displayThankYouScreen = () => {
|
|
90
|
+
displayThankyouMessage();
|
|
91
|
+
};
|
|
92
92
|
const onCancelEndChat = () => {
|
|
93
93
|
setShowEndChatDialog(false);
|
|
94
94
|
toggleThankyouMessage?.();
|
|
@@ -182,7 +182,7 @@ const ChatWindow = ({
|
|
|
182
182
|
alignContent: "center",
|
|
183
183
|
background: menuOpen ? "#0000000f" : void 0
|
|
184
184
|
},
|
|
185
|
-
children: /* @__PURE__ */ jsx(EllipsisIcon, {
|
|
185
|
+
children: /* @__PURE__ */ jsx(EllipsisIcon, {})
|
|
186
186
|
}
|
|
187
187
|
),
|
|
188
188
|
menuOpen && /* @__PURE__ */ jsx("ul", { className: clsx(chatbotMenu), children: /* @__PURE__ */ jsx("li", { className: chatbotMenuItem, children: /* @__PURE__ */ jsxs(
|
|
@@ -214,7 +214,7 @@ const ChatWindow = ({
|
|
|
214
214
|
"path",
|
|
215
215
|
{
|
|
216
216
|
d: "M11.1236 5.37374L8.60278 7.89457L11.1236 10.4167L10.4166 11.1237L7.89445 8.6029L5.37362 11.1237L4.66658 10.4167L7.18742 7.89457L4.66658 5.37374L5.37362 4.66671L7.89445 7.18754L10.4166 4.66671L11.1236 5.37374Z",
|
|
217
|
-
fill:
|
|
217
|
+
fill: "#1E3860"
|
|
218
218
|
}
|
|
219
219
|
),
|
|
220
220
|
/* @__PURE__ */ jsx(
|
|
@@ -223,7 +223,7 @@ const ChatWindow = ({
|
|
|
223
223
|
fillRule: "evenodd",
|
|
224
224
|
clipRule: "evenodd",
|
|
225
225
|
d: "M13.3333 0.833374C14.3458 0.833374 15.1666 1.65419 15.1666 2.66671V13.3334C15.1666 14.3459 14.3458 15.1667 13.3333 15.1667H2.66659C1.65406 15.1667 0.833252 14.3459 0.833252 13.3334V2.66671C0.833252 1.65419 1.65406 0.833374 2.66659 0.833374H13.3333ZM2.66659 1.83337C2.20635 1.83337 1.83325 2.20647 1.83325 2.66671V13.3334C1.83325 13.7936 2.20635 14.1667 2.66659 14.1667H13.3333C13.7935 14.1667 14.1666 13.7936 14.1666 13.3334V2.66671C14.1666 2.20647 13.7935 1.83337 13.3333 1.83337H2.66659Z",
|
|
226
|
-
fill:
|
|
226
|
+
fill: "#1E3860"
|
|
227
227
|
}
|
|
228
228
|
)
|
|
229
229
|
] }),
|
|
@@ -310,7 +310,7 @@ const ChatWindow = ({
|
|
|
310
310
|
type: "submit",
|
|
311
311
|
onClick: () => {
|
|
312
312
|
endChat();
|
|
313
|
-
|
|
313
|
+
displayThankYouScreen();
|
|
314
314
|
setShowEndChatDialog(false);
|
|
315
315
|
},
|
|
316
316
|
children: "Yes, End Chat"
|
|
@@ -333,45 +333,6 @@ const ChatWindow = ({
|
|
|
333
333
|
" "
|
|
334
334
|
] }) })
|
|
335
335
|
] }),
|
|
336
|
-
chatStatus == "ending" && /* @__PURE__ */ jsxs("div", { children: [
|
|
337
|
-
/* @__PURE__ */ jsx(
|
|
338
|
-
"div",
|
|
339
|
-
{
|
|
340
|
-
style: {
|
|
341
|
-
background: "#00000080",
|
|
342
|
-
position: "fixed",
|
|
343
|
-
top: 0,
|
|
344
|
-
left: 0,
|
|
345
|
-
right: 0,
|
|
346
|
-
bottom: 0,
|
|
347
|
-
zIndex: 999
|
|
348
|
-
}
|
|
349
|
-
}
|
|
350
|
-
),
|
|
351
|
-
/* @__PURE__ */ jsx(
|
|
352
|
-
"div",
|
|
353
|
-
{
|
|
354
|
-
style: {
|
|
355
|
-
position: "fixed",
|
|
356
|
-
top: 0,
|
|
357
|
-
left: 0,
|
|
358
|
-
right: 0,
|
|
359
|
-
bottom: 0,
|
|
360
|
-
zIndex: 1e3,
|
|
361
|
-
display: "flex",
|
|
362
|
-
justifyContent: "center",
|
|
363
|
-
alignItems: "center"
|
|
364
|
-
},
|
|
365
|
-
children: /* @__PURE__ */ jsx(
|
|
366
|
-
LoadingIndicator,
|
|
367
|
-
{
|
|
368
|
-
variant: "primary",
|
|
369
|
-
style: { borderTopColor: vars.chatbot.bubble.glowShadow }
|
|
370
|
-
}
|
|
371
|
-
)
|
|
372
|
-
}
|
|
373
|
-
)
|
|
374
|
-
] }),
|
|
375
336
|
/* @__PURE__ */ jsx(
|
|
376
337
|
ThankYouMessage,
|
|
377
338
|
{
|
|
@@ -475,7 +436,7 @@ const ChatWindow = ({
|
|
|
475
436
|
fontSize: 14,
|
|
476
437
|
display: "flex",
|
|
477
438
|
flexDirection: "column",
|
|
478
|
-
gap:
|
|
439
|
+
gap: 4
|
|
479
440
|
},
|
|
480
441
|
children: /* @__PURE__ */ jsx("p", { className: shimmerText, children: "Chat connecting..." })
|
|
481
442
|
}
|
|
@@ -515,91 +476,71 @@ const ChatWindow = ({
|
|
|
515
476
|
),
|
|
516
477
|
/* @__PURE__ */ jsx("div", { ref: messagesEndRef })
|
|
517
478
|
] }),
|
|
518
|
-
/* @__PURE__ */ jsx("div", { style: { padding: "16px 16px 24px 16px" }, children: /* @__PURE__ */
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
{
|
|
522
|
-
|
|
523
|
-
|
|
479
|
+
/* @__PURE__ */ jsx("div", { style: { padding: "16px 16px 24px 16px" }, children: /* @__PURE__ */ jsx("form", { onSubmit: handleSend, className: clsx(gradientFocus), children: /* @__PURE__ */ jsxs(
|
|
480
|
+
"div",
|
|
481
|
+
{
|
|
482
|
+
style: {
|
|
483
|
+
display: "flex",
|
|
484
|
+
padding: "12px 16px",
|
|
485
|
+
background: isBlockedInput || inputDisabled || status !== "connected" || messages.length == 0 || escalationDeflected ? "light-dark(rgba(239, 239, 239, 0.3), rgba(59, 59, 59, 0.3))" : "#ffffff",
|
|
486
|
+
borderRadius: 12
|
|
487
|
+
},
|
|
488
|
+
children: [
|
|
489
|
+
/* @__PURE__ */ jsx(
|
|
490
|
+
"textarea",
|
|
491
|
+
{
|
|
492
|
+
ref: inputRef,
|
|
493
|
+
value: input,
|
|
494
|
+
onChange: (e) => setInput(e.target.value),
|
|
495
|
+
onKeyDown: (e) => {
|
|
496
|
+
if (hasEscalated) {
|
|
497
|
+
previewTyping(e.target?.value);
|
|
498
|
+
}
|
|
499
|
+
if (e.key === "Enter" && !e.shiftKey) {
|
|
500
|
+
handleSend(e);
|
|
501
|
+
}
|
|
502
|
+
},
|
|
503
|
+
placeholder: "Ask anything...",
|
|
504
|
+
className: clsx(inputStyle, autoResize),
|
|
505
|
+
autoFocus: true,
|
|
506
|
+
disabled: isBlockedInput || inputDisabled || status !== "connected" || messages.length == 0 || escalationDeflected,
|
|
507
|
+
rows: 1
|
|
508
|
+
}
|
|
524
509
|
),
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
onFocus: () => setFocused(() => true),
|
|
560
|
-
onBlur: () => setFocused(() => false),
|
|
561
|
-
placeholder: "Ask anything...",
|
|
562
|
-
className: clsx(inputStyle, autoResize),
|
|
563
|
-
autoFocus: true,
|
|
564
|
-
disabled: isBlockedInput || inputDisabled || status !== "connected" || messages.length == 0 || escalationDeflected,
|
|
565
|
-
rows: 1
|
|
566
|
-
}
|
|
567
|
-
),
|
|
568
|
-
/* @__PURE__ */ jsx(
|
|
569
|
-
"button",
|
|
570
|
-
{
|
|
571
|
-
className: clsx(
|
|
572
|
-
sendButtonStyle,
|
|
573
|
-
input.trim().length > 0 && "active"
|
|
574
|
-
),
|
|
575
|
-
type: "submit",
|
|
576
|
-
title: "Send message",
|
|
577
|
-
disabled: isBlockedInput || inputDisabled || status !== "connected" || !input.trim() || messages.length == 0 || escalationDeflected,
|
|
578
|
-
children: /* @__PURE__ */ jsx(
|
|
579
|
-
"svg",
|
|
580
|
-
{
|
|
581
|
-
xmlns: "http://www.w3.org/2000/svg",
|
|
582
|
-
width: "20",
|
|
583
|
-
height: "20",
|
|
584
|
-
viewBox: "0 0 16 16",
|
|
585
|
-
fill: "none",
|
|
586
|
-
children: /* @__PURE__ */ jsx(
|
|
587
|
-
"path",
|
|
588
|
-
{
|
|
589
|
-
fillRule: "evenodd",
|
|
590
|
-
clipRule: "evenodd",
|
|
591
|
-
d: "M0.0030533 5.42479C0.0273417 5.1795 0.193529 4.9714 0.427369 4.89345L15.0114 0.0320896C15.236 -0.0427712 15.4836 0.0156801 15.651 0.183075C15.8184 0.35047 15.8769 0.598075 15.802 0.822659L10.9407 15.4067C10.8627 15.6406 10.6546 15.8068 10.4093 15.8311C10.164 15.8553 9.92737 15.7332 9.80508 15.5192L6.35411 9.47999L0.314925 6.02903C0.100912 5.90673 -0.0212351 5.67008 0.0030533 5.42479ZM7.59169 9.1263L9.64202 12.7144C9.85645 13.0896 10.4138 13.0344 10.5505 12.6244L13.9046 2.56191C14.0349 2.17103 13.6631 1.79916 13.2722 1.92946L3.20969 5.28362C2.79967 5.4203 2.74448 5.97766 3.11973 6.19209L6.70781 8.24242L9.90579 5.04443C10.1499 4.80036 10.5456 4.80036 10.7897 5.04443C11.0337 5.28851 11.0337 5.68424 10.7897 5.92832L7.59169 9.1263Z",
|
|
592
|
-
fill: "#435164"
|
|
593
|
-
}
|
|
594
|
-
)
|
|
595
|
-
}
|
|
596
|
-
)
|
|
597
|
-
}
|
|
598
|
-
)
|
|
599
|
-
]
|
|
600
|
-
}
|
|
601
|
-
)
|
|
602
|
-
] }) })
|
|
510
|
+
/* @__PURE__ */ jsx(
|
|
511
|
+
"button",
|
|
512
|
+
{
|
|
513
|
+
className: clsx(
|
|
514
|
+
sendButtonStyle,
|
|
515
|
+
input.trim().length > 0 && "active"
|
|
516
|
+
),
|
|
517
|
+
type: "submit",
|
|
518
|
+
title: "Send message",
|
|
519
|
+
disabled: isBlockedInput || inputDisabled || status !== "connected" || !input.trim() || messages.length == 0 || escalationDeflected,
|
|
520
|
+
children: /* @__PURE__ */ jsx(
|
|
521
|
+
"svg",
|
|
522
|
+
{
|
|
523
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
524
|
+
width: "16",
|
|
525
|
+
height: "16",
|
|
526
|
+
viewBox: "0 0 16 16",
|
|
527
|
+
fill: "none",
|
|
528
|
+
children: /* @__PURE__ */ jsx(
|
|
529
|
+
"path",
|
|
530
|
+
{
|
|
531
|
+
fillRule: "evenodd",
|
|
532
|
+
clipRule: "evenodd",
|
|
533
|
+
d: "M0.0030533 5.42479C0.0273417 5.1795 0.193529 4.9714 0.427369 4.89345L15.0114 0.0320896C15.236 -0.0427712 15.4836 0.0156801 15.651 0.183075C15.8184 0.35047 15.8769 0.598075 15.802 0.822659L10.9407 15.4067C10.8627 15.6406 10.6546 15.8068 10.4093 15.8311C10.164 15.8553 9.92737 15.7332 9.80508 15.5192L6.35411 9.47999L0.314925 6.02903C0.100912 5.90673 -0.0212351 5.67008 0.0030533 5.42479ZM7.59169 9.1263L9.64202 12.7144C9.85645 13.0896 10.4138 13.0344 10.5505 12.6244L13.9046 2.56191C14.0349 2.17103 13.6631 1.79916 13.2722 1.92946L3.20969 5.28362C2.79967 5.4203 2.74448 5.97766 3.11973 6.19209L6.70781 8.24242L9.90579 5.04443C10.1499 4.80036 10.5456 4.80036 10.7897 5.04443C11.0337 5.28851 11.0337 5.68424 10.7897 5.92832L7.59169 9.1263Z",
|
|
534
|
+
fill: "#435164"
|
|
535
|
+
}
|
|
536
|
+
)
|
|
537
|
+
}
|
|
538
|
+
)
|
|
539
|
+
}
|
|
540
|
+
)
|
|
541
|
+
]
|
|
542
|
+
}
|
|
543
|
+
) }) })
|
|
603
544
|
]
|
|
604
545
|
}
|
|
605
546
|
);
|
package/dist/Chatbot/Chatbot.js
CHANGED
|
@@ -13,9 +13,6 @@ import { useMessages } from "./store/messages.js";
|
|
|
13
13
|
const audioManager = new AudioManager();
|
|
14
14
|
audioManager.installUjetAudioOverride(notificationSound);
|
|
15
15
|
audioManager.setSoundEnabled(false);
|
|
16
|
-
function isChat(obj) {
|
|
17
|
-
return obj !== null && typeof obj === "object" && "id" in obj && "agent" in obj && typeof obj.connect === "function";
|
|
18
|
-
}
|
|
19
16
|
const Chatbot = ({
|
|
20
17
|
project = "axos",
|
|
21
18
|
projectEnv = "dev",
|
|
@@ -31,13 +28,7 @@ const Chatbot = ({
|
|
|
31
28
|
hasEscalated,
|
|
32
29
|
endEscalation,
|
|
33
30
|
unblockInput,
|
|
34
|
-
blockInput
|
|
35
|
-
hasStarted,
|
|
36
|
-
setChatStarted,
|
|
37
|
-
resetChatStarted,
|
|
38
|
-
setChatStatus,
|
|
39
|
-
displayThankyouMessage,
|
|
40
|
-
hideDisplayThankyouMessage
|
|
31
|
+
blockInput
|
|
41
32
|
} = useOpenChat();
|
|
42
33
|
const isVisible = usePageVisibility();
|
|
43
34
|
const { addMessage, addMessages, clearMessages, messages } = useMessages();
|
|
@@ -48,6 +39,7 @@ const Chatbot = ({
|
|
|
48
39
|
const chatLoading = useRef(false);
|
|
49
40
|
const agent_virtual = useRef(null);
|
|
50
41
|
const [status, setStatus] = useState("idle");
|
|
42
|
+
const [hasStarted, setHasStarted] = useState(false);
|
|
51
43
|
const [menusLoaded, setMenusLoaded] = useState(false);
|
|
52
44
|
const [isTyping, setIsTyping] = useState(false);
|
|
53
45
|
const [scalationStarted, setScalationStarted] = useState(false);
|
|
@@ -77,7 +69,7 @@ const Chatbot = ({
|
|
|
77
69
|
$index: -10,
|
|
78
70
|
$userId: 0
|
|
79
71
|
};
|
|
80
|
-
const custom_data =
|
|
72
|
+
const custom_data = {
|
|
81
73
|
unsigned: {
|
|
82
74
|
facingBrandId: {
|
|
83
75
|
label: "facingBrandId",
|
|
@@ -94,13 +86,9 @@ const Chatbot = ({
|
|
|
94
86
|
env: {
|
|
95
87
|
label: "env",
|
|
96
88
|
value: projectEnv === "uat" ? "dev" : projectEnv
|
|
97
|
-
},
|
|
98
|
-
url: {
|
|
99
|
-
label: "url",
|
|
100
|
-
value: window.location.href
|
|
101
89
|
}
|
|
102
90
|
}
|
|
103
|
-
}
|
|
91
|
+
};
|
|
104
92
|
const onReadyHandler = async () => {
|
|
105
93
|
console.log("Chat client is ready");
|
|
106
94
|
if (clientRef.current) {
|
|
@@ -242,6 +230,9 @@ const Chatbot = ({
|
|
|
242
230
|
const createClient = async () => {
|
|
243
231
|
const { Client } = await import("@ujet/websdk-headless");
|
|
244
232
|
if (clientRef.current) return;
|
|
233
|
+
console.log({
|
|
234
|
+
config
|
|
235
|
+
});
|
|
245
236
|
const client = new Client({
|
|
246
237
|
companyId: config.companyId,
|
|
247
238
|
tenant: config.tenantName,
|
|
@@ -268,20 +259,12 @@ const Chatbot = ({
|
|
|
268
259
|
};
|
|
269
260
|
const startChat = async (source) => {
|
|
270
261
|
const client = clientRef.current;
|
|
271
|
-
if (!client)
|
|
272
|
-
|
|
273
|
-
return;
|
|
274
|
-
}
|
|
275
|
-
if (hasStarted) {
|
|
276
|
-
console.log(`has started is ${hasStarted}`);
|
|
277
|
-
return;
|
|
278
|
-
}
|
|
279
|
-
hideDisplayThankyouMessage();
|
|
262
|
+
if (!client) return;
|
|
263
|
+
if (hasStarted) return;
|
|
280
264
|
if (chatLoading.current) {
|
|
281
265
|
console.log(`startChat skipped [${source}] — already in progress`);
|
|
282
266
|
return;
|
|
283
267
|
}
|
|
284
|
-
setChatStatus("connected");
|
|
285
268
|
try {
|
|
286
269
|
console.log(`Starting chat [${source}]`, chatRef.current);
|
|
287
270
|
chatLoading.current = true;
|
|
@@ -316,10 +299,8 @@ const Chatbot = ({
|
|
|
316
299
|
if (!foundMenu) {
|
|
317
300
|
throw new Error("Menu not found: " + menuOption);
|
|
318
301
|
}
|
|
319
|
-
const newChat = await client.createChat(menuId, {
|
|
320
|
-
|
|
321
|
-
});
|
|
322
|
-
if (newChat && typeof newChat === "object" && isChat(newChat)) {
|
|
302
|
+
const newChat = await client.createChat(menuId, { custom_data });
|
|
303
|
+
if (newChat !== null) {
|
|
323
304
|
chatRef.current = newChat;
|
|
324
305
|
agent_virtual.current = newChat.agent;
|
|
325
306
|
console.log("Chat created id:", newChat.id);
|
|
@@ -328,7 +309,7 @@ const Chatbot = ({
|
|
|
328
309
|
console.error("Error creating chat:", err);
|
|
329
310
|
} finally {
|
|
330
311
|
chatLoading.current = false;
|
|
331
|
-
|
|
312
|
+
setHasStarted(true);
|
|
332
313
|
}
|
|
333
314
|
};
|
|
334
315
|
const handleClick = async () => {
|
|
@@ -337,7 +318,7 @@ const Chatbot = ({
|
|
|
337
318
|
if (hasStarted) return;
|
|
338
319
|
if (!hasOpenedOnce) {
|
|
339
320
|
await startChat("bubbleClick");
|
|
340
|
-
|
|
321
|
+
setHasStarted(true);
|
|
341
322
|
}
|
|
342
323
|
};
|
|
343
324
|
const onSendMessage = async (msg) => {
|
|
@@ -362,27 +343,15 @@ const Chatbot = ({
|
|
|
362
343
|
}
|
|
363
344
|
};
|
|
364
345
|
const onEndChat = async () => {
|
|
365
|
-
console.log(
|
|
346
|
+
console.log("Ending chat");
|
|
366
347
|
if (chatRef.current) {
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
resetChatStarted();
|
|
375
|
-
console.log("Chat ended");
|
|
376
|
-
endEscalation?.();
|
|
377
|
-
}).finally(() => {
|
|
378
|
-
setChatStatus("ending");
|
|
379
|
-
displayThankyouMessage();
|
|
380
|
-
});
|
|
381
|
-
});
|
|
382
|
-
} catch (error) {
|
|
383
|
-
console.log(error, "from onEndChat");
|
|
384
|
-
}
|
|
385
|
-
return;
|
|
348
|
+
await clientRef.current?.finishChat();
|
|
349
|
+
await chatRef.current?.destroy();
|
|
350
|
+
clearMessages();
|
|
351
|
+
chatRef.current = null;
|
|
352
|
+
console.log("Chat ended");
|
|
353
|
+
setHasStarted(false);
|
|
354
|
+
endEscalation?.();
|
|
386
355
|
}
|
|
387
356
|
};
|
|
388
357
|
const onEndAndStartNewChat = async () => {
|
|
@@ -401,7 +370,7 @@ const Chatbot = ({
|
|
|
401
370
|
deregisterEventHandlers();
|
|
402
371
|
chatLoading.current = false;
|
|
403
372
|
reset();
|
|
404
|
-
|
|
373
|
+
setHasStarted(false);
|
|
405
374
|
setStatus("idle");
|
|
406
375
|
clearMessages();
|
|
407
376
|
endEscalation?.();
|
|
@@ -417,7 +386,7 @@ const Chatbot = ({
|
|
|
417
386
|
};
|
|
418
387
|
const onCloseAfterThankYou = async () => {
|
|
419
388
|
reset();
|
|
420
|
-
|
|
389
|
+
setHasStarted(false);
|
|
421
390
|
newChatSession();
|
|
422
391
|
};
|
|
423
392
|
const onPreviewTyping = async (msg) => {
|