Skip to content

Commit

Permalink
add chat input component
Browse files Browse the repository at this point in the history
  • Loading branch information
deveshidwivedi committed Jun 27, 2024
1 parent 552516d commit 4494bc7
Showing 1 changed file with 27 additions and 0 deletions.
27 changes: 27 additions & 0 deletions modules/room/components/chat/ChatInput.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import {socket} from "@/common/lib/socket";
import {FormEvent, useState} from "react";
import { AiOutlineSend } from "react-icons/ai";

const ChatInput = () => {
const [msg, setMsg] = useState("");
const handleSubmit= (e: FormEvent<HTMLFormElement>)=> {
e.preventDefault();
socket.emit("send_msg", msg);
setMsg("");
};
return (
<form className="flex w-full items-center gap-2" onSubmit={handleSubmit}
>
<input
className="w-full rounded-xl border border-zinc-300 p-5 py-1"
value={msg}
onChange={(e)=> setMsg(e.target.value)}
/>
<button className="h-full w-10 bg-black" type="submit">
<AiOutlineSend />
</button>
</form>
);
};

export default ChatInput;

0 comments on commit 4494bc7

Please sign in to comment.