feat(BOOK-67): Added functionality to show/hide the chatbot

Approved-by: Linus Flood
This commit is contained in:
Erik Tiekstra
2025-10-16 10:59:47 +00:00
parent 69a1b5f213
commit 800df0ade9
13 changed files with 147 additions and 72 deletions

View File

@@ -1,33 +1,9 @@
import Script from "next/script"
import { env } from "@/env/server"
import { CHATBOT_HIDE_ROUTES } from "@/components/ChatbotScript/constants"
import { ChatbotRouteChange } from "@/components/ChatbotScript/RouteChange"
import { getLang } from "@/i18n/serverContext"
import { getPathname } from "@/utils/getPathname"
import { ChatbotClient } from "@/components/ChatbotScript/Client"
export default async function ChatbotScript() {
const lang = await getLang()
const liveLangs = env.CHATBOT_LIVE_LANGS
const pathName = await getPathname()
const isLive = liveLangs.includes(lang)
const shouldHideChatbot = CHATBOT_HIDE_ROUTES.some((route) =>
pathName.includes(route)
)
return (
<>
<Script
id="kindly-chat"
src="https://chat.kindlycdn.com/kindly-chat.js"
data-bot-key="910bd27a-7472-43a1-bcfc-955b41adc3e7"
data-shadow-dom
data-bubble-hidden={!isLive || shouldHideChatbot}
data-language={lang}
defer
></Script>
<ChatbotRouteChange liveLangs={liveLangs} />
</>
)
return <ChatbotClient liveLangs={liveLangs} />
}