import React, { useState, useEffect, useRef } from 'react';
import { Head, Link } 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]);
const filteredConversations = (conversations || []).filter(c =>
c.worker_name.toLowerCase().includes(searchTerm.toLowerCase())
);
const sendMsg = (text) => {
if (!text.trim()) return;
const newMsg = {
id: Date.now(),
sender: 'employer',
text: text,
time: new Date().toLocaleTimeString([], { hour: '2-digit', minute: '2-digit' }),
};
setMessages(prev => [...prev, newMsg]);
setInput('');
setIsTyping(true);
setTimeout(() => {
setIsTyping(false);
setMessages(prev => [...prev, {
id: Date.now() + 1,
sender: 'worker',
text: "Thank you for the message ma'am! I confirm I have received your request and look forward to speaking with you.",
time: new Date().toLocaleTimeString([], { hour: '2-digit', minute: '2-digit' }),
}]);
}, 1500 + Math.random() * 1000);
};
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 (