import { useState, useRef, useEffect } from 'react' import { Send } from 'lucide-react' import { ChatBubble } from './ChatBubble' export function ChatWindow({ messages, onSend }) { const [text, setText] = useState('') const bottomRef = useRef(null) useEffect(() => { bottomRef.current?.scrollIntoView({ behavior: 'smooth' }) }, [messages]) const handleSend = () => { if (!text.trim()) return onSend?.(text) setText('') } return (
{messages?.map((msg, i) => ( ))}
setText(e.target.value)} onKeyDown={(e) => e.key === 'Enter' && handleSend()} placeholder="اكتب رسالة..." className="flex-1 rounded-xl border border-gray-300 px-4 py-2.5 text-sm focus:outline-none focus:border-brand-500" />
) }