feat(BOOK-68): Added kindly chatbot
Approved-by: Linus Flood
This commit is contained in:
@@ -0,0 +1,34 @@
|
||||
"use client"
|
||||
|
||||
import { usePathname } from "next/navigation"
|
||||
import { useEffect } from "react"
|
||||
|
||||
import useLang from "@/hooks/useLang"
|
||||
|
||||
import { CHATBOT_HIDE_ROUTES } from "./constants"
|
||||
|
||||
interface ChatbotRouteChangeProps {
|
||||
liveLangs: string[]
|
||||
}
|
||||
|
||||
export function ChatbotRouteChange({ liveLangs }: ChatbotRouteChangeProps) {
|
||||
const pathName = usePathname()
|
||||
const currentLang = useLang()
|
||||
|
||||
useEffect(() => {
|
||||
const isLive = liveLangs.includes(currentLang)
|
||||
const shouldHideChatbot = CHATBOT_HIDE_ROUTES.some((route) =>
|
||||
pathName.includes(route)
|
||||
)
|
||||
if (window.kindlyChat) {
|
||||
if (shouldHideChatbot || !isLive) {
|
||||
window.kindlyChat.closeChat()
|
||||
window.kindlyChat.hideBubble()
|
||||
} else {
|
||||
window.kindlyChat.showBubble()
|
||||
}
|
||||
}
|
||||
}, [pathName, liveLangs, currentLang])
|
||||
|
||||
return null
|
||||
}
|
||||
Reference in New Issue
Block a user