diff --git a/src/components/form/FormMessage.tsx b/src/components/form/FormMessage.tsx index 35de198..9ab0e3f 100644 --- a/src/components/form/FormMessage.tsx +++ b/src/components/form/FormMessage.tsx @@ -1,8 +1,6 @@ import {Button, Flex, Input} from '@chakra-ui/react'; import {useState} from 'react'; import {User} from '@prisma/client'; -import {io, Socket} from 'socket.io-client'; -import Message from '@/components/chat/Message'; type Props = { user: User, @@ -15,19 +13,7 @@ export default function FormMessage(props: Props) { const [text, setText] = useState(""); const handleSubmit = () => { - if (text !== "") { - socket.emit("createdMessage", {text, sender: user.id}) - - // fetch("/api/messages", { - // method: "POST", - // headers: {'Content-Type': 'application/json'}, - // body: JSON.stringify({ - // text, - // 'User': {"connect": {'id': user.id}}, - // 'Chat': {"connect": {'id': chatId}} - // }) - // }).then(res => res.json()).then(res => console.log(res)).catch(err => console.error(err)) - } + if (text) socket.emit("createdMessage", {text, sender: user.id}) } return (