@axos-web-dev/shared-components 1.0.77-patch.4 → 1.0.77-patch.40
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 +10 -3
- package/dist/Auth/ErrorAlert.js +12 -5
- package/dist/Button/Button.js +12 -5
- package/dist/Calculators/ApyCalculator/index.js +11 -5
- package/dist/Calculators/AxosOneCalculator/BalanceAPYCalculator.css.d.ts +1 -0
- package/dist/Calculators/AxosOneCalculator/BalanceAPYCalculator.css.js +3 -1
- package/dist/Calculators/AxosOneCalculator/index.d.ts +2 -0
- package/dist/Calculators/AxosOneCalculator/index.js +38 -20
- package/dist/Calculators/Calculator.d.ts +2 -0
- package/dist/Calculators/Calculator.js +29 -8
- package/dist/Calculators/MarineLoanMonthlyPaymentCalculator/index.d.ts +9 -0
- package/dist/Calculators/MarineLoanMonthlyPaymentCalculator/index.js +219 -0
- package/dist/Calculators/MaxLoanCalculator/index.js +22 -5
- package/dist/Calculators/MonthlyPaymentCalculator/MonthlyPaymentCalculator.css.d.ts +1 -0
- package/dist/Calculators/MonthlyPaymentCalculator/MonthlyPaymentCalculator.css.js +2 -0
- package/dist/Calculators/MonthlyPaymentCalculator/index.js +15 -5
- package/dist/Calculators/SummitApyCalculator/index.js +15 -6
- package/dist/Calculators/index.d.ts +2 -1
- package/dist/Calculators/index.js +3 -1
- package/dist/Carousel/index.js +20 -13
- package/dist/Chatbot/Bubble.css.d.ts +2 -0
- package/dist/Chatbot/Bubble.css.js +7 -0
- package/dist/Chatbot/Bubble.d.ts +5 -0
- package/dist/Chatbot/Bubble.js +103 -0
- package/dist/Chatbot/Chat.d.ts +1 -0
- package/dist/Chatbot/Chat.js +165 -0
- package/dist/Chatbot/ChatWindow.css.d.ts +18 -0
- package/dist/Chatbot/ChatWindow.css.js +39 -0
- package/dist/Chatbot/ChatWindow.d.ts +26 -0
- package/dist/Chatbot/ChatWindow.js +446 -0
- package/dist/Chatbot/Chatbot.css.d.ts +2 -0
- package/dist/Chatbot/Chatbot.css.js +7 -0
- package/dist/Chatbot/Chatbot.css.ts.vanilla.css.js +1 -0
- package/dist/Chatbot/Chatbot.d.ts +10 -0
- package/dist/Chatbot/Chatbot.js +222 -0
- package/dist/Chatbot/EllipsisAnimation.d.ts +2 -0
- package/dist/Chatbot/EllipsisAnimation.js +85 -0
- package/dist/Chatbot/EllipsisIcon.d.ts +4 -0
- package/dist/Chatbot/EllipsisIcon.js +19 -0
- package/dist/Chatbot/authenticate.d.ts +3 -0
- package/dist/Chatbot/authenticate.js +16 -0
- package/dist/Chatbot/index.d.ts +8 -0
- package/dist/Chatbot/index.js +38 -0
- package/dist/Chatbot/store/chat.d.ts +10 -0
- package/dist/Chatbot/store/chat.js +18 -0
- package/dist/Chatbot/store/messages.d.ts +15 -0
- package/dist/Chatbot/store/messages.js +13 -0
- package/dist/Chatbot/useHeadlessChat.d.ts +27 -0
- package/dist/Chatbot/useHeadlessChat.js +240 -0
- package/dist/Chevron/index.js +12 -5
- package/dist/Comparison/Comparison.js +16 -9
- package/dist/Comparison/ComparisonSet.js +33 -24
- package/dist/ExecutiveBio/ExecutiveBio.js +12 -5
- package/dist/FaqAccordion/index.js +12 -5
- package/dist/FooterSiteMap/AxosBank/FooterSiteMap.js +30 -9
- package/dist/Forms/ApplicationStart.d.ts +1 -1
- package/dist/Forms/ApplicationStart.js +111 -89
- package/dist/Forms/ApplyNow.d.ts +2 -2
- package/dist/Forms/ApplyNow.js +180 -148
- package/dist/Forms/ClearingForm.d.ts +1 -1
- package/dist/Forms/ClearingForm.js +184 -162
- package/dist/Forms/CommercialDeposits.d.ts +1 -1
- package/dist/Forms/CommercialDeposits.js +201 -179
- package/dist/Forms/CommercialDepositsNoLendingOption.d.ts +16 -0
- package/dist/Forms/CommercialDepositsNoLendingOption.js +330 -0
- package/dist/Forms/CommercialLending.d.ts +1 -1
- package/dist/Forms/CommercialLending.js +278 -256
- package/dist/Forms/CommercialPremiumFinance.d.ts +1 -1
- package/dist/Forms/CommercialPremiumFinance.js +128 -106
- package/dist/Forms/ContactCompany.d.ts +1 -1
- package/dist/Forms/ContactCompany.js +113 -91
- package/dist/Forms/ContactCompanyTitle.d.ts +1 -1
- package/dist/Forms/ContactCompanyTitle.js +127 -105
- package/dist/Forms/ContactUs.d.ts +1 -1
- package/dist/Forms/ContactUs.js +99 -77
- package/dist/Forms/ContactUsAAS.d.ts +1 -1
- package/dist/Forms/ContactUsAAS.js +180 -158
- package/dist/Forms/ContactUsBusiness.d.ts +2 -2
- package/dist/Forms/ContactUsBusiness.js +146 -118
- package/dist/Forms/ContactUsBusinessNameEmail.d.ts +1 -1
- package/dist/Forms/ContactUsBusinessNameEmail.js +114 -86
- package/dist/Forms/ContactUsLVF.d.ts +7 -1
- package/dist/Forms/ContactUsLVF.js +133 -105
- package/dist/Forms/ContactUsNMLSId.d.ts +1 -1
- package/dist/Forms/ContactUsNMLSId.js +128 -100
- package/dist/Forms/CpraRequest.d.ts +1 -1
- package/dist/Forms/CpraRequest.js +641 -619
- package/dist/Forms/CraPublicFile.d.ts +1 -1
- package/dist/Forms/CraPublicFile.js +120 -92
- package/dist/Forms/DealerServices.d.ts +1 -1
- package/dist/Forms/DealerServices.js +225 -203
- package/dist/Forms/EmailOnly.d.ts +1 -1
- package/dist/Forms/EmailOnly.js +67 -41
- package/dist/Forms/EmailUs.d.ts +1 -1
- package/dist/Forms/EmailUs.js +75 -53
- package/dist/Forms/FormProps.d.ts +3 -0
- package/dist/Forms/Forms.css.d.ts +18 -0
- package/dist/Forms/Forms.css.js +44 -38
- package/dist/Forms/HoneyPot/HoneyPot.css.d.ts +1 -0
- package/dist/Forms/HoneyPot/HoneyPot.css.js +5 -0
- package/dist/Forms/HoneyPot/index.d.ts +23 -0
- package/dist/Forms/HoneyPot/index.js +69 -0
- package/dist/Forms/MortgageRate/MortgageRateForm.js +12 -5
- package/dist/Forms/MortgageRate/MortgageRateWatch.js +12 -5
- package/dist/Forms/MortgageWarehouseLending.d.ts +11 -0
- package/dist/Forms/MortgageWarehouseLending.js +343 -0
- package/dist/Forms/QuickPricer/QuickPricerForm.d.ts +1 -1
- package/dist/Forms/QuickPricer/QuickPricerForm.js +624 -609
- package/dist/Forms/SalesforceFieldsForm.d.ts +5 -0
- package/dist/Forms/SalesforceFieldsForm.js +11 -1
- package/dist/Forms/ScheduleCall.d.ts +1 -1
- package/dist/Forms/ScheduleCall.js +156 -134
- package/dist/Forms/ScheduleCallPremier.d.ts +1 -1
- package/dist/Forms/ScheduleCallPremier.js +178 -156
- package/dist/Forms/SuccesForm.js +16 -9
- package/dist/Forms/VendorQuestionnaire.d.ts +1 -1
- package/dist/Forms/VendorQuestionnaire.js +817 -795
- package/dist/Forms/WcplSurvey.d.ts +1 -1
- package/dist/Forms/WcplSurvey.js +112 -90
- package/dist/Forms/applynow-utils.d.ts +1 -0
- package/dist/Forms/applynow-utils.js +48 -0
- package/dist/Forms/index.d.ts +4 -0
- package/dist/Forms/index.js +14 -2
- package/dist/HeroBanner/HeroBanner.css.d.ts +2 -0
- package/dist/HeroBanner/HeroBanner.css.js +4 -0
- package/dist/HeroBanner/HeroBanner.d.ts +1 -1
- package/dist/HeroBanner/HeroBanner.interface.d.ts +3 -0
- package/dist/HeroBanner/HeroBanner.js +90 -3
- package/dist/HeroBanner/index.js +3 -1
- package/dist/Hyperlink/index.js +12 -5
- package/dist/IconBillboard/IconBillboard.css.d.ts +1 -0
- package/dist/IconBillboard/IconBillboard.css.js +2 -0
- package/dist/IconBillboard/IconBillboard.d.ts +1 -2
- package/dist/IconBillboard/IconBillboard.js +30 -85
- package/dist/IconBillboard/index.js +3 -3
- package/dist/IconBillboard/sections/CallToActionSection.d.ts +12 -0
- package/dist/IconBillboard/sections/CallToActionSection.js +102 -0
- package/dist/IconBillboard/sections/HeaderSection.d.ts +11 -0
- package/dist/IconBillboard/sections/HeaderSection.js +23 -0
- package/dist/IconBillboard/sections/IconSection.d.ts +7 -0
- package/dist/IconBillboard/sections/IconSection.js +18 -0
- package/dist/IconBillboard/sections/ItemsSection.d.ts +11 -0
- package/dist/IconBillboard/sections/ItemsSection.js +11 -0
- package/dist/IconBillboard/sections/LayoutSection.d.ts +8 -0
- package/dist/IconBillboard/sections/LayoutSection.js +6 -0
- package/dist/ImageBillboard/ExitIntentModal/useExitIntentModal.js +6 -1
- package/dist/ImageBillboard/ImageBillboard.interface.d.ts +7 -0
- package/dist/ImageBillboard/ImageBillboardSet.d.ts +1 -1
- package/dist/ImageBillboard/ImageBillboardSet.js +20 -4
- package/dist/ImageLink/ImageLink.js +12 -5
- package/dist/ImageLink/ImageLinkSet.js +15 -8
- package/dist/ImageLink/index.js +12 -5
- package/dist/Insight/Featured/CategorySelector.js +13 -6
- package/dist/Insight/Featured/Featured.js +20 -13
- package/dist/Insight/Featured/Header.js +19 -12
- package/dist/LandingPageHeader/LandingPageHeader.css.d.ts +2 -0
- package/dist/LandingPageHeader/LandingPageHeader.css.js +6 -2
- package/dist/LandingPageHeader/LandingPageHeader.js +18 -9
- package/dist/LandingPageHeader/index.js +3 -1
- package/dist/Modal/Modal.js +12 -5
- package/dist/NavigationMenu/AxosALTS/NavData.js +12 -5
- package/dist/NavigationMenu/AxosALTS/index.js +12 -5
- package/dist/NavigationMenu/AxosAdvisor/SubNavBar.js +3 -10
- package/dist/NavigationMenu/AxosAdvisor/index.js +3 -11
- package/dist/NavigationMenu/AxosBank/MobileMenu/MobileNavData.d.ts +3 -4
- package/dist/NavigationMenu/AxosBank/MobileMenu/MobileNavData.js +29 -13
- package/dist/NavigationMenu/AxosBank/NavData.js +12 -5
- package/dist/NavigationMenu/AxosBank/SubNavBar.js +67 -63
- package/dist/NavigationMenu/AxosBank/index.js +12 -5
- package/dist/NavigationMenu/LaVictoire/NavData.js +12 -5
- package/dist/NavigationMenu/LaVictoire/index.js +12 -5
- package/dist/SetContainer/SetContainer.js +12 -5
- package/dist/SocialMediaBar/iconsRepository.js +12 -5
- package/dist/StepItemSet/StepItemSet.css.d.ts +1 -0
- package/dist/StepItemSet/StepItemSet.css.js +9 -5
- package/dist/StepItemSet/StepItemSet.d.ts +6 -0
- package/dist/StepItemSet/StepItemSet.js +22 -3
- package/dist/StepItemSet/index.js +2 -1
- package/dist/Table/Table.d.ts +1 -1
- package/dist/VideoTile/VideoTile.interface.d.ts +4 -3
- package/dist/VideoTile/VideoTile.js +189 -28
- package/dist/VideoWrapper/index.js +13 -6
- package/dist/WalnutIframe/wrapper.module.js +3 -3
- package/dist/assets/Calculators/AxosOneCalculator/BalanceAPYCalculator.css +12 -0
- package/dist/assets/Calculators/MonthlyPaymentCalculator/MonthlyPaymentCalculator.css +3 -0
- package/dist/assets/Chatbot/Bubble.css +51 -0
- package/dist/assets/Chatbot/ChatWindow.css +213 -0
- package/dist/assets/Comparison/Comparison.css +3 -1
- package/dist/assets/Forms/Forms.css +135 -105
- package/dist/assets/Forms/HoneyPot/HoneyPot.css +8 -0
- package/dist/assets/HeroBanner/HeroBanner.css +12 -0
- package/dist/assets/IconBillboard/IconBillboard.css +21 -1
- package/dist/assets/ImageBillboard/ImageBillboard.css +26 -15
- package/dist/assets/LandingPageHeader/LandingPageHeader.css +36 -3
- package/dist/assets/StepItemSet/StepItemSet.css +27 -10
- package/dist/assets/TopicalNavItem/TopicalNavItem.css +2 -2
- package/dist/assets/WalnutIframe/wrapper.css.css +7 -8
- package/dist/icons/Logos/SPB.d.ts +4 -0
- package/dist/icons/Logos/SPB.js +132 -0
- package/dist/icons/index.d.ts +1 -0
- package/dist/icons/index.js +2 -0
- package/dist/main.d.ts +1 -0
- package/dist/main.js +79 -23
- package/dist/utils/allowedAxosDomains.js +4 -2
- package/package.json +3 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export type ChatbotProps = {
|
|
2
|
+
project?: "axos" | "ufb";
|
|
3
|
+
debug?: boolean;
|
|
4
|
+
};
|
|
5
|
+
export declare const Chatbot: ({ project, projectEnv, menuOption, debug, }: {
|
|
6
|
+
project?: "axos" | "ufb";
|
|
7
|
+
projectEnv?: "dev" | "qa" | "uat" | "stg" | "prod";
|
|
8
|
+
menuOption?: "Support Virtual Agent" | string;
|
|
9
|
+
debug?: boolean;
|
|
10
|
+
}) => import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,222 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsxs, jsx } from "react/jsx-runtime";
|
|
3
|
+
import { authenticate } from "./authenticate.js";
|
|
4
|
+
import { Bubble } from "./Bubble.js";
|
|
5
|
+
import { chatbotUFB, chatbotAXB } from "./Chatbot.css.js";
|
|
6
|
+
import { ChatWindow } from "./ChatWindow.js";
|
|
7
|
+
import { useOpenChat } from "./store/chat.js";
|
|
8
|
+
import { useMessages } from "./store/messages.js";
|
|
9
|
+
import { useRef, useState } from "react";
|
|
10
|
+
import { useMount, useUnmount } from "react-use";
|
|
11
|
+
const Chatbot = ({
|
|
12
|
+
project = "axos",
|
|
13
|
+
projectEnv = "dev",
|
|
14
|
+
menuOption = "Support Virtual Agent",
|
|
15
|
+
debug = false
|
|
16
|
+
}) => {
|
|
17
|
+
const { hasOpenedOnce, toggle, reset } = useOpenChat();
|
|
18
|
+
const { addMessage, addMessages, clearMessages, messages } = useMessages();
|
|
19
|
+
const clientRef = useRef(null);
|
|
20
|
+
const menuRef = useRef(null);
|
|
21
|
+
const isMountedRef = useRef(false);
|
|
22
|
+
const hasLoadedBefore = useRef(true);
|
|
23
|
+
const chatRef = useRef(null);
|
|
24
|
+
const agent_virtual = useRef(null);
|
|
25
|
+
const [status, setStatus] = useState("idle");
|
|
26
|
+
const [hasStarted, setHasStarted] = useState(false);
|
|
27
|
+
const brandMap = /* @__PURE__ */ new Map([
|
|
28
|
+
["axos", 1],
|
|
29
|
+
["ufb", 3]
|
|
30
|
+
]);
|
|
31
|
+
const custom_data = {
|
|
32
|
+
unsigned: {
|
|
33
|
+
facingBrandId: {
|
|
34
|
+
label: "facingBrandId",
|
|
35
|
+
value: `${brandMap.get(project) || 1}`
|
|
36
|
+
},
|
|
37
|
+
channel: {
|
|
38
|
+
label: "channel",
|
|
39
|
+
value: "in_web"
|
|
40
|
+
},
|
|
41
|
+
user_auth: {
|
|
42
|
+
label: "user_auth",
|
|
43
|
+
value: "false"
|
|
44
|
+
},
|
|
45
|
+
env: {
|
|
46
|
+
label: "env",
|
|
47
|
+
value: projectEnv === "dev" ? "uat" : projectEnv
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
};
|
|
51
|
+
const onReadyHandler = async () => {
|
|
52
|
+
console.log("Chat client is ready");
|
|
53
|
+
};
|
|
54
|
+
const onAuthenticatedHandler = async () => {
|
|
55
|
+
console.log("Chat client is authenticated");
|
|
56
|
+
};
|
|
57
|
+
const onChatOngoingHandler = async (chat) => {
|
|
58
|
+
console.log("Ongoing chat:", chat);
|
|
59
|
+
};
|
|
60
|
+
const onChatMessageHandler = async (message) => {
|
|
61
|
+
console.log("Received message:", message);
|
|
62
|
+
addMessage(message);
|
|
63
|
+
};
|
|
64
|
+
const onChatTypingStartedHandler = async (identity) => {
|
|
65
|
+
console.log("Typing started by:", identity);
|
|
66
|
+
};
|
|
67
|
+
const onChatDisconnectedHandler = async () => {
|
|
68
|
+
console.log("Chat disconnected");
|
|
69
|
+
setStatus("idle");
|
|
70
|
+
};
|
|
71
|
+
const onDismissedHandler = async () => {
|
|
72
|
+
console.log("Chat dismissed");
|
|
73
|
+
};
|
|
74
|
+
const onTimeoutHandler = async () => {
|
|
75
|
+
console.log("Chat timeout");
|
|
76
|
+
};
|
|
77
|
+
const onEndedHandler = async () => {
|
|
78
|
+
console.log("Chat ended");
|
|
79
|
+
setStatus("finished");
|
|
80
|
+
};
|
|
81
|
+
const onDestroyedHandler = async () => {
|
|
82
|
+
console.log("Chat destroyed");
|
|
83
|
+
};
|
|
84
|
+
const onChatMemberLeftHandler = async (identity) => {
|
|
85
|
+
console.log("Chat member left:", identity);
|
|
86
|
+
};
|
|
87
|
+
const onChatConnectedHandler = async () => {
|
|
88
|
+
setStatus("connected");
|
|
89
|
+
console.log("connected");
|
|
90
|
+
const messages2 = await clientRef.current?.fetchMessages();
|
|
91
|
+
if (messages2) {
|
|
92
|
+
addMessages(messages2);
|
|
93
|
+
}
|
|
94
|
+
};
|
|
95
|
+
const registerEventHandlers = () => {
|
|
96
|
+
clientRef.current?.on("ready", onReadyHandler);
|
|
97
|
+
clientRef.current?.on("authenticated", onAuthenticatedHandler);
|
|
98
|
+
clientRef.current?.on("chat.ongoing", onChatOngoingHandler);
|
|
99
|
+
clientRef.current?.on("chat.message", onChatMessageHandler);
|
|
100
|
+
clientRef.current?.on("chat.typingStarted", onChatTypingStartedHandler);
|
|
101
|
+
clientRef.current?.on("chat.disconnected", onChatDisconnectedHandler);
|
|
102
|
+
clientRef.current?.on("chat.dismissed", onDismissedHandler);
|
|
103
|
+
clientRef.current?.on("chat.timeout", onTimeoutHandler);
|
|
104
|
+
clientRef.current?.on("chat.ended", onEndedHandler);
|
|
105
|
+
clientRef.current?.on("chat.destroyed", onDestroyedHandler);
|
|
106
|
+
clientRef.current?.on("chat.memberLeft", onChatMemberLeftHandler);
|
|
107
|
+
clientRef?.current?.on("chat.connected", onChatConnectedHandler);
|
|
108
|
+
};
|
|
109
|
+
const deregisterEventHandlers = () => {
|
|
110
|
+
clientRef.current?.off("ready", onReadyHandler);
|
|
111
|
+
clientRef.current?.off("authenticated", onAuthenticatedHandler);
|
|
112
|
+
clientRef.current?.off("chat.ongoing", onDismissedHandler);
|
|
113
|
+
clientRef.current?.off("chat.message", onChatMessageHandler);
|
|
114
|
+
clientRef.current?.off("chat.typingStarted", onChatTypingStartedHandler);
|
|
115
|
+
clientRef.current?.off("chat.disconnected", onChatDisconnectedHandler);
|
|
116
|
+
clientRef.current?.off("chat.dismissed", onDismissedHandler);
|
|
117
|
+
clientRef.current?.off("chat.timeout", onTimeoutHandler);
|
|
118
|
+
clientRef.current?.off("chat.ended", onEndedHandler);
|
|
119
|
+
clientRef.current?.off("chat.destroyed", onDestroyedHandler);
|
|
120
|
+
clientRef.current?.off("chat.memberLeft", onChatMemberLeftHandler);
|
|
121
|
+
clientRef.current?.off("chat.connected", onChatConnectedHandler);
|
|
122
|
+
};
|
|
123
|
+
const createClient = async () => {
|
|
124
|
+
const { Client, Logger, consoleLoggerHandler } = await import("@ujet/websdk-headless");
|
|
125
|
+
if (projectEnv !== "prod" || debug) {
|
|
126
|
+
Logger.addHandler(consoleLoggerHandler);
|
|
127
|
+
}
|
|
128
|
+
if (clientRef.current) return;
|
|
129
|
+
const client = new Client({
|
|
130
|
+
companyId: process.env.CCAI_COMPANY_ID || "",
|
|
131
|
+
tenant: process.env.CCAI_TENANT_NAME || "",
|
|
132
|
+
host: process.env.CCAI_HOST || "",
|
|
133
|
+
// or your region
|
|
134
|
+
authenticate
|
|
135
|
+
});
|
|
136
|
+
isMountedRef.current = true;
|
|
137
|
+
clientRef.current = client;
|
|
138
|
+
menuRef.current = await client.getMenus();
|
|
139
|
+
console.log("menus:", menuRef.current);
|
|
140
|
+
registerEventHandlers();
|
|
141
|
+
return;
|
|
142
|
+
};
|
|
143
|
+
const startChat = async () => {
|
|
144
|
+
console.log("Starting chat");
|
|
145
|
+
const client = clientRef.current;
|
|
146
|
+
if (!client) return;
|
|
147
|
+
try {
|
|
148
|
+
const ongoingChat = await client.loadOngoingChat();
|
|
149
|
+
if (ongoingChat) {
|
|
150
|
+
console.log("Ongoing chat found:", ongoingChat);
|
|
151
|
+
console.log("Resuming chat:", ongoingChat.id);
|
|
152
|
+
chatRef.current = await client.resumeChat(ongoingChat.id);
|
|
153
|
+
agent_virtual.current = ongoingChat.agent;
|
|
154
|
+
return;
|
|
155
|
+
}
|
|
156
|
+
const foundMenu = menuRef.current.menus.find(
|
|
157
|
+
(menu) => menu.name === menuOption
|
|
158
|
+
);
|
|
159
|
+
const menuId = foundMenu && foundMenu.id;
|
|
160
|
+
console.log("Creating new chat with menu ID:", menuId);
|
|
161
|
+
const newChat = await client.createChat(menuId, { custom_data });
|
|
162
|
+
if (newChat !== null) {
|
|
163
|
+
chatRef.current = newChat;
|
|
164
|
+
console.log("Chat created id:", newChat.id);
|
|
165
|
+
}
|
|
166
|
+
} catch (err) {
|
|
167
|
+
console.error("Error creating chat:", err);
|
|
168
|
+
}
|
|
169
|
+
};
|
|
170
|
+
const handleClick = async () => {
|
|
171
|
+
toggle();
|
|
172
|
+
if (hasStarted) return;
|
|
173
|
+
if (!hasOpenedOnce) {
|
|
174
|
+
await startChat();
|
|
175
|
+
setHasStarted(true);
|
|
176
|
+
}
|
|
177
|
+
};
|
|
178
|
+
const onSendMessage = (msg) => {
|
|
179
|
+
console.log("Sending message:", msg);
|
|
180
|
+
clientRef.current?.sendTextMessage(msg);
|
|
181
|
+
};
|
|
182
|
+
const onEndChat = async () => {
|
|
183
|
+
console.log("Ending chat");
|
|
184
|
+
if (chatRef.current) {
|
|
185
|
+
await clientRef.current?.finishChat();
|
|
186
|
+
await chatRef.current.destroy();
|
|
187
|
+
clearMessages();
|
|
188
|
+
chatRef.current = null;
|
|
189
|
+
console.log("Chat ended");
|
|
190
|
+
setHasStarted(false);
|
|
191
|
+
reset();
|
|
192
|
+
}
|
|
193
|
+
};
|
|
194
|
+
useMount(async () => {
|
|
195
|
+
console.log("Chatbot mounted");
|
|
196
|
+
if (isMountedRef.current) return;
|
|
197
|
+
isMountedRef.current = true;
|
|
198
|
+
await createClient();
|
|
199
|
+
});
|
|
200
|
+
useUnmount(() => {
|
|
201
|
+
console.log("Chatbot unmounted");
|
|
202
|
+
deregisterEventHandlers();
|
|
203
|
+
isMountedRef.current = false;
|
|
204
|
+
hasLoadedBefore.current = true;
|
|
205
|
+
});
|
|
206
|
+
return /* @__PURE__ */ jsxs("div", { className: project === "ufb" ? chatbotUFB : chatbotAXB, children: [
|
|
207
|
+
/* @__PURE__ */ jsx(Bubble, { onClick: handleClick }),
|
|
208
|
+
/* @__PURE__ */ jsx(
|
|
209
|
+
ChatWindow,
|
|
210
|
+
{
|
|
211
|
+
status,
|
|
212
|
+
virtualAgent: agent_virtual.current,
|
|
213
|
+
messages,
|
|
214
|
+
onSend: onSendMessage,
|
|
215
|
+
endChat: onEndChat
|
|
216
|
+
}
|
|
217
|
+
)
|
|
218
|
+
] });
|
|
219
|
+
};
|
|
220
|
+
export {
|
|
221
|
+
Chatbot
|
|
222
|
+
};
|
|
@@ -0,0 +1,85 @@
|
|
|
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
|
+
};
|
|
@@ -0,0 +1,19 @@
|
|
|
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
|
+
};
|
|
@@ -0,0 +1,16 @@
|
|
|
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
|
+
};
|
|
@@ -0,0 +1,38 @@
|
|
|
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
|
+
};
|
|
@@ -0,0 +1,10 @@
|
|
|
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 {};
|
|
@@ -0,0 +1,18 @@
|
|
|
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
|
+
};
|
|
@@ -0,0 +1,15 @@
|
|
|
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 {};
|
|
@@ -0,0 +1,13 @@
|
|
|
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
|
+
};
|
|
@@ -0,0 +1,27 @@
|
|
|
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 {};
|