import React, { useState, useEffect, useRef } from 'react';
import { Head, Link, router } from '@inertiajs/react';
import EmployerLayout from '../../../Layouts/EmployerLayout';
import {
Send,
ArrowLeft,
CheckCircle2,
Globe2,
DollarSign,
Sparkles,
MoreVertical,
Phone,
Video,
Paperclip,
Search,
Info,
Calendar,
Briefcase,
ShieldCheck,
ChevronRight,
MapPin,
Smile
} from 'lucide-react';
export default function Show({ conversation, initialMessages, conversations = [] }) {
const [messages, setMessages] = useState(initialMessages || []);
const [input, setInput] = useState('');
const [isTyping, setIsTyping] = useState(false);
const [searchTerm, setSearchTerm] = useState('');
const [showProfile, setShowProfile] = useState(false);
const messagesEndRef = useRef(null);
const scrollToBottom = () => {
messagesEndRef.current?.scrollIntoView({ behavior: "smooth" });
};
useEffect(() => {
scrollToBottom();
}, [messages, isTyping]);
useEffect(() => {
setMessages(initialMessages || []);
}, [initialMessages]);
const filteredConversations = (conversations || []).filter(c =>
c.worker_name.toLowerCase().includes(searchTerm.toLowerCase())
);
const sendMsg = (text) => {
if (!text.trim()) return;
router.post(`/employer/messages/${conversation.id}/send`, {
text: text
}, {
preserveScroll: true,
onSuccess: () => {
setInput('');
}
});
};
const handleFormSubmit = (e) => {
e.preventDefault();
sendMsg(input);
};
const chips = [
"Are you available for a video interview today?",
"What is your final expected salary?",
"Can you transfer your visa immediately?"
];
return (