Skip to content

Commit 743ef58

Browse files
authored
Merge pull request #68 from zecrypt-io/feature/shivil/search-command-fixing
Search bar error fixed
2 parents bcefc7b + bbe3f3e commit 743ef58

7 files changed

Lines changed: 320 additions & 252 deletions

File tree

Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
"use client";
2+
3+
import { useEffect } from 'react';
4+
5+
declare global {
6+
interface Window {
7+
Tawk_API?: {
8+
onLoad?: () => void;
9+
onChatMaximized?: () => void;
10+
onChatMinimized?: () => void;
11+
onChatHidden?: () => void;
12+
onChatStarted?: () => void;
13+
onChatEnded?: () => void;
14+
onPrechatSubmit?: (data: any) => void;
15+
onOfflineSubmit?: (data: any) => void;
16+
maximize?: () => void;
17+
minimize?: () => void;
18+
toggle?: () => void;
19+
popup?: () => void;
20+
showWidget?: () => void;
21+
hideWidget?: () => void;
22+
toggleVisibility?: () => void;
23+
endChat?: () => void;
24+
};
25+
Tawk_LoadStart?: Date;
26+
}
27+
}
28+
29+
export function ChatWidget() {
30+
useEffect(() => {
31+
// Initialize Tawk_API
32+
window.Tawk_API = window.Tawk_API || {};
33+
34+
// Set up event handlers
35+
window.Tawk_API.onLoad = function() {
36+
console.log('Tawk.to chat widget loaded');
37+
};
38+
39+
window.Tawk_API.onChatMaximized = function() {
40+
console.log('Chat maximized');
41+
};
42+
43+
window.Tawk_API.onChatMinimized = function() {
44+
console.log('Chat minimized');
45+
};
46+
47+
window.Tawk_API.onChatStarted = function() {
48+
console.log('Chat started');
49+
};
50+
51+
window.Tawk_API.onChatEnded = function() {
52+
console.log('Chat ended');
53+
};
54+
55+
window.Tawk_API.onPrechatSubmit = function(data: any) {
56+
console.log('Pre-chat form submitted:', data);
57+
};
58+
59+
window.Tawk_API.onOfflineSubmit = function(data: any) {
60+
console.log('Offline form submitted:', data);
61+
};
62+
63+
// Load Tawk.to script
64+
const Tawk_LoadStart = new Date();
65+
const s1 = document.createElement("script");
66+
const s0 = document.getElementsByTagName("script")[0];
67+
68+
s1.async = true;
69+
s1.src = 'https://embed.tawk.to/684c069b4b5a53190afc6fb5/1itkfjkm5';
70+
s1.charset = 'UTF-8';
71+
s1.setAttribute('crossorigin', '*');
72+
73+
if (s0?.parentNode) {
74+
s0.parentNode.insertBefore(s1, s0);
75+
}
76+
77+
// Cleanup function
78+
return () => {
79+
s1.remove();
80+
// Reset Tawk_API
81+
window.Tawk_API = {};
82+
};
83+
}, []);
84+
85+
return null;
86+
}

0 commit comments

Comments
 (0)