diff --git a/src/components/chatbot/ChannelService.ts b/src/components/chatbot/ChannelService.ts deleted file mode 100644 index 70e5326..0000000 --- a/src/components/chatbot/ChannelService.ts +++ /dev/null @@ -1,64 +0,0 @@ -/* eslint-disable @typescript-eslint/no-explicit-any */ -declare global { - interface Window { - ChannelIO: (arg0: string, arg1?: unknown, arg2?: unknown) => void; - ChannelIOInitialized: boolean; - } -} - -class ChannelService { - constructor() { - this.loadScript(); - } - - loadScript() { - const w = window; - if (w.ChannelIOInitialized) { - return; - } - const channelIO = function () { - // eslint-disable-next-line prefer-rest-params - channelIO.c(arguments); - }; - - channelIO.q = [] as any[]; - channelIO.c = function (args: any) { - channelIO.q.push(args); - }; - w.ChannelIO = channelIO; - function initializeChannelIO() { - if (w.ChannelIOInitialized) { - return; - } - w.ChannelIOInitialized = true; - const script = document.createElement("script"); - script.type = "text/javascript"; - script.async = true; - script.src = "https://cdn.channel.io/plugin/ch-plugin-web.js"; - const firstScript = document.getElementsByTagName("script")[0]; - if (firstScript?.parentNode) { - firstScript.parentNode.insertBefore(script, firstScript); - } - } - if (document.readyState === "complete") { - initializeChannelIO(); - } else { - w.addEventListener("DOMContentLoaded", initializeChannelIO); - w.addEventListener("load", initializeChannelIO); - } - } - boot(settings: any, callback: any) { - window.ChannelIO("boot", settings, callback); - } - onBadgeChanged(callback: (number: number) => void) { - window.ChannelIO("onBadgeChanged", callback); - } - addTags(tags: string[]) { - window.ChannelIO("addTags", tags); - } - shutdown() { - window.ChannelIO("shutdown"); - } -} - -export default ChannelService; diff --git a/src/components/chatbot/Chatbot.tsx b/src/components/chatbot/Chatbot.tsx deleted file mode 100644 index 422ef9e..0000000 --- a/src/components/chatbot/Chatbot.tsx +++ /dev/null @@ -1,17 +0,0 @@ -import { useEffect } from 'react'; - -import { CHANNELIO_PLUGIN_KEY } from '@constants/environment'; - -import ChannelService from '@/components/chatbot/ChannelService'; - -export default function Chatbot() { - useEffect(() => { - const channelTalk = new ChannelService(); - - channelTalk.boot({ pluginKey: CHANNELIO_PLUGIN_KEY }, () => {}); - - return () => channelTalk.shutdown(); - }, []); - - return