blob: 4746b778d04c53b49b8f7a0ca52acf8929ff1099 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
|
import React, { useEffect } from 'react';
const ChatwootLoader = () => {
useEffect(() => {
const loadChatwoot = () => {
const BASE_URL = "https://chat.g-r-l.com";
const script = document.createElement('script');
script.src = `${BASE_URL}/packs/js/sdk.js`;
script.defer = true;
script.async = true;
script.onload = () => {
if (window.chatwootSDK) {
window.chatwootSDK.run({
websiteToken: 'dEEw3fcexQvnQ5tesJPKFjSb',
baseUrl: BASE_URL,
});
}
};
document.body.appendChild(script);
};
loadChatwoot();
// Clean up script when the component unmounts
return () => {
const existingScript = document.querySelector(`script[src="https://app.chatwoot.com/packs/js/sdk.js"]`);
if (existingScript) {
document.body.removeChild(existingScript);
}
};
}, []);
return null;
};
export {ChatwootLoader};
|