11import { useRef , useState } from "react" ;
2+ import { useSendMessage } from "@/hooks/useSendMessage" ;
3+ import { useRoomStore } from "@/app/store/roomStore" ;
4+ import { useGetUsername } from "@/hooks/useGetUsername" ;
25
36export const RoomInput = ( ) => {
7+ const { sendMessage, isPending } = useSendMessage ( ) ;
48 const [ input , setInput ] = useState ( "" ) ;
59 const inputRef = useRef < HTMLInputElement > ( null ) ;
10+ const roomId = useRoomStore ( ( state ) => state . roomId ) ;
11+ const { username } = useGetUsername ( ) ;
612
7- const sendMessage = ( message : { text : string } ) => {
8- // TODO: Implement send message
9- } ;
1013 return (
1114 < div className = "border-t border-zinc-800 bg-zinc-900/30 p-4" >
1215 < div className = "flex gap-4" >
@@ -20,7 +23,7 @@ export const RoomInput = () => {
2023 value = { input }
2124 onKeyDown = { ( e ) => {
2225 if ( e . key === "Enter" && input . trim ( ) ) {
23- sendMessage ( { text : input } ) ;
26+ sendMessage ( { text : input , roomId , username } ) ;
2427 inputRef . current ?. focus ( ) ;
2528 }
2629 } }
@@ -32,7 +35,7 @@ export const RoomInput = () => {
3235
3336 < button
3437 onClick = { ( ) => {
35- sendMessage ( { text : input } ) ;
38+ sendMessage ( { text : input , roomId , username } ) ;
3639 inputRef . current ?. focus ( ) ;
3740 } }
3841 disabled = { ! input . trim ( ) }
0 commit comments