feat: add Intelliticks chat widget

This commit is contained in:
Alvalen 2023-09-29 10:21:02 +07:00
parent a1c0ba2e51
commit 294ae759b4
3 changed files with 38 additions and 1 deletions

View file

@ -40,6 +40,8 @@ export const metadata = {
},
};
import Chat from "@/components/Chat";
const TopProgressBar = dynamic(() => import("@/components/TopProgressbar"), {
ssr: false,
});
@ -54,6 +56,7 @@ export default function RootLayout({ children }) {
<TopProgressBar />
<Navbar />
{children}
<Chat />
</body>
</html>
);

View file

@ -7,7 +7,6 @@ export const metadata = {
export default function Layout({ children }) {
return (
<>
{children}
<Footer />
</>

35
components/Chat.jsx Normal file
View file

@ -0,0 +1,35 @@
// components/Intelliticks.js
"use client"
import { useEffect } from "react";
// Component for Intelliticks chat widget
const Chat = () => {
useEffect(() => {
// Paste the Intelliticks script here
(function (I, L, T, i, c, k, s) {
if (I.iticks) return;
I.iticks = { host: c, settings: s, clientId: k, cdn: L, queue: [] };
var h = T.head || T.documentElement;
var e = T.createElement(i);
var l = I.location;
e.async = true;
e.src = (L || c) + "/client/inject-v2.min.js";
h.insertBefore(e, h.firstChild);
I.iticks.call = function (a, b) {
I.iticks.queue.push([a, b]);
};
})(
window,
"https://cdn-v1.intelliticks.com/prod/common",
document,
"script",
"https://app.intelliticks.com",
"u3cWw3sDpdKexqXCY_c",
{}
);
}, []);
return null;
};
export default Chat;