@axos-web-dev/shared-components 1.0.77-patch.38 → 1.0.77-patch.39
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 +1 -8
- package/dist/Auth/ErrorAlert.js +1 -8
- package/dist/Avatar/Avatar.module.js +7 -7
- package/dist/Blockquote/Blockquote.module.js +3 -3
- package/dist/Button/Button.js +1 -8
- package/dist/Calculators/BuyDownCalculator/index.js +1 -1
- package/dist/Calculators/Calculator.js +2 -9
- package/dist/Calculators/SummitApyCalculator/index.js +15 -6
- package/dist/Carousel/index.js +1 -8
- package/dist/Chevron/index.js +1 -8
- package/dist/Comparison/Comparison.js +1 -8
- package/dist/ExecutiveBio/ExecutiveBio.js +1 -8
- package/dist/FaqAccordion/index.js +1 -8
- package/dist/FooterSiteMap/AxosBank/FooterSiteMap.js +1 -8
- package/dist/Forms/ApplyNow.js +1 -8
- package/dist/Forms/ContactUsBusiness.js +1 -8
- package/dist/Forms/ContactUsBusinessNameEmail.js +1 -8
- package/dist/Forms/ContactUsNMLSId.js +1 -8
- package/dist/Forms/CraPublicFile.js +1 -8
- package/dist/Forms/EmailOnly.js +1 -8
- package/dist/Forms/MortgageRate/MortgageRateForm.js +1 -8
- package/dist/Forms/MortgageRate/MortgageRateWatch.js +1 -8
- package/dist/Forms/MortgageWarehouseLending.js +1 -8
- package/dist/Forms/SuccesForm.js +2 -9
- package/dist/Hyperlink/index.js +1 -8
- package/dist/ImageLink/ImageLink.js +1 -8
- package/dist/ImageLink/ImageLinkSet.js +1 -8
- package/dist/ImageLink/index.js +1 -8
- package/dist/Insight/Featured/CategorySelector.js +1 -8
- package/dist/Insight/Featured/Featured.js +1 -8
- package/dist/Insight/Featured/Header.js +1 -8
- package/dist/Modal/Modal.js +1 -8
- package/dist/NavigationMenu/AxosALTS/NavData.js +1 -8
- package/dist/NavigationMenu/AxosALTS/index.js +1 -8
- package/dist/NavigationMenu/AxosAdvisor/NavBar.module.js +52 -52
- package/dist/NavigationMenu/AxosAdvisorServices/NavBar.module.js +53 -53
- package/dist/NavigationMenu/AxosBank/MobileMenu/MobileMenu.module.js +16 -16
- package/dist/NavigationMenu/AxosBank/MobileMenu/MobileNavData.js +1 -8
- package/dist/NavigationMenu/AxosBank/NavBar.module.js +39 -39
- package/dist/NavigationMenu/AxosBank/NavData.js +1 -8
- package/dist/NavigationMenu/AxosBank/SubNavBar.js +1 -8
- package/dist/NavigationMenu/AxosBank/index.js +1 -8
- package/dist/NavigationMenu/AxosClearing/NavBar.module.js +37 -37
- package/dist/NavigationMenu/AxosFiduciary/NavBar.module.js +41 -41
- package/dist/NavigationMenu/LaVictoire/NavData.js +1 -8
- package/dist/NavigationMenu/LaVictoire/index.js +1 -8
- package/dist/SetContainer/SetContainer.js +1 -8
- package/dist/SocialMediaBar/iconsRepository.js +1 -8
- package/dist/Table/Table.d.ts +1 -1
- package/dist/VideoTile/VideoTile.js +1 -8
- package/dist/VideoWrapper/index.js +1 -8
- package/dist/WalnutIframe/wrapper.module.js +3 -3
- package/dist/assets/Avatar/Avatar.css.css +59 -59
- package/dist/assets/Blockquote/Blockquote.css.css +68 -68
- package/dist/assets/NavigationMenu/AxosAdvisor/NavBar.css.css +597 -597
- package/dist/assets/NavigationMenu/AxosAdvisorServices/NavBar.css.css +618 -618
- package/dist/assets/NavigationMenu/AxosBank/MobileMenu/MobileMenu.css.css +191 -191
- package/dist/assets/NavigationMenu/AxosBank/NavBar.css.css +473 -473
- package/dist/assets/NavigationMenu/AxosClearing/NavBar.css.css +458 -458
- package/dist/assets/NavigationMenu/AxosFiduciary/NavBar.css.css +426 -426
- package/dist/assets/WalnutIframe/wrapper.css.css +48 -48
- package/dist/main.d.ts +0 -1
- package/dist/main.js +0 -35
- package/dist/utils/emailValidation.d.ts +1 -0
- package/dist/utils/emailValidation.js +31 -0
- package/dist/utils/nmlsValidation.d.ts +1 -0
- package/dist/utils/nmlsValidation.js +31 -0
- package/package.json +133 -135
- package/dist/Chatbot/Bubble.css.d.ts +0 -2
- package/dist/Chatbot/Bubble.css.js +0 -8
- package/dist/Chatbot/Bubble.d.ts +0 -5
- package/dist/Chatbot/Bubble.js +0 -103
- package/dist/Chatbot/Chat.d.ts +0 -1
- package/dist/Chatbot/Chat.js +0 -165
- package/dist/Chatbot/ChatWindow.css.d.ts +0 -18
- package/dist/Chatbot/ChatWindow.css.js +0 -39
- package/dist/Chatbot/ChatWindow.d.ts +0 -26
- package/dist/Chatbot/ChatWindow.js +0 -446
- package/dist/Chatbot/Chatbot.css.d.ts +0 -2
- package/dist/Chatbot/Chatbot.css.js +0 -6
- package/dist/Chatbot/Chatbot.css.ts.vanilla.css.js +0 -1
- package/dist/Chatbot/Chatbot.d.ts +0 -10
- package/dist/Chatbot/Chatbot.js +0 -221
- package/dist/Chatbot/EllipsisAnimation.d.ts +0 -2
- package/dist/Chatbot/EllipsisAnimation.js +0 -85
- package/dist/Chatbot/EllipsisIcon.d.ts +0 -4
- package/dist/Chatbot/EllipsisIcon.js +0 -19
- package/dist/Chatbot/authenticate.d.ts +0 -3
- package/dist/Chatbot/authenticate.js +0 -16
- package/dist/Chatbot/index.d.ts +0 -8
- package/dist/Chatbot/index.js +0 -38
- package/dist/Chatbot/store/chat.d.ts +0 -10
- package/dist/Chatbot/store/chat.js +0 -18
- package/dist/Chatbot/store/messages.d.ts +0 -15
- package/dist/Chatbot/store/messages.js +0 -13
- package/dist/Chatbot/useHeadlessChat.d.ts +0 -27
- package/dist/Chatbot/useHeadlessChat.js +0 -240
- package/dist/assets/Chatbot/Bubble.css +0 -51
- package/dist/assets/Chatbot/ChatWindow.css +0 -213
|
@@ -1,85 +0,0 @@
|
|
|
1
|
-
import { jsxs, jsx } from "react/jsx-runtime";
|
|
2
|
-
import { motion } from "framer-motion";
|
|
3
|
-
const loadingContainerVariants = {
|
|
4
|
-
start: {
|
|
5
|
-
transition: {
|
|
6
|
-
staggerChildren: 0.2
|
|
7
|
-
// Delay between each dot's animation
|
|
8
|
-
}
|
|
9
|
-
},
|
|
10
|
-
end: {
|
|
11
|
-
transition: {
|
|
12
|
-
staggerChildren: 0.2
|
|
13
|
-
}
|
|
14
|
-
}
|
|
15
|
-
};
|
|
16
|
-
const loadingCircleVariants = {
|
|
17
|
-
start: {
|
|
18
|
-
y: "0%"
|
|
19
|
-
},
|
|
20
|
-
end: {
|
|
21
|
-
y: "100%"
|
|
22
|
-
// Move down by 100% of its height
|
|
23
|
-
}
|
|
24
|
-
};
|
|
25
|
-
const loadingTransition = {
|
|
26
|
-
duration: 0.6,
|
|
27
|
-
repeat: Infinity,
|
|
28
|
-
repeatType: "reverse",
|
|
29
|
-
// Reverse the animation direction
|
|
30
|
-
ease: "easeInOut"
|
|
31
|
-
};
|
|
32
|
-
const EllipsisLoader = () => {
|
|
33
|
-
const project = process.env.CCAI_PROJECT_ID;
|
|
34
|
-
const isAxos = project === "axos";
|
|
35
|
-
const endUserBg = isAxos ? "#14263d" : "#323339";
|
|
36
|
-
return /* @__PURE__ */ jsxs(
|
|
37
|
-
motion.svg,
|
|
38
|
-
{
|
|
39
|
-
width: "30",
|
|
40
|
-
height: "15",
|
|
41
|
-
viewBox: "0 0 100 50",
|
|
42
|
-
variants: loadingContainerVariants,
|
|
43
|
-
initial: "start",
|
|
44
|
-
animate: "end",
|
|
45
|
-
children: [
|
|
46
|
-
/* @__PURE__ */ jsx(
|
|
47
|
-
motion.circle,
|
|
48
|
-
{
|
|
49
|
-
cx: "20",
|
|
50
|
-
cy: "15",
|
|
51
|
-
r: "8",
|
|
52
|
-
fill: endUserBg,
|
|
53
|
-
variants: loadingCircleVariants,
|
|
54
|
-
transition: loadingTransition
|
|
55
|
-
}
|
|
56
|
-
),
|
|
57
|
-
/* @__PURE__ */ jsx(
|
|
58
|
-
motion.circle,
|
|
59
|
-
{
|
|
60
|
-
cx: "50",
|
|
61
|
-
cy: "15",
|
|
62
|
-
r: "8",
|
|
63
|
-
fill: endUserBg,
|
|
64
|
-
variants: loadingCircleVariants,
|
|
65
|
-
transition: loadingTransition
|
|
66
|
-
}
|
|
67
|
-
),
|
|
68
|
-
/* @__PURE__ */ jsx(
|
|
69
|
-
motion.circle,
|
|
70
|
-
{
|
|
71
|
-
cx: "80",
|
|
72
|
-
cy: "15",
|
|
73
|
-
r: "8",
|
|
74
|
-
fill: endUserBg,
|
|
75
|
-
variants: loadingCircleVariants,
|
|
76
|
-
transition: loadingTransition
|
|
77
|
-
}
|
|
78
|
-
)
|
|
79
|
-
]
|
|
80
|
-
}
|
|
81
|
-
);
|
|
82
|
-
};
|
|
83
|
-
export {
|
|
84
|
-
EllipsisLoader as default
|
|
85
|
-
};
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import { jsxs, jsx } from "react/jsx-runtime";
|
|
2
|
-
const EllipsisIcon = ({ size = 24, color = "currentColor" }) => /* @__PURE__ */ jsxs(
|
|
3
|
-
"svg",
|
|
4
|
-
{
|
|
5
|
-
width: size,
|
|
6
|
-
height: size,
|
|
7
|
-
viewBox: "0 0 24 24",
|
|
8
|
-
fill: "none",
|
|
9
|
-
"aria-hidden": "true",
|
|
10
|
-
children: [
|
|
11
|
-
/* @__PURE__ */ jsx("circle", { cx: "5", cy: "12", r: "2", fill: color }),
|
|
12
|
-
/* @__PURE__ */ jsx("circle", { cx: "12", cy: "12", r: "2", fill: color }),
|
|
13
|
-
/* @__PURE__ */ jsx("circle", { cx: "19", cy: "12", r: "2", fill: color })
|
|
14
|
-
]
|
|
15
|
-
}
|
|
16
|
-
);
|
|
17
|
-
export {
|
|
18
|
-
EllipsisIcon
|
|
19
|
-
};
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
const AUTH_URL = process.env.AUTH_CHAT_URL || "http://localhost:3000/api/auth/token";
|
|
2
|
-
const authenticate = async () => {
|
|
3
|
-
const res = await fetch(AUTH_URL, {
|
|
4
|
-
method: "GET",
|
|
5
|
-
headers: {
|
|
6
|
-
"Content-Type": "application/json"
|
|
7
|
-
}
|
|
8
|
-
});
|
|
9
|
-
const data = await res.json();
|
|
10
|
-
return {
|
|
11
|
-
token: data.token
|
|
12
|
-
};
|
|
13
|
-
};
|
|
14
|
-
export {
|
|
15
|
-
authenticate
|
|
16
|
-
};
|
package/dist/Chatbot/index.d.ts
DELETED
package/dist/Chatbot/index.js
DELETED
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
"use client";
|
|
2
|
-
import { Bubble } from "./Bubble.js";
|
|
3
|
-
import { bubbleWrapper, svgFill } from "./Bubble.css.js";
|
|
4
|
-
import { Chatbot } from "./Chatbot.js";
|
|
5
|
-
import { chatbotAXB, chatbotUFB } from "./Chatbot.css.js";
|
|
6
|
-
import { ChatWindow } from "./ChatWindow.js";
|
|
7
|
-
import { arrowFill, button_reset, chatFinishDialog, chatNetworkStatus, chat_title, chatbotMenu, chatbotMenuItem, endChatButtonStyle, inline_button, inline_button_wrapper, inputStyle, messageStyle, messagesContainerStyle, notificationStyle, sendButtonStyle, windowBarStyle, windowOpenStyle, windowStyle } from "./ChatWindow.css.js";
|
|
8
|
-
import { useOpenChat } from "./store/chat.js";
|
|
9
|
-
import { useMessages } from "./store/messages.js";
|
|
10
|
-
export {
|
|
11
|
-
Bubble,
|
|
12
|
-
ChatWindow,
|
|
13
|
-
Chatbot,
|
|
14
|
-
arrowFill,
|
|
15
|
-
bubbleWrapper,
|
|
16
|
-
button_reset,
|
|
17
|
-
chatFinishDialog,
|
|
18
|
-
chatNetworkStatus,
|
|
19
|
-
chat_title,
|
|
20
|
-
chatbotAXB,
|
|
21
|
-
chatbotMenu,
|
|
22
|
-
chatbotMenuItem,
|
|
23
|
-
chatbotUFB,
|
|
24
|
-
endChatButtonStyle,
|
|
25
|
-
inline_button,
|
|
26
|
-
inline_button_wrapper,
|
|
27
|
-
inputStyle,
|
|
28
|
-
messageStyle,
|
|
29
|
-
messagesContainerStyle,
|
|
30
|
-
notificationStyle,
|
|
31
|
-
sendButtonStyle,
|
|
32
|
-
svgFill,
|
|
33
|
-
useMessages,
|
|
34
|
-
useOpenChat,
|
|
35
|
-
windowBarStyle,
|
|
36
|
-
windowOpenStyle,
|
|
37
|
-
windowStyle
|
|
38
|
-
};
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
interface OpenChatState {
|
|
2
|
-
isOpen: boolean;
|
|
3
|
-
hasOpenedOnce: boolean;
|
|
4
|
-
toggle: () => void;
|
|
5
|
-
open: () => void;
|
|
6
|
-
close: () => void;
|
|
7
|
-
reset: () => void;
|
|
8
|
-
}
|
|
9
|
-
export declare const useOpenChat: import('zustand').UseBoundStore<import('zustand').StoreApi<OpenChatState>>;
|
|
10
|
-
export {};
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import { create } from "zustand";
|
|
2
|
-
const useOpenChat = create((set, get) => ({
|
|
3
|
-
isOpen: false,
|
|
4
|
-
hasOpenedOnce: false,
|
|
5
|
-
toggle: () => set((state) => ({ isOpen: !state.isOpen, hasOpenedOnce: true })),
|
|
6
|
-
open: () => {
|
|
7
|
-
const alreadyOpened = get().hasOpenedOnce;
|
|
8
|
-
set({
|
|
9
|
-
isOpen: true,
|
|
10
|
-
hasOpenedOnce: alreadyOpened ? true : true
|
|
11
|
-
});
|
|
12
|
-
},
|
|
13
|
-
close: () => set({ isOpen: false }),
|
|
14
|
-
reset: () => set({ hasOpenedOnce: false, isOpen: false })
|
|
15
|
-
}));
|
|
16
|
-
export {
|
|
17
|
-
useOpenChat
|
|
18
|
-
};
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import { MessageResponse } from '@ujet/websdk-headless';
|
|
2
|
-
|
|
3
|
-
interface MessageStore {
|
|
4
|
-
messages: MessageResponse[];
|
|
5
|
-
addMessage: (message: MessageResponse) => void;
|
|
6
|
-
removeMessage: (id: string) => void;
|
|
7
|
-
addMessages: (newMessages: MessageResponse[]) => void;
|
|
8
|
-
clearMessages: () => void;
|
|
9
|
-
}
|
|
10
|
-
export interface Message {
|
|
11
|
-
id: string;
|
|
12
|
-
text: string;
|
|
13
|
-
}
|
|
14
|
-
export declare const useMessages: import('zustand').UseBoundStore<import('zustand').StoreApi<MessageStore>>;
|
|
15
|
-
export {};
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import { create } from "zustand";
|
|
2
|
-
const useMessages = create((set) => ({
|
|
3
|
-
messages: [],
|
|
4
|
-
addMessage: (message) => set((state) => ({ messages: [...state.messages, message] })),
|
|
5
|
-
removeMessage: (id) => set((state) => ({
|
|
6
|
-
messages: state.messages.filter((msg) => msg.id !== id)
|
|
7
|
-
})),
|
|
8
|
-
addMessages: (newMessages) => set((state) => ({ messages: [...state.messages, ...newMessages] })),
|
|
9
|
-
clearMessages: () => set({ messages: [] })
|
|
10
|
-
}));
|
|
11
|
-
export {
|
|
12
|
-
useMessages
|
|
13
|
-
};
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
import { TokenResponse } from '@ujet/websdk-headless';
|
|
2
|
-
|
|
3
|
-
interface UseHeadlessChatOptions {
|
|
4
|
-
companyId: string;
|
|
5
|
-
tenant: string;
|
|
6
|
-
host: string;
|
|
7
|
-
getToken: () => Promise<TokenResponse>;
|
|
8
|
-
channelId?: string;
|
|
9
|
-
projectId?: "axos" | "" | "ufb" | string;
|
|
10
|
-
debug?: boolean;
|
|
11
|
-
menuOption?: string;
|
|
12
|
-
}
|
|
13
|
-
export interface ChatMessage {
|
|
14
|
-
id: string;
|
|
15
|
-
body: string;
|
|
16
|
-
sender?: string;
|
|
17
|
-
timestamp?: string;
|
|
18
|
-
}
|
|
19
|
-
export declare function useHeadlessChat({ companyId, tenant, host, getToken, projectId, debug, menuOption, }: UseHeadlessChatOptions): {
|
|
20
|
-
status: "error" | "idle" | "connected" | "connecting" | "finished";
|
|
21
|
-
sendMessage: (body: string) => Promise<void>;
|
|
22
|
-
showReconnect: boolean;
|
|
23
|
-
setShowReconnect: import('react').Dispatch<import('react').SetStateAction<boolean>>;
|
|
24
|
-
endChat: () => Promise<void>;
|
|
25
|
-
virtualAgent: any;
|
|
26
|
-
};
|
|
27
|
-
export {};
|
|
@@ -1,240 +0,0 @@
|
|
|
1
|
-
"use client";
|
|
2
|
-
import { useState, useRef, useCallback, useEffect } from "react";
|
|
3
|
-
import { useLocation } from "react-use";
|
|
4
|
-
import { useMessages } from "./store/messages.js";
|
|
5
|
-
const brandMap = /* @__PURE__ */ new Map([
|
|
6
|
-
["axos", 1],
|
|
7
|
-
["", 2],
|
|
8
|
-
["ufb", 3]
|
|
9
|
-
]);
|
|
10
|
-
function useHeadlessChat({
|
|
11
|
-
companyId,
|
|
12
|
-
tenant,
|
|
13
|
-
host,
|
|
14
|
-
getToken,
|
|
15
|
-
projectId = "axos",
|
|
16
|
-
debug = false,
|
|
17
|
-
menuOption = "Support Virtual Agent"
|
|
18
|
-
}) {
|
|
19
|
-
const { hostname } = useLocation();
|
|
20
|
-
const addMessage = useMessages((state) => state.addMessage);
|
|
21
|
-
const addMessages = useMessages((state) => state.addMessages);
|
|
22
|
-
const clearMessages = useMessages((state) => state.clearMessages);
|
|
23
|
-
const [showReconnect, setShowReconnect] = useState(false);
|
|
24
|
-
const [status, setStatus] = useState("idle");
|
|
25
|
-
const chatRef = useRef(null);
|
|
26
|
-
const clientRef = useRef(null);
|
|
27
|
-
const isMountedRef = useRef(true);
|
|
28
|
-
const hasLoadedBefore = useRef(true);
|
|
29
|
-
const menuRef = useRef({ menus: [] });
|
|
30
|
-
const sendMessage = useCallback(async (body) => {
|
|
31
|
-
if (chatRef.current) {
|
|
32
|
-
await clientRef.current?.sendTextMessage(body);
|
|
33
|
-
}
|
|
34
|
-
}, []);
|
|
35
|
-
const endChat = useCallback(async () => {
|
|
36
|
-
if (chatRef.current) {
|
|
37
|
-
await clientRef.current?.finishChat();
|
|
38
|
-
clearMessages();
|
|
39
|
-
clientRef.current?.createChat(
|
|
40
|
-
menuRef.current.menus.find((menu) => menu.name === menuOption)?.id,
|
|
41
|
-
{
|
|
42
|
-
custom_data: {
|
|
43
|
-
unsigned: {
|
|
44
|
-
facingBrandId: {
|
|
45
|
-
label: "facingBrandId",
|
|
46
|
-
value: `${brandMap.get(projectId) || 1}`
|
|
47
|
-
},
|
|
48
|
-
channel: {
|
|
49
|
-
label: "channel",
|
|
50
|
-
value: "in_web"
|
|
51
|
-
},
|
|
52
|
-
user_auth: {
|
|
53
|
-
label: "user_auth",
|
|
54
|
-
value: "false"
|
|
55
|
-
},
|
|
56
|
-
env: {
|
|
57
|
-
label: "env",
|
|
58
|
-
value: hostname?.includes("www") ? "prod" : hostname?.split(".")[1] ? hostname?.split(".")[1] : ""
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
);
|
|
64
|
-
}
|
|
65
|
-
}, [clearMessages, hostname, menuOption, projectId]);
|
|
66
|
-
useEffect(() => {
|
|
67
|
-
let messageHandler;
|
|
68
|
-
let chatReadyHandler;
|
|
69
|
-
let chatEndedHandler;
|
|
70
|
-
let chatConnectedHandler;
|
|
71
|
-
let chatDisconnectedHandler;
|
|
72
|
-
let memberLeftHandler;
|
|
73
|
-
let memberJoinedHandler;
|
|
74
|
-
let startTypingHandler;
|
|
75
|
-
let stopTypingHandler;
|
|
76
|
-
let chatTimeoutHandler;
|
|
77
|
-
async function init() {
|
|
78
|
-
setStatus("connecting");
|
|
79
|
-
const { Client, Logger, consoleLoggerHandler } = await import("@ujet/websdk-headless");
|
|
80
|
-
if (debug) Logger.addHandler(consoleLoggerHandler);
|
|
81
|
-
try {
|
|
82
|
-
clientRef.current = new Client({
|
|
83
|
-
companyId,
|
|
84
|
-
tenant,
|
|
85
|
-
host,
|
|
86
|
-
authenticate: getToken
|
|
87
|
-
});
|
|
88
|
-
if (debug) console.log("clientRef:", clientRef.current);
|
|
89
|
-
} catch (e) {
|
|
90
|
-
console.error("Error creating client:", e);
|
|
91
|
-
if (isMountedRef.current) setStatus("error");
|
|
92
|
-
return;
|
|
93
|
-
}
|
|
94
|
-
menuRef.current = await clientRef.current?.getMenus();
|
|
95
|
-
if (debug) console.log("channelId:", menuRef.current);
|
|
96
|
-
if (debug)
|
|
97
|
-
console.log(
|
|
98
|
-
"channelId:",
|
|
99
|
-
menuRef.current?.menus.find((menu) => menu.name === menuOption)?.id
|
|
100
|
-
);
|
|
101
|
-
const custom_data = {
|
|
102
|
-
unsigned: {
|
|
103
|
-
facingBrandId: {
|
|
104
|
-
label: "facingBrandId",
|
|
105
|
-
value: `${brandMap.get(projectId) || 1}`
|
|
106
|
-
},
|
|
107
|
-
channel: {
|
|
108
|
-
label: "channel",
|
|
109
|
-
value: "in_web"
|
|
110
|
-
},
|
|
111
|
-
user_auth: {
|
|
112
|
-
label: "user_auth",
|
|
113
|
-
value: "false"
|
|
114
|
-
},
|
|
115
|
-
env: {
|
|
116
|
-
label: "env",
|
|
117
|
-
value: hostname?.includes("www") ? "prod" : hostname?.split(".")[1] ? hostname?.split(".")[1] : ""
|
|
118
|
-
}
|
|
119
|
-
}
|
|
120
|
-
};
|
|
121
|
-
try {
|
|
122
|
-
chatRef.current = await clientRef.current?.loadOngoingChat();
|
|
123
|
-
if (chatRef.current != null) {
|
|
124
|
-
chatRef.current = await clientRef.current?.resumeChat(
|
|
125
|
-
chatRef.current?.state?.id
|
|
126
|
-
);
|
|
127
|
-
if (debug) console.log("Resumed chatRef:", chatRef.current);
|
|
128
|
-
} else {
|
|
129
|
-
chatRef.current = await clientRef.current?.createChat(
|
|
130
|
-
menuRef.current.menus.find((menu) => menu.name === menuOption)?.id,
|
|
131
|
-
{
|
|
132
|
-
custom_data
|
|
133
|
-
}
|
|
134
|
-
);
|
|
135
|
-
if (debug) console.log("chatRef:", chatRef.current);
|
|
136
|
-
}
|
|
137
|
-
} catch (error) {
|
|
138
|
-
console.error("Error creating chat:", error);
|
|
139
|
-
}
|
|
140
|
-
messageHandler = (msg) => {
|
|
141
|
-
if (debug) console.log("Received message:", msg);
|
|
142
|
-
addMessage(msg);
|
|
143
|
-
};
|
|
144
|
-
chatReadyHandler = () => {
|
|
145
|
-
console.log("Chat is ready");
|
|
146
|
-
};
|
|
147
|
-
chatEndedHandler = () => {
|
|
148
|
-
console.log("Chat has ended");
|
|
149
|
-
setStatus("finished");
|
|
150
|
-
};
|
|
151
|
-
chatConnectedHandler = async () => {
|
|
152
|
-
console.log("Chat connected");
|
|
153
|
-
setStatus("connected");
|
|
154
|
-
try {
|
|
155
|
-
const messagesFetched = await chatRef.current?.fetchMessages();
|
|
156
|
-
if (debug) console.log("[messages]:", messagesFetched);
|
|
157
|
-
addMessages(messagesFetched || []);
|
|
158
|
-
} catch (error) {
|
|
159
|
-
console.error("Error fetching messages:", error);
|
|
160
|
-
}
|
|
161
|
-
};
|
|
162
|
-
startTypingHandler = (identity) => {
|
|
163
|
-
console.log("start typing: ", identity);
|
|
164
|
-
};
|
|
165
|
-
stopTypingHandler = (identity) => {
|
|
166
|
-
console.log("stop typing: ", identity);
|
|
167
|
-
};
|
|
168
|
-
memberLeftHandler = (identity) => {
|
|
169
|
-
console.log("Member has left the chat: ", identity);
|
|
170
|
-
};
|
|
171
|
-
memberJoinedHandler = (identity) => {
|
|
172
|
-
console.log("Member has joined the chat: ", identity);
|
|
173
|
-
};
|
|
174
|
-
chatDisconnectedHandler = () => {
|
|
175
|
-
console.log("Chat disconnected");
|
|
176
|
-
setStatus("idle");
|
|
177
|
-
};
|
|
178
|
-
chatTimeoutHandler = () => {
|
|
179
|
-
console.log("Chat timeout");
|
|
180
|
-
};
|
|
181
|
-
clientRef.current?.on("ready", chatReadyHandler);
|
|
182
|
-
clientRef.current?.on("chat.connected", chatConnectedHandler);
|
|
183
|
-
clientRef.current?.on("chat.message", messageHandler);
|
|
184
|
-
clientRef.current?.on("chat.memberLeft", memberLeftHandler);
|
|
185
|
-
clientRef.current?.on("chat.memberJoined", memberJoinedHandler);
|
|
186
|
-
clientRef.current?.on("chat.typingStarted", startTypingHandler);
|
|
187
|
-
clientRef.current?.on("chat.typingEnded", stopTypingHandler);
|
|
188
|
-
clientRef.current?.on("chat.disconnected", chatDisconnectedHandler);
|
|
189
|
-
clientRef.current?.on("chat.ended", chatEndedHandler);
|
|
190
|
-
clientRef.current?.on("chat.timeout", chatTimeoutHandler);
|
|
191
|
-
}
|
|
192
|
-
if (hasLoadedBefore.current) {
|
|
193
|
-
if (debug) console.log("Initializing chat...");
|
|
194
|
-
init();
|
|
195
|
-
hasLoadedBefore.current = false;
|
|
196
|
-
}
|
|
197
|
-
return () => {
|
|
198
|
-
isMountedRef.current = false;
|
|
199
|
-
if (debug)
|
|
200
|
-
console.log(
|
|
201
|
-
"Component unmounted. Cancelling pending async operations."
|
|
202
|
-
);
|
|
203
|
-
chatRef.current = null;
|
|
204
|
-
clientRef.current?.off("ready", chatReadyHandler);
|
|
205
|
-
clientRef.current?.off("chat.message", messageHandler);
|
|
206
|
-
clientRef.current?.off("chat.connected", chatConnectedHandler);
|
|
207
|
-
clientRef.current?.off("chat.ended", chatEndedHandler);
|
|
208
|
-
clientRef.current?.off("chat.memberLeft", memberLeftHandler);
|
|
209
|
-
clientRef.current?.off("chat.memberJoined", memberJoinedHandler);
|
|
210
|
-
clientRef.current?.off("chat.typingStarted", startTypingHandler);
|
|
211
|
-
clientRef.current?.off("chat.typingEnded", stopTypingHandler);
|
|
212
|
-
clientRef.current?.off("chat.disconnected", chatDisconnectedHandler);
|
|
213
|
-
clientRef.current?.off("chat.timeout", chatTimeoutHandler);
|
|
214
|
-
clientRef.current?.destroyChat();
|
|
215
|
-
clientRef.current = null;
|
|
216
|
-
};
|
|
217
|
-
}, [
|
|
218
|
-
companyId,
|
|
219
|
-
tenant,
|
|
220
|
-
host,
|
|
221
|
-
getToken,
|
|
222
|
-
addMessage,
|
|
223
|
-
addMessages,
|
|
224
|
-
debug,
|
|
225
|
-
projectId,
|
|
226
|
-
menuOption,
|
|
227
|
-
hostname
|
|
228
|
-
]);
|
|
229
|
-
return {
|
|
230
|
-
status,
|
|
231
|
-
sendMessage,
|
|
232
|
-
showReconnect,
|
|
233
|
-
setShowReconnect,
|
|
234
|
-
endChat,
|
|
235
|
-
virtualAgent: chatRef.current?.state.virtual_agent
|
|
236
|
-
};
|
|
237
|
-
}
|
|
238
|
-
export {
|
|
239
|
-
useHeadlessChat
|
|
240
|
-
};
|
|
@@ -1,51 +0,0 @@
|
|
|
1
|
-
@keyframes fade-in-bounce {
|
|
2
|
-
0% {
|
|
3
|
-
transform: translate3d(100px,100px,0) scale(0.3);
|
|
4
|
-
opacity: 0;
|
|
5
|
-
}
|
|
6
|
-
50% {
|
|
7
|
-
transform: translate3d(-10px,-10px,0) scale(1.1);
|
|
8
|
-
opacity: 1;
|
|
9
|
-
}
|
|
10
|
-
100% {
|
|
11
|
-
transform: translate3d(0,0,0) scale(1);
|
|
12
|
-
opacity: 1;
|
|
13
|
-
}
|
|
14
|
-
}
|
|
15
|
-
@keyframes pulse {
|
|
16
|
-
0%,100% {
|
|
17
|
-
box-shadow: 0 0 0 0 rgba(0,123,255,0.4);
|
|
18
|
-
}
|
|
19
|
-
50% {
|
|
20
|
-
box-shadow: 0 0 0 10px rgba(0,123,255,0);
|
|
21
|
-
}
|
|
22
|
-
}
|
|
23
|
-
._7u9pv30 {
|
|
24
|
-
align-items: center;
|
|
25
|
-
animation: fade-in-bounce 2s cubic-bezier(0.65, 0.25, 0.14, 0.93) forwards, pulse 4.5s 0.5s;
|
|
26
|
-
background-color: #14263d;
|
|
27
|
-
border-radius: 50%;
|
|
28
|
-
bottom: 16px;
|
|
29
|
-
cursor: pointer;
|
|
30
|
-
display: grid;
|
|
31
|
-
font-family: var(--main-font-family);
|
|
32
|
-
height: 68px;
|
|
33
|
-
line-height: 1;
|
|
34
|
-
outline: 2px solid #98DDFF;
|
|
35
|
-
place-items: center;
|
|
36
|
-
position: fixed;
|
|
37
|
-
right: 16px;
|
|
38
|
-
width: 68px;
|
|
39
|
-
z-index: 9999;
|
|
40
|
-
}
|
|
41
|
-
._1hpv6vm1 ._7u9pv30 {
|
|
42
|
-
animation: fade-in-bounce 2s cubic-bezier(0.65, 0.25, 0.14, 0.93) forwards;
|
|
43
|
-
background-color: #60707A;
|
|
44
|
-
outline: none;
|
|
45
|
-
}
|
|
46
|
-
._7u9pv31 {
|
|
47
|
-
fill: #98DDFF;
|
|
48
|
-
}
|
|
49
|
-
._1hpv6vm1 ._7u9pv31 {
|
|
50
|
-
fill: #FFFFFF;
|
|
51
|
-
}
|