feat: user registration and chat messaging (wip)
This commit is contained in:
parent
b0ce2fe0af
commit
18dd8b83f0
14 changed files with 243 additions and 33 deletions
36
client/src/components/ChatInput.tsx
Normal file
36
client/src/components/ChatInput.tsx
Normal file
|
|
@ -0,0 +1,36 @@
|
|||
import React, { useState } from "react";
|
||||
|
||||
interface ChatInputProps {
|
||||
onSendMessage: (content: string) => void;
|
||||
}
|
||||
|
||||
function ChatInput({ onSendMessage }: ChatInputProps) {
|
||||
const [message, setMessage] = useState("");
|
||||
|
||||
function handleSubmit(e: React.FormEvent) {
|
||||
e.preventDefault();
|
||||
if (!message.trim()) return;
|
||||
|
||||
onSendMessage(message);
|
||||
setMessage("");
|
||||
}
|
||||
|
||||
return (
|
||||
<form onSubmit={handleSubmit} className="mt-4">
|
||||
<div className="flex gap-2">
|
||||
<input
|
||||
type="text"
|
||||
value={message}
|
||||
onChange={(e) => setMessage(e.target.value)}
|
||||
placeholder="Type a message..."
|
||||
className="flex-1 px-3 py-2 border border-gray-300 rounded-md shadow-sm placeholder-gray-400 focus:outline-none focus:ring-2 focus:ring-blue-500 focus:border-blue-500"
|
||||
/>
|
||||
<button type="submit" disabled={!message.trim()} className="btn">
|
||||
Send
|
||||
</button>
|
||||
</div>
|
||||
</form>
|
||||
);
|
||||
}
|
||||
|
||||
export default React.memo(ChatInput);
|
||||
Loading…
Add table
Add a link
Reference in a new issue