Files
web/apps/scandic-web/components/ChatbotScript/RouteChange.tsx
Erik Tiekstra 15a352ea99 feat(BOOK-68): Added kindly chatbot
Approved-by: Linus Flood
2025-09-11 12:44:47 +00:00

35 lines
837 B
TypeScript

"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
}