/ components / ChatInput.jsx
ChatInput.jsx
1 "use client" 2 3 import { useState } from "react" 4 5 export default function ChatInput({ onSend }) { 6 const [message, setMessage] = useState("") 7 8 const handleSubmit = e => { 9 e.preventDefault() 10 if (message.trim()) { 11 onSend(message) 12 setMessage("") 13 } 14 } 15 16 return ( 17 <form 18 onSubmit={handleSubmit} 19 className="flex items-center px-4 py-2 bg-gray-100" 20 > 21 <input 22 type="text" 23 value={message} 24 onChange={e => setMessage(e.target.value)} 25 placeholder="Type your message..." 26 className="flex-grow px-4 py-2 rounded-md" 27 /> 28 <button 29 type="submit" 30 className="px-4 py-2 ml-2 text-white bg-blue-500 rounded-md hover:bg-blue-600" 31 > 32 Send 33 </button> 34 </form> 35 ) 36 }