'use client'; import { useState, useRef, useEffect } from 'react'; import Image from 'next/image'; import { ChatHeader, MessageInput } from './component'; // Custom scrollbar styles const customScrollbarStyles = ` .custom-scrollbar::-webkit-scrollbar { width: 8px; } .custom-scrollbar::-webkit-scrollbar-track { background: transparent; } .custom-scrollbar::-webkit-scrollbar-thumb { background: rgba(0, 41, 61, 0.5); border-radius: 10px; } .custom-scrollbar::-webkit-scrollbar-thumb:hover { background: rgba(0, 41, 61, 0.7); } `; // Mock data for conversations const conversations = [ { id: '1', name: 'Pradeep Ram', avatar: '/assets/icons/user-placeholder-icon.svg', lastMessage: 'Lorem ipsum dolor sit amet, consectetur adipiscing elit.', date: 'Dec 4', isOnline: true, }, { id: '2', name: 'Pradeep', avatar: '/assets/icons/user-placeholder-icon.svg', lastMessage: 'Lorem ipsum dolor sit amet, consectetur adipiscing elit.', date: 'Dec 4', isOnline: true, }, { id: '3', name: 'Gokulraj', avatar: '/assets/icons/user-placeholder-icon.svg', lastMessage: 'Lorem ipsum dolor sit amet, consectetur adipiscing elit.', date: 'Dec 4', isOnline: true, }, { id: '4', name: 'Suriya s', avatar: '/assets/icons/user-placeholder-icon.svg', lastMessage: 'Lorem ipsum dolor sit amet, consectetur adipiscing elit.', date: 'Dec 4', isOnline: true, }, { id: '5', name: 'Sanjay', avatar: '/assets/icons/user-placeholder-icon.svg', lastMessage: 'Lorem ipsum dolor sit amet, consectetur adipiscing elit.', date: 'Dec 4', isOnline: true, }, { id: '6', name: 'Pradeep Ram', avatar: '/assets/icons/user-placeholder-icon.svg', lastMessage: 'Lorem ipsum dolor sit amet, consectetur adipiscing elit.', date: 'Dec 4', isOnline: false, }, { id: '7', name: 'Rahul Kumar', avatar: '/assets/icons/user-placeholder-icon.svg', lastMessage: 'Thanks for your help with the property listing!', date: 'Dec 3', isOnline: true, }, { id: '8', name: 'Anita Singh', avatar: '/assets/icons/user-placeholder-icon.svg', lastMessage: 'Can we schedule a viewing for tomorrow?', date: 'Dec 3', isOnline: false, }, { id: '9', name: 'Vikram Patel', avatar: '/assets/icons/user-placeholder-icon.svg', lastMessage: 'The documents have been submitted.', date: 'Dec 2', isOnline: true, }, { id: '10', name: 'Meera Sharma', avatar: '/assets/icons/user-placeholder-icon.svg', lastMessage: 'Looking forward to our meeting next week.', date: 'Dec 2', isOnline: false, }, { id: '11', name: 'Arjun Reddy', avatar: '/assets/icons/user-placeholder-icon.svg', lastMessage: 'Please send me the property details.', date: 'Dec 1', isOnline: true, }, { id: '12', name: 'Sneha Nair', avatar: '/assets/icons/user-placeholder-icon.svg', lastMessage: 'I have a few questions about the contract.', date: 'Dec 1', isOnline: false, }, ]; // Mock data for selected user const selectedUserData = { name: 'Pradeep Ram', role: 'Advisor', lastSeen: '21h Ago', avatar: '/assets/icons/user-placeholder-icon.svg', isOnline: true, pronouns: 'He/Him', expertise: ['Sales', 'Analytics', 'Inspection', 'Residential', 'Commercial'], }; // Mock messages data const messages = [ { id: '1', senderId: '1', text: 'Hi! I saw your profile and I think you might be a great fit for what I\'m looking for.', timestamp: '10:30 AM', isOwn: false, }, { id: '2', senderId: 'me', text: 'Hello! Thank you for reaching out. I\'d be happy to help. What kind of property are you looking for?', timestamp: '10:32 AM', isOwn: true, }, { id: '3', senderId: '1', text: 'I\'m looking for a residential property in the downtown area. Preferably a 3-bedroom apartment with modern amenities.', timestamp: '10:35 AM', isOwn: false, }, { id: '4', senderId: 'me', text: 'That sounds great! I have several listings that might interest you. Do you have a specific budget range in mind?', timestamp: '10:38 AM', isOwn: true, }, { id: '5', senderId: '1', text: 'My budget is around $500,000 to $700,000. I\'m also interested in properties with good investment potential.', timestamp: '10:40 AM', isOwn: false, }, { id: '6', senderId: 'me', text: 'Perfect! I have a few properties in that range. Would you like to schedule a viewing this weekend?', timestamp: '10:42 AM', isOwn: true, }, { id: '7', senderId: '1', text: 'Yes, that would be great! Saturday afternoon works best for me.', timestamp: '10:45 AM', isOwn: false, }, { id: '8', senderId: 'me', text: 'Saturday at 2 PM works for me. I\'ll send you the addresses and details of the properties we\'ll be visiting.', timestamp: '10:48 AM', isOwn: true, }, { id: '9', senderId: '1', text: 'Sounds perfect! Looking forward to it. Thank you for your quick response.', timestamp: '10:50 AM', isOwn: false, }, { id: '10', senderId: 'me', text: 'You\'re welcome! See you on Saturday. Feel free to reach out if you have any questions before then.', timestamp: '10:52 AM', isOwn: true, }, ]; export default function MessagePage() { const [selectedConversation, setSelectedConversation] = useState('1'); const [searchQuery, setSearchQuery] = useState(''); const [showScrollButton, setShowScrollButton] = useState(false); const messagesContainerRef = useRef(null); const handleSendMessage = (message: string) => { console.log('Sending message:', message); // In production, this would send the message to the API }; const handleScroll = () => { if (messagesContainerRef.current) { const { scrollTop, scrollHeight, clientHeight } = messagesContainerRef.current; // Show button if not at bottom (with 100px threshold) setShowScrollButton(scrollHeight - scrollTop - clientHeight > 100); } }; const scrollToBottom = () => { if (messagesContainerRef.current) { messagesContainerRef.current.scrollTo({ top: messagesContainerRef.current.scrollHeight, behavior: 'smooth' }); } }; useEffect(() => { // Scroll to bottom on initial load scrollToBottom(); }, [selectedConversation]); const filteredConversations = conversations.filter((conv) => conv.name.toLowerCase().includes(searchQuery.toLowerCase()) ); return ( <>
{/* Header */}

Messaging

{/* Search bar */}
Search setSearchQuery(e.target.value)} placeholder="Search Message" className="flex-1 font-serif font-normal text-[18px] leading-[24px] text-[#00293D] placeholder-[#00293D]/50 focus:outline-none" />
{/* Header actions */}
{/* Main content */}
{/* Left sidebar - Conversation list */}
{filteredConversations.map((conversation) => (
setSelectedConversation(conversation.id)} className={`relative flex items-start gap-3 p-4 rounded-[15px] cursor-pointer transition-colors ${ selectedConversation === conversation.id ? 'bg-[#00293d]/5' : 'hover:bg-[#00293d]/5' }`} style={{ border: '1px solid rgba(0, 41, 61, 0.1)' }} > {/* Active indicator line */} {selectedConversation === conversation.id && (
)} {/* Avatar with online indicator */}
{conversation.name}
{conversation.isOnline && (
)}
{/* Content */}

{conversation.name}

{conversation.lastMessage}

{/* Date */}

{conversation.date}

))}
{/* Right panel - Chat area */}
{selectedConversation ? ( <> {/* Chat header */} {/* Messages area wrapper */}
{messages.map((message) => (

{message.text}

{message.timestamp}

))}
{/* Scroll to bottom button - only shows when scrolled up */} {showScrollButton && ( )}
{/* Message input */} ) : (
Select a conversation to start messaging
)}
); }