@axos-web-dev/shared-components 1.0.77-patch.55 → 1.0.77-patch.57
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 +5 -3
- package/dist/Accordion/Accordion.css.js +2 -1
- package/dist/Accordion/Accordion.js +2 -1
- package/dist/AlertBanner/index.js +2 -1
- package/dist/Article/Article.css.d.ts +1 -0
- package/dist/Article/Article.css.js +12 -9
- package/dist/Article/Article.d.ts +2 -1
- package/dist/Article/Article.js +13 -2
- package/dist/Article/index.js +3 -2
- package/dist/ArticlesSet/ArticlesSet.css.js +2 -1
- package/dist/Auth/ErrorAlert.js +5 -3
- package/dist/Auth/SignIn.css.js +2 -1
- package/dist/AwardsBanner/AwardsBanner.css.js +2 -1
- package/dist/Blockquote/Blockquote.module.js +3 -3
- package/dist/BulletItem/BulletItem.js +2 -1
- package/dist/Button/Button.css.js +2 -1
- package/dist/Button/Button.js +5 -3
- package/dist/Calculators/AnnualFeeCalculator/AnnualFeeCalculator.css.js +2 -1
- package/dist/Calculators/ApyCalculator/ApyCalculator.css.js +2 -1
- package/dist/Calculators/AxosOneCalculator/BalanceAPYCalculator.css.js +2 -1
- package/dist/Calculators/AxosOneCalculator/index.js +2 -1
- package/dist/Calculators/BalanceAPYCalculator/BalanceAPYCalculator.css.js +2 -1
- package/dist/Calculators/BalanceAPYCalculator/index.js +2 -1
- package/dist/Calculators/BuyDownCalculator/BuyDownCalculator.css.js +2 -1
- package/dist/Calculators/Calculator.js +5 -3
- package/dist/Calculators/MonthlyPaymentCalculator/MonthlyPaymentCalculator.css.js +2 -1
- package/dist/Calculators/MonthlyPaymentLVFCalculator/MonthlyPaymentCalculator.css.js +2 -1
- package/dist/Calculators/SummitApyCalculator/BalanceAPYCalculator.css.js +2 -1
- package/dist/Calculators/SummitApyCalculator/index.js +2 -1
- package/dist/Calculators/calculator.css.js +2 -1
- package/dist/CallToActionBar/CallToActionBar.css.d.ts +3 -1
- package/dist/CallToActionBar/CallToActionBar.css.js +23 -16
- package/dist/CallToActionBar/index.js +3 -2
- package/dist/Carousel/Carousel.css.js +2 -1
- package/dist/Carousel/index.js +5 -3
- package/dist/Chatbot/AnimatedGradientBorder.css.d.ts +3 -0
- package/dist/Chatbot/AnimatedGradientBorder.css.js +13 -0
- package/dist/Chatbot/Bubble.css.d.ts +4 -0
- package/dist/Chatbot/Bubble.css.js +15 -3
- package/dist/Chatbot/Bubble.js +26 -19
- package/dist/Chatbot/Chat.js +0 -7
- package/dist/Chatbot/ChatWindow.css.d.ts +17 -0
- package/dist/Chatbot/ChatWindow.css.js +46 -17
- package/dist/Chatbot/ChatWindow.d.ts +6 -1
- package/dist/Chatbot/ChatWindow.js +338 -283
- package/dist/Chatbot/Chatbot.css.js +1 -1
- package/dist/Chatbot/Chatbot.js +117 -9
- package/dist/Chatbot/ChatbotMessage.d.ts +17 -0
- package/dist/Chatbot/ChatbotMessage.js +219 -0
- package/dist/Chatbot/ThankYouMessage.d.ts +9 -0
- package/dist/Chatbot/ThankYouMessage.js +510 -0
- package/dist/Chatbot/index.js +18 -2
- package/dist/Chatbot/store/chat.d.ts +6 -0
- package/dist/Chatbot/store/chat.js +12 -1
- package/dist/Chatbot/store/messages.d.ts +2 -1
- package/dist/Chatbot/store/messages.js +12 -4
- package/dist/Chevron/Chevron.css.js +2 -1
- package/dist/Chevron/index.js +5 -3
- package/dist/CollectInformationAlert/CollectInformationAlert.css.js +2 -1
- package/dist/CollectInformationAlert/index.js +2 -1
- package/dist/Comparison/Comparison.css.js +2 -1
- package/dist/Comparison/Comparison.js +6 -4
- package/dist/ContentBanner/ContentBanner.css.js +3 -1
- package/dist/DownloadTile/DownloadTile.css.js +2 -1
- package/dist/ExecutiveBio/ExecutiveBio.css.js +2 -1
- package/dist/ExecutiveBio/ExecutiveBio.js +5 -3
- package/dist/FaqAccordion/FaqAccordion.css.js +2 -1
- package/dist/FaqAccordion/index.js +5 -3
- package/dist/FooterDisclosure/LVF/LaVictorieFooter.css.js +2 -1
- package/dist/FooterDisclosure/LVF/LaVictorieFooter.js +2 -1
- package/dist/FooterSiteMap/AxosBank/FooterSiteMap.css.js +2 -1
- package/dist/FooterSiteMap/AxosBank/FooterSiteMap.js +5 -3
- package/dist/Forms/ApplicationStart.js +2 -1
- package/dist/Forms/ApplyNow.js +5 -3
- package/dist/Forms/ClearingForm.js +2 -1
- package/dist/Forms/CommercialDeposits.js +2 -1
- package/dist/Forms/CommercialDepositsNoLendingOption.js +2 -1
- package/dist/Forms/CommercialLending.js +2 -1
- package/dist/Forms/CommercialPremiumFinance.js +2 -1
- package/dist/Forms/ContactCompany.js +2 -1
- package/dist/Forms/ContactCompanyTitle.js +2 -1
- package/dist/Forms/ContactUs.js +2 -1
- package/dist/Forms/ContactUsAAS.js +2 -1
- package/dist/Forms/ContactUsBusiness.js +5 -3
- package/dist/Forms/ContactUsBusinessNameEmail.js +5 -3
- package/dist/Forms/ContactUsLVF.js +2 -1
- package/dist/Forms/ContactUsNMLSId.js +5 -3
- package/dist/Forms/CpraRequest.js +2 -1
- package/dist/Forms/CraPublicFile.js +5 -3
- package/dist/Forms/DealerServices.js +2 -1
- package/dist/Forms/EmailOnly.js +92 -65
- package/dist/Forms/EmailUs.js +2 -1
- package/dist/Forms/Forms.css.d.ts +6 -1
- package/dist/Forms/Forms.css.js +52 -45
- package/dist/Forms/MortgageRate/MortgageRateForm.js +5 -3
- package/dist/Forms/MortgageRate/MortgageRateWatch.js +5 -3
- package/dist/Forms/MortgageWarehouseLending.js +5 -3
- package/dist/Forms/QuickPricer/QuickPricerForm.js +2 -1
- package/dist/Forms/QuickPricer/UserInformation.css.js +2 -1
- package/dist/Forms/ScheduleCall.js +2 -1
- package/dist/Forms/ScheduleCallPremier.js +2 -1
- package/dist/Forms/SuccesForm.js +5 -3
- package/dist/Forms/WcplSurvey.js +2 -1
- package/dist/Forms/index.js +4 -1
- package/dist/HeroBanner/HeroBanner.css.js +3 -1
- package/dist/HeroBanner/HeroBanner.js +2 -1
- package/dist/HeroBanner/LargeBanner.css.js +2 -1
- package/dist/HeroBanner/SelectionBanner.css.js +2 -1
- package/dist/Hyperlink/Hyperlink.css.js +2 -1
- package/dist/Hyperlink/index.js +5 -3
- package/dist/IconBillboard/IconBillboard.css.d.ts +1 -0
- package/dist/IconBillboard/IconBillboard.css.js +13 -10
- package/dist/IconBillboard/IconBillboard.js +2 -2
- package/dist/IconBillboard/index.js +2 -1
- package/dist/ImageBillboard/ImageBillboard.css.js +3 -1
- package/dist/ImageBillboard/ImageBillboard.js +2 -1
- package/dist/ImageBillboard/ImageBillboardSet.js +4 -3
- package/dist/ImageLink/ImageLink.js +5 -3
- package/dist/ImageLink/ImageLinkSet.js +5 -3
- package/dist/ImageLink/index.js +5 -3
- package/dist/Input/Input.css.d.ts +1 -0
- package/dist/Input/Input.css.js +12 -9
- package/dist/Input/index.js +2 -1
- package/dist/Inputs/Input.css.js +2 -1
- package/dist/Insight/Featured/CategorySelector.css.js +2 -1
- package/dist/Insight/Featured/CategorySelector.js +5 -3
- package/dist/Insight/Featured/Featured.js +5 -3
- package/dist/Insight/Featured/Header.js +5 -3
- package/dist/Insight/Insight.css.d.ts +18 -0
- package/dist/Insight/Insight.css.js +44 -8
- package/dist/Insight/index.js +19 -1
- package/dist/Interstitial/Interstitial-variants.css.js +2 -1
- package/dist/LandingPageHeader/LandingPageHeader.css.js +2 -1
- package/dist/LandingPageHeader/LandingPageHeader.js +2 -1
- package/dist/MainHTML/index.d.ts +1 -1
- package/dist/MainHTML/index.js +3 -1
- package/dist/Modal/Modal.css.js +2 -1
- package/dist/Modal/Modal.js +5 -3
- package/dist/NavigationMenu/AxosALTS/NavBar.css.js +2 -1
- package/dist/NavigationMenu/AxosALTS/NavData.js +5 -3
- package/dist/NavigationMenu/AxosALTS/index.js +5 -3
- package/dist/NavigationMenu/AxosAdvisor/NavBar.css.js +2 -1
- package/dist/NavigationMenu/AxosAdvisor/SubNavbar.css.js +2 -1
- package/dist/NavigationMenu/AxosAdvisorServices/NavBar.css.js +2 -1
- package/dist/NavigationMenu/AxosAdvisorServices/SubNavbar.css.js +2 -1
- package/dist/NavigationMenu/AxosBank/MobileMenu/MobileMenu.module.js +16 -16
- package/dist/NavigationMenu/AxosBank/MobileMenu/MobileNavData.js +5 -3
- package/dist/NavigationMenu/AxosBank/NavBar.css.js +2 -1
- package/dist/NavigationMenu/AxosBank/NavData.js +5 -3
- package/dist/NavigationMenu/AxosBank/SubNavBar.js +5 -3
- package/dist/NavigationMenu/AxosBank/SubNavbar.css.js +2 -1
- package/dist/NavigationMenu/AxosBank/index.js +5 -3
- package/dist/NavigationMenu/LaVictoire/NavData.js +5 -3
- package/dist/NavigationMenu/LaVictoire/index.js +5 -3
- package/dist/NavigationMenu/NavDataJson.js +5 -3
- package/dist/NavigationMenu/Navbar.js +5 -3
- package/dist/NavigationMenu/SignInNavButton.js +5 -3
- package/dist/PageNavItem/PageNavItem.css.js +2 -1
- package/dist/Pagination/Pagination.js +2 -1
- package/dist/SecondaryFooter/SecondaryFooter.css.js +2 -1
- package/dist/SetContainer/SetContainer.css.js +2 -1
- package/dist/SetContainer/SetContainer.js +5 -3
- package/dist/SocialMediaBar/iconsRepository.js +5 -3
- package/dist/StepItem/StepItem.css.js +2 -1
- package/dist/StepItemSet/StepItemSet.css.js +2 -1
- package/dist/StepItemSet/StepItemSet.js +2 -1
- package/dist/Tab/Tab.css.js +2 -1
- package/dist/Table/Table.css.js +2 -1
- package/dist/Table/Table.js +2 -1
- package/dist/TextBlock/TextBlock.css.js +2 -1
- package/dist/Typography/Typography.css.d.ts +0 -6
- package/dist/VideoTile/VideoTile.css.js +2 -1
- package/dist/VideoTile/VideoTile.js +5 -3
- package/dist/VideoWrapper/index.js +5 -3
- package/dist/assets/Article/Article.css +54 -41
- package/dist/assets/Blockquote/Blockquote.css.css +19 -15
- package/dist/assets/Calculators/ApyCalculator/ApyCalculator.css +1 -1
- package/dist/assets/Calculators/MarginTradingCalculator/MarginTradingCalculator.css +2 -2
- package/dist/assets/Calculators/SummitApyCalculator/BalanceAPYCalculator.css +1 -1
- package/dist/assets/CallToActionBar/CallToActionBar.css +90 -66
- package/dist/assets/Carousel/Carousel.css +1 -1
- package/dist/assets/Chatbot/AnimatedGradientBorder.css +38 -0
- package/dist/assets/Chatbot/Bubble.css +58 -21
- package/dist/assets/Chatbot/ChatWindow.css +211 -85
- package/dist/assets/Chatbot/Chatbot.css +3 -0
- package/dist/assets/ContentBanner/ContentBanner.css +6 -0
- package/dist/assets/DownloadTile/DownloadTile.css +3 -3
- package/dist/assets/ExecutiveBio/ExecutiveBio.css +1 -1
- package/dist/assets/Forms/Forms.css +147 -120
- package/dist/assets/HelpArticle/HelpArticle.css +2 -2
- package/dist/assets/HeroBanner/HeroBanner.css +4 -0
- package/dist/assets/IconBillboard/IconBillboard.css +35 -28
- package/dist/assets/ImageBillboard/ImageBillboard.css +32 -3
- package/dist/assets/Input/Input.css +49 -42
- package/dist/assets/Inputs/Input.css +1 -1
- package/dist/assets/Insight/Featured/CategorySelector.css +1 -1
- package/dist/assets/Insight/Insight.css +213 -44
- package/dist/assets/NavigationMenu/AxosBank/MobileMenu/MobileMenu.css.css +27 -27
- package/dist/assets/Topic/Topic.css +1 -1
- package/dist/assets/Typography/Typography.css +1 -1
- package/dist/assets/VideoTile/VideoTile.css +1 -1
- package/dist/assets/globals.css +4 -0
- package/dist/assets/themes/axos.css +12 -0
- package/dist/assets/themes/premier.css +12 -0
- package/dist/assets/themes/ufb.css +52 -0
- package/dist/assets/themes/victorie.css +12 -0
- package/dist/icons/ArrowIcon/ArrowIcon.css.js +2 -1
- package/dist/icons/CheckIcon/CheckIcon.css.js +2 -1
- package/dist/icons/Clock/index.js +6 -6
- package/dist/icons/DownloadIcon/DownloadIcon.css.js +2 -1
- package/dist/icons/FollowIcon/FollowIcon.css.js +2 -1
- package/dist/main.js +49 -7
- package/dist/themes/axos.css.d.ts +18 -0
- package/dist/themes/axos.css.js +1 -1
- package/dist/themes/index.d.ts +1 -0
- package/dist/themes/index.js +2 -0
- package/dist/themes/ufb.css.d.ts +1 -0
- package/dist/themes/ufb.css.js +6 -0
- package/package.json +1 -1
- package/dist/Chatbot/Chatbot.css.ts.vanilla.css.js +0 -1
package/dist/Chatbot/Chatbot.js
CHANGED
|
@@ -14,7 +14,14 @@ const Chatbot = ({
|
|
|
14
14
|
menuOption = "Support Virtual Agent",
|
|
15
15
|
debug = false
|
|
16
16
|
}) => {
|
|
17
|
-
const {
|
|
17
|
+
const {
|
|
18
|
+
hasOpenedOnce,
|
|
19
|
+
toggle,
|
|
20
|
+
reset,
|
|
21
|
+
startEscalation,
|
|
22
|
+
hasEscalated,
|
|
23
|
+
endEscalation
|
|
24
|
+
} = useOpenChat();
|
|
18
25
|
const { addMessage, addMessages, clearMessages, messages } = useMessages();
|
|
19
26
|
const clientRef = useRef(null);
|
|
20
27
|
const menuRef = useRef(null);
|
|
@@ -26,10 +33,34 @@ const Chatbot = ({
|
|
|
26
33
|
const [hasStarted, setHasStarted] = useState(false);
|
|
27
34
|
const [menusLoaded, setMenusLoaded] = useState(false);
|
|
28
35
|
const [pendingStart, setPendingStart] = useState(false);
|
|
36
|
+
const [isTyping, setIsTyping] = useState(false);
|
|
37
|
+
const [scalationStarted, setScalationStarted] = useState(false);
|
|
38
|
+
useEffect(() => {
|
|
39
|
+
if (messages.length === 0) return;
|
|
40
|
+
const hasScalation = messages.some(
|
|
41
|
+
(msg) => msg.$userType === "user" || ["escalationAccepted", "escalationStarted"].includes(
|
|
42
|
+
msg.event
|
|
43
|
+
)
|
|
44
|
+
);
|
|
45
|
+
setScalationStarted(hasScalation);
|
|
46
|
+
return () => {
|
|
47
|
+
setScalationStarted(false);
|
|
48
|
+
};
|
|
49
|
+
}, [messages]);
|
|
29
50
|
const brandMap = /* @__PURE__ */ new Map([
|
|
30
51
|
["axos", 1],
|
|
31
52
|
["ufb", 3]
|
|
32
53
|
]);
|
|
54
|
+
const typingMessage = {
|
|
55
|
+
$sid: "typing-1",
|
|
56
|
+
type: "system",
|
|
57
|
+
text: scalationStarted ? "Typing" : "AI is typing...",
|
|
58
|
+
sender: { id: "system", type: "system" },
|
|
59
|
+
$timestamp: /* @__PURE__ */ new Date(),
|
|
60
|
+
$userType: "system",
|
|
61
|
+
$index: -10,
|
|
62
|
+
$userId: 0
|
|
63
|
+
};
|
|
33
64
|
const custom_data = {
|
|
34
65
|
unsigned: {
|
|
35
66
|
facingBrandId: {
|
|
@@ -46,7 +77,7 @@ const Chatbot = ({
|
|
|
46
77
|
},
|
|
47
78
|
env: {
|
|
48
79
|
label: "env",
|
|
49
|
-
value: projectEnv === "
|
|
80
|
+
value: projectEnv === "uat" ? "dev" : projectEnv
|
|
50
81
|
}
|
|
51
82
|
}
|
|
52
83
|
};
|
|
@@ -66,10 +97,39 @@ const Chatbot = ({
|
|
|
66
97
|
};
|
|
67
98
|
const onChatMessageHandler = async (message) => {
|
|
68
99
|
console.log("Received message:", message);
|
|
69
|
-
|
|
100
|
+
if (["system", "virtual_agent", "user"].includes(message.$userType) && message.event === void 0) {
|
|
101
|
+
addMessage(message);
|
|
102
|
+
return;
|
|
103
|
+
}
|
|
104
|
+
const eventName = message?.event;
|
|
105
|
+
switch (eventName) {
|
|
106
|
+
case "escalationAccepted":
|
|
107
|
+
setScalationStarted(true);
|
|
108
|
+
startEscalation?.();
|
|
109
|
+
addMessage(message);
|
|
110
|
+
return;
|
|
111
|
+
case "escalationStarted":
|
|
112
|
+
setScalationStarted(true);
|
|
113
|
+
startEscalation?.();
|
|
114
|
+
addMessage(message);
|
|
115
|
+
return;
|
|
116
|
+
default:
|
|
117
|
+
addMessage(message);
|
|
118
|
+
if (["end_user"].includes(message.$userType)) {
|
|
119
|
+
if (!hasEscalated) {
|
|
120
|
+
addMessage(typingMessage);
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
return;
|
|
124
|
+
}
|
|
70
125
|
};
|
|
71
126
|
const onChatTypingStartedHandler = async (identity) => {
|
|
72
127
|
console.log("Typing started by:", identity);
|
|
128
|
+
setIsTyping(true);
|
|
129
|
+
};
|
|
130
|
+
const onChatTypingEndedHandler = async (identity) => {
|
|
131
|
+
console.log("Typing ended by:", identity);
|
|
132
|
+
setIsTyping(false);
|
|
73
133
|
};
|
|
74
134
|
const onChatDisconnectedHandler = async () => {
|
|
75
135
|
console.log("Chat disconnected");
|
|
@@ -91,23 +151,38 @@ const Chatbot = ({
|
|
|
91
151
|
const onChatMemberLeftHandler = async (identity) => {
|
|
92
152
|
console.log("Chat member left:", identity);
|
|
93
153
|
};
|
|
154
|
+
const onChatMemberJoinedHandler = async (identity) => {
|
|
155
|
+
console.log("Chat member joined:", identity);
|
|
156
|
+
};
|
|
94
157
|
const onChatConnectedHandler = async () => {
|
|
95
158
|
setStatus("connected");
|
|
96
159
|
console.log("connected");
|
|
97
160
|
const messages2 = await clientRef.current?.fetchMessages();
|
|
98
161
|
if (messages2) {
|
|
99
162
|
addMessages(messages2);
|
|
163
|
+
const hasEscalation = messages2.some(
|
|
164
|
+
(msg) => msg.$userType === "user" || ["escalationAccepted", "escalationStarted"].includes(
|
|
165
|
+
msg.event
|
|
166
|
+
)
|
|
167
|
+
);
|
|
168
|
+
console.log(hasEscalation);
|
|
169
|
+
if (hasEscalation) {
|
|
170
|
+
setScalationStarted(true);
|
|
171
|
+
startEscalation?.();
|
|
172
|
+
}
|
|
100
173
|
}
|
|
101
174
|
};
|
|
102
175
|
const registerEventHandlers = () => {
|
|
103
176
|
clientRef.current?.on("chat.ongoing", onChatOngoingHandler);
|
|
104
177
|
clientRef.current?.on("chat.message", onChatMessageHandler);
|
|
105
178
|
clientRef.current?.on("chat.typingStarted", onChatTypingStartedHandler);
|
|
179
|
+
clientRef.current?.on("chat.typingEnded", onChatTypingEndedHandler);
|
|
106
180
|
clientRef.current?.on("chat.disconnected", onChatDisconnectedHandler);
|
|
107
181
|
clientRef.current?.on("chat.dismissed", onDismissedHandler);
|
|
108
182
|
clientRef.current?.on("chat.timeout", onTimeoutHandler);
|
|
109
183
|
clientRef.current?.on("chat.ended", onEndedHandler);
|
|
110
184
|
clientRef.current?.on("chat.destroyed", onDestroyedHandler);
|
|
185
|
+
clientRef.current?.on("chat.memberJoined", onChatMemberJoinedHandler);
|
|
111
186
|
clientRef.current?.on("chat.memberLeft", onChatMemberLeftHandler);
|
|
112
187
|
clientRef?.current?.on("chat.connected", onChatConnectedHandler);
|
|
113
188
|
};
|
|
@@ -117,12 +192,14 @@ const Chatbot = ({
|
|
|
117
192
|
clientRef.current?.off("chat.ongoing", onDismissedHandler);
|
|
118
193
|
clientRef.current?.off("chat.message", onChatMessageHandler);
|
|
119
194
|
clientRef.current?.off("chat.typingStarted", onChatTypingStartedHandler);
|
|
195
|
+
clientRef.current?.off("chat.typingEnded", onChatTypingEndedHandler);
|
|
120
196
|
clientRef.current?.off("chat.disconnected", onChatDisconnectedHandler);
|
|
121
197
|
clientRef.current?.off("chat.dismissed", onDismissedHandler);
|
|
122
198
|
clientRef.current?.off("chat.timeout", onTimeoutHandler);
|
|
123
199
|
clientRef.current?.off("chat.ended", onEndedHandler);
|
|
124
200
|
clientRef.current?.off("chat.destroyed", onDestroyedHandler);
|
|
125
201
|
clientRef.current?.off("chat.memberLeft", onChatMemberLeftHandler);
|
|
202
|
+
clientRef.current?.off("chat.memberJoined", onChatMemberJoinedHandler);
|
|
126
203
|
clientRef.current?.off("chat.connected", onChatConnectedHandler);
|
|
127
204
|
};
|
|
128
205
|
const createClient = async () => {
|
|
@@ -136,6 +213,9 @@ const Chatbot = ({
|
|
|
136
213
|
tenant: process.env.CCAI_TENANT_NAME || "",
|
|
137
214
|
host: process.env.CCAI_HOST || "",
|
|
138
215
|
// or your region
|
|
216
|
+
// companyId: import.meta.env.VITE_COMPANY_ID || "",
|
|
217
|
+
// tenant: import.meta.env.VITE_TENANT_NAME || "",
|
|
218
|
+
// host: import.meta.env.VITE_HOST || "", // or your region
|
|
139
219
|
authenticate
|
|
140
220
|
});
|
|
141
221
|
client?.on("ready", onReadyHandler);
|
|
@@ -196,22 +276,27 @@ const Chatbot = ({
|
|
|
196
276
|
setHasStarted(true);
|
|
197
277
|
}
|
|
198
278
|
};
|
|
199
|
-
const onSendMessage = (msg) => {
|
|
279
|
+
const onSendMessage = async (msg) => {
|
|
200
280
|
console.log("Sending message:", msg);
|
|
201
|
-
clientRef.current?.sendTextMessage(msg);
|
|
281
|
+
await clientRef.current?.sendTextMessage(msg);
|
|
202
282
|
};
|
|
203
283
|
const onEndChat = async () => {
|
|
204
284
|
console.log("Ending chat");
|
|
205
285
|
if (chatRef.current) {
|
|
206
286
|
await clientRef.current?.finishChat();
|
|
207
|
-
await chatRef.current
|
|
287
|
+
await chatRef.current?.destroy();
|
|
208
288
|
clearMessages();
|
|
209
289
|
chatRef.current = null;
|
|
210
290
|
console.log("Chat ended");
|
|
211
291
|
setHasStarted(false);
|
|
212
|
-
|
|
292
|
+
endEscalation?.();
|
|
213
293
|
}
|
|
214
294
|
};
|
|
295
|
+
const onEndAndStartNewChat = async () => {
|
|
296
|
+
console.log("Ending current chat and starting a new one");
|
|
297
|
+
await onEndChat();
|
|
298
|
+
await startChat();
|
|
299
|
+
};
|
|
215
300
|
useMount(async () => {
|
|
216
301
|
console.log("Chatbot mounted");
|
|
217
302
|
if (isMountedRef.current) return;
|
|
@@ -221,7 +306,6 @@ const Chatbot = ({
|
|
|
221
306
|
useEffect(() => {
|
|
222
307
|
if (menusLoaded && pendingStart && !hasStarted) {
|
|
223
308
|
startChat();
|
|
224
|
-
setHasStarted(true);
|
|
225
309
|
setPendingStart(false);
|
|
226
310
|
}
|
|
227
311
|
}, [menusLoaded, pendingStart, hasStarted]);
|
|
@@ -234,10 +318,29 @@ const Chatbot = ({
|
|
|
234
318
|
setHasStarted(false);
|
|
235
319
|
setStatus("idle");
|
|
236
320
|
clearMessages();
|
|
321
|
+
endEscalation?.();
|
|
237
322
|
clientRef.current?.destroy();
|
|
238
323
|
clientRef.current?.destroyChat();
|
|
239
324
|
clientRef.current = null;
|
|
240
325
|
});
|
|
326
|
+
const onClose = () => {
|
|
327
|
+
toggle();
|
|
328
|
+
};
|
|
329
|
+
const onCloseAfterThankYou = () => {
|
|
330
|
+
reset();
|
|
331
|
+
setHasStarted(false);
|
|
332
|
+
};
|
|
333
|
+
const onPreviewTyping = async (msg) => {
|
|
334
|
+
console.log("Preview typing message:", msg);
|
|
335
|
+
try {
|
|
336
|
+
if (clientRef.current) {
|
|
337
|
+
chatRef.current?.startTyping();
|
|
338
|
+
await clientRef.current?.sendPreviewMessage(msg);
|
|
339
|
+
}
|
|
340
|
+
} catch (error) {
|
|
341
|
+
console.error("Error sending preview message:", error);
|
|
342
|
+
}
|
|
343
|
+
};
|
|
241
344
|
return /* @__PURE__ */ jsxs("div", { className: project === "ufb" ? chatbotUFB : chatbotAXB, children: [
|
|
242
345
|
/* @__PURE__ */ jsx(Bubble, { onClick: handleClick }),
|
|
243
346
|
/* @__PURE__ */ jsx(
|
|
@@ -247,7 +350,12 @@ const Chatbot = ({
|
|
|
247
350
|
virtualAgent: agent_virtual.current,
|
|
248
351
|
messages,
|
|
249
352
|
onSend: onSendMessage,
|
|
250
|
-
endChat: onEndChat
|
|
353
|
+
endChat: onEndChat,
|
|
354
|
+
onClose,
|
|
355
|
+
onNewChat: onEndAndStartNewChat,
|
|
356
|
+
onCloseAfterThankYou,
|
|
357
|
+
previewTyping: onPreviewTyping,
|
|
358
|
+
isTyping
|
|
251
359
|
}
|
|
252
360
|
)
|
|
253
361
|
] });
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { FC } from 'react';
|
|
2
|
+
import { MessageResponse as BaseMessageResponse, HumanAgent, VirtualAgent } from '@ujet/websdk-headless';
|
|
3
|
+
|
|
4
|
+
interface MessageResponse extends BaseMessageResponse {
|
|
5
|
+
to_agent?: HumanAgent;
|
|
6
|
+
}
|
|
7
|
+
interface ChatbotMessageProps {
|
|
8
|
+
msg: MessageResponse;
|
|
9
|
+
showAvatar?: boolean;
|
|
10
|
+
showName?: boolean;
|
|
11
|
+
virtualAgent?: VirtualAgent | null;
|
|
12
|
+
onCancelEndChat?: () => void;
|
|
13
|
+
onSend?: (content: string) => void;
|
|
14
|
+
onEndChat?: () => void;
|
|
15
|
+
}
|
|
16
|
+
export declare const ChatbotMessage: FC<ChatbotMessageProps>;
|
|
17
|
+
export {};
|
|
@@ -0,0 +1,219 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx, jsxs, Fragment } from "react/jsx-runtime";
|
|
3
|
+
import { useState, useEffect } from "react";
|
|
4
|
+
import ReactMarkdown from "react-markdown";
|
|
5
|
+
import remarkGfm from "remark-gfm";
|
|
6
|
+
import { vars } from "../themes/axos.css.js";
|
|
7
|
+
import '../assets/themes/victorie.css';import '../assets/themes/ufb.css';import '../assets/themes/premier.css';import '../assets/themes/axos.css';/* empty css */
|
|
8
|
+
/* empty css */
|
|
9
|
+
/* empty css */
|
|
10
|
+
/* empty css */
|
|
11
|
+
import clsx from "clsx";
|
|
12
|
+
import { shimmerText, notificationStyle, endChatButtonStyle, messageStyle, user_msg, agent_msg, inline_button_wrapper, inline_button } from "./ChatWindow.css.js";
|
|
13
|
+
import { useOpenChat } from "./store/chat.js";
|
|
14
|
+
function timeAgo(date) {
|
|
15
|
+
const seconds = Math.floor(((/* @__PURE__ */ new Date()).getTime() - date.getTime()) / 1e3);
|
|
16
|
+
if (seconds < 60) return "Just now";
|
|
17
|
+
return new Date(date).toLocaleTimeString([], {
|
|
18
|
+
hour: "2-digit",
|
|
19
|
+
minute: "2-digit"
|
|
20
|
+
});
|
|
21
|
+
}
|
|
22
|
+
const ChatbotMessage = ({
|
|
23
|
+
msg,
|
|
24
|
+
showAvatar,
|
|
25
|
+
showName,
|
|
26
|
+
virtualAgent,
|
|
27
|
+
onCancelEndChat,
|
|
28
|
+
onEndChat,
|
|
29
|
+
onSend
|
|
30
|
+
}) => {
|
|
31
|
+
const { hasEscalated } = useOpenChat();
|
|
32
|
+
const [timeText, setTimeText] = useState(timeAgo(msg.$timestamp));
|
|
33
|
+
useEffect(() => {
|
|
34
|
+
const interval = setInterval(() => {
|
|
35
|
+
setTimeText(timeAgo(msg.$timestamp));
|
|
36
|
+
}, 3e4);
|
|
37
|
+
return () => clearInterval(interval);
|
|
38
|
+
}, [msg.$timestamp]);
|
|
39
|
+
if (msg.$sid === "typing-1" && !hasEscalated) {
|
|
40
|
+
return /* @__PURE__ */ jsx(
|
|
41
|
+
"div",
|
|
42
|
+
{
|
|
43
|
+
className: clsx(),
|
|
44
|
+
style: {
|
|
45
|
+
textAlign: "left",
|
|
46
|
+
alignSelf: "flex-start",
|
|
47
|
+
color: "#1e3860",
|
|
48
|
+
borderRadius: 16,
|
|
49
|
+
padding: "8px 8px",
|
|
50
|
+
maxWidth: "80%",
|
|
51
|
+
marginBottom: 2
|
|
52
|
+
},
|
|
53
|
+
children: /* @__PURE__ */ jsx(
|
|
54
|
+
"div",
|
|
55
|
+
{
|
|
56
|
+
style: {
|
|
57
|
+
fontSize: 14,
|
|
58
|
+
display: "flex",
|
|
59
|
+
flexDirection: "column",
|
|
60
|
+
gap: 4
|
|
61
|
+
},
|
|
62
|
+
children: /* @__PURE__ */ jsx("p", { className: shimmerText, children: "AI thinking..." })
|
|
63
|
+
}
|
|
64
|
+
)
|
|
65
|
+
}
|
|
66
|
+
);
|
|
67
|
+
}
|
|
68
|
+
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
69
|
+
msg.type == "noti" && msg.$userType == "system" && msg.event == "escalationStarted" && /* @__PURE__ */ jsx("div", { className: notificationStyle, children: "We are connecting you with a human agent..." }, msg.$index),
|
|
70
|
+
msg.type == "noti" && msg.$userType == "system" && msg.event == "memberLeft" && /* @__PURE__ */ jsxs("div", { className: notificationStyle, children: [
|
|
71
|
+
/* @__PURE__ */ jsx("strong", { children: "Virtual Agent" }),
|
|
72
|
+
" just left the conversation."
|
|
73
|
+
] }, msg.$index),
|
|
74
|
+
msg.type == "noti" && msg.$userType == "system" && msg.event == "escalationAccepted" && /* @__PURE__ */ jsxs("div", { className: notificationStyle, children: [
|
|
75
|
+
"You are now connected with a",
|
|
76
|
+
" ",
|
|
77
|
+
msg.to_agent ? /* @__PURE__ */ jsx("strong", { children: msg?.to_agent?.name }) : "an agent"
|
|
78
|
+
] }, msg.$index),
|
|
79
|
+
msg.type == "noti" && msg.$userType == "virtual_agent" && msg.event == "escalationDeflected" && /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
80
|
+
/* @__PURE__ */ jsxs(
|
|
81
|
+
"div",
|
|
82
|
+
{
|
|
83
|
+
className: notificationStyle,
|
|
84
|
+
style: { fontSize: 12 },
|
|
85
|
+
children: [
|
|
86
|
+
"Our chat team is available weekdays, 8am-5pm, except federal bank holidays. For immediate assistance you can reach out to us at",
|
|
87
|
+
" ",
|
|
88
|
+
/* @__PURE__ */ jsx("a", { href: "tel:1-888-502-2967", children: "1-888-502-2967" }),
|
|
89
|
+
"."
|
|
90
|
+
]
|
|
91
|
+
},
|
|
92
|
+
msg.$index
|
|
93
|
+
),
|
|
94
|
+
/* @__PURE__ */ jsx("div", { style: { textAlign: "center", marginBottom: 12 }, children: /* @__PURE__ */ jsx("button", { className: endChatButtonStyle, onClick: onCancelEndChat, children: "End Chat" }) })
|
|
95
|
+
] }),
|
|
96
|
+
["text", "markdown_template", "markdown"].includes(msg.type) && /* @__PURE__ */ jsx(
|
|
97
|
+
"div",
|
|
98
|
+
{
|
|
99
|
+
className: clsx(
|
|
100
|
+
messageStyle,
|
|
101
|
+
msg.$userType == "end_user" ? user_msg : agent_msg
|
|
102
|
+
),
|
|
103
|
+
children: /* @__PURE__ */ jsxs(
|
|
104
|
+
"div",
|
|
105
|
+
{
|
|
106
|
+
style: {
|
|
107
|
+
fontSize: 14,
|
|
108
|
+
display: "flex",
|
|
109
|
+
flexDirection: "column",
|
|
110
|
+
gap: 4
|
|
111
|
+
},
|
|
112
|
+
children: [
|
|
113
|
+
msg.$userType == "virtual_agent" && /* @__PURE__ */ jsxs(
|
|
114
|
+
"div",
|
|
115
|
+
{
|
|
116
|
+
style: {
|
|
117
|
+
display: "flex",
|
|
118
|
+
alignItems: "center",
|
|
119
|
+
gap: "8px"
|
|
120
|
+
},
|
|
121
|
+
children: [
|
|
122
|
+
showAvatar && /* @__PURE__ */ jsx(
|
|
123
|
+
"img",
|
|
124
|
+
{
|
|
125
|
+
width: 24,
|
|
126
|
+
height: 24,
|
|
127
|
+
src: virtualAgent?.avatar_url,
|
|
128
|
+
alt: "agent avatar"
|
|
129
|
+
}
|
|
130
|
+
),
|
|
131
|
+
showName && /* @__PURE__ */ jsx("strong", { children: virtualAgent?.name })
|
|
132
|
+
]
|
|
133
|
+
}
|
|
134
|
+
),
|
|
135
|
+
msg.$userType != "end_user" ? /* @__PURE__ */ jsx(Fragment, { children: /* @__PURE__ */ jsx(
|
|
136
|
+
ReactMarkdown,
|
|
137
|
+
{
|
|
138
|
+
remarkPlugins: [[remarkGfm, { singleTilde: false }]],
|
|
139
|
+
components: {
|
|
140
|
+
p: ({ ...props }) => /* @__PURE__ */ jsx(
|
|
141
|
+
"p",
|
|
142
|
+
{
|
|
143
|
+
style: { margin: 0, fontSize: "inherit" },
|
|
144
|
+
title: new Date(msg.$timestamp).toLocaleTimeString([], {
|
|
145
|
+
hour: "2-digit",
|
|
146
|
+
minute: "2-digit"
|
|
147
|
+
}),
|
|
148
|
+
...props
|
|
149
|
+
}
|
|
150
|
+
),
|
|
151
|
+
a: ({ ...props }) => /* @__PURE__ */ jsx("a", { style: { wordBreak: "break-word" }, ...props })
|
|
152
|
+
},
|
|
153
|
+
children: msg.content
|
|
154
|
+
}
|
|
155
|
+
) }) : /* @__PURE__ */ jsx(
|
|
156
|
+
"div",
|
|
157
|
+
{
|
|
158
|
+
title: new Date(msg.$timestamp).toLocaleTimeString([], {
|
|
159
|
+
hour: "2-digit",
|
|
160
|
+
minute: "2-digit"
|
|
161
|
+
}),
|
|
162
|
+
children: msg.content
|
|
163
|
+
}
|
|
164
|
+
)
|
|
165
|
+
]
|
|
166
|
+
}
|
|
167
|
+
)
|
|
168
|
+
},
|
|
169
|
+
msg.$index
|
|
170
|
+
),
|
|
171
|
+
msg.type == "inline_button" && Array.isArray(msg.buttons) && msg.buttons.length > 0 && /* @__PURE__ */ jsx("div", { className: inline_button_wrapper, children: msg.buttons.length !== 0 && Array.isArray(msg.buttons) && msg.buttons.map((button, index) => {
|
|
172
|
+
return /* @__PURE__ */ jsx(
|
|
173
|
+
"button",
|
|
174
|
+
{
|
|
175
|
+
className: inline_button,
|
|
176
|
+
onClick: () => {
|
|
177
|
+
onSend?.(button?.title);
|
|
178
|
+
},
|
|
179
|
+
children: button.title
|
|
180
|
+
},
|
|
181
|
+
index
|
|
182
|
+
);
|
|
183
|
+
}) }),
|
|
184
|
+
msg.event == "chatEnded" && /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
185
|
+
/* @__PURE__ */ jsxs(
|
|
186
|
+
"div",
|
|
187
|
+
{
|
|
188
|
+
title: (/* @__PURE__ */ new Date()).toLocaleString(),
|
|
189
|
+
style: {
|
|
190
|
+
fontSize: 12,
|
|
191
|
+
color: "#888",
|
|
192
|
+
marginBottom: 4,
|
|
193
|
+
textAlign: "center"
|
|
194
|
+
},
|
|
195
|
+
children: [
|
|
196
|
+
"Thank you for chatting!",
|
|
197
|
+
/* @__PURE__ */ jsx("br", {}),
|
|
198
|
+
" This conversation has ended."
|
|
199
|
+
]
|
|
200
|
+
}
|
|
201
|
+
),
|
|
202
|
+
/* @__PURE__ */ jsx("div", { style: { textAlign: "center", marginBottom: 12 }, children: /* @__PURE__ */ jsx("button", { className: endChatButtonStyle, onClick: onEndChat, children: "End Chat" }) })
|
|
203
|
+
] }),
|
|
204
|
+
msg.type == "text" && /* @__PURE__ */ jsx(
|
|
205
|
+
"div",
|
|
206
|
+
{
|
|
207
|
+
style: {
|
|
208
|
+
textAlign: msg.$userType === "end_user" ? "right" : "left",
|
|
209
|
+
fontSize: 12,
|
|
210
|
+
color: vars.chatbot.window.timestampColor
|
|
211
|
+
},
|
|
212
|
+
children: timeText
|
|
213
|
+
}
|
|
214
|
+
)
|
|
215
|
+
] });
|
|
216
|
+
};
|
|
217
|
+
export {
|
|
218
|
+
ChatbotMessage
|
|
219
|
+
};
|