import { useEffect } from 'react' import { useAuthStore } from '@/store/authStore' import { useChatStore } from '@/store/chatStore' import { socketService } from '@/services/socketService' import ChatSidebar from '@/components/chat/ChatSidebar' import ChatWindow from '@/components/chat/ChatWindow' import { Separator } from '@/components/ui/separator' export default function ChatPage() { const { user, token } = useAuthStore() const { loadChats, currentChat } = useChatStore() useEffect(() => { if (token && user) { // Connect to socket socketService.connect(token).then(() => { console.log('Socket connected successfully') }).catch((error) => { console.error('Socket connection failed:', error) }) // Load initial data loadChats() // Cleanup on unmount return () => { socketService.disconnect() } } }, [token, user, loadChats]) return (
Select a chat to start messaging