From ee2b4806431597bb216ee8def301ff5db3d600ce Mon Sep 17 00:00:00 2001 From: parkyejin Date: Fri, 9 Aug 2024 01:24:46 +0900 Subject: [PATCH] fix: vercel deploy error --- src/app/board/page.tsx | 4 +- src/app/chatting/page.tsx | 152 +++++++++++++--------------- src/components/home/HotBoardBox.tsx | 2 +- 3 files changed, 74 insertions(+), 84 deletions(-) diff --git a/src/app/board/page.tsx b/src/app/board/page.tsx index 4d54149..55b167c 100644 --- a/src/app/board/page.tsx +++ b/src/app/board/page.tsx @@ -9,9 +9,9 @@ import { useState } from 'react' const BoardPage = () => { const [mbti, setMbti] = useState('all') - const [page, setPage] = useState(0) + // const [page, setPage] = useState(0) - const { data } = useBoardList(mbti, page, 6) + const { data } = useBoardList(mbti, 0, 6) return ( <> diff --git a/src/app/chatting/page.tsx b/src/app/chatting/page.tsx index a72ca93..c91817f 100644 --- a/src/app/chatting/page.tsx +++ b/src/app/chatting/page.tsx @@ -1,88 +1,78 @@ 'use client' -import React, { useState, useEffect, useRef } from 'react' - const Chatting = () => { - const chatRoomId = 1 - const member = 1 - const [messages, setMessages] = useState([]) - const [input, setInput] = useState('') - const [isConnected, setIsConnected] = useState(false) - const socketRef = useRef(null) - - useEffect(() => { - const socket = new WebSocket( - `wss://lc3cc1cnma.execute-api.ap-northeast-2.amazonaws.com/mssaem?chatRoomId=${chatRoomId}&member=${member}`, - ) - - socket.onopen = () => { - console.log('WebSocket Opened') - setIsConnected(true) - } - - socket.onmessage = (event: MessageEvent) => { - console.log('WebSocket Message:', event.data) - setMessages((prev) => [...prev, event.data]) - } - - socket.onerror = (error: Event) => { - console.error('WebSocket Error:', error) - } - - socket.onclose = () => { - console.log('WebSocket is closed') - setIsConnected(false) - } - - socketRef.current = socket - - return () => { - socket.close() - } - }, [chatRoomId, member]) - - const sendMessage = () => { - if (socketRef.current && input.trim() !== '') { - const message = { - action: 'sendMessage', - chatRoomId: 1, - message: input, - } - socketRef.current.send(JSON.stringify(message)) - setInput('') - } - } - - const disconnect = () => { - if (socketRef.current) { - socketRef.current.close() - socketRef.current = null - setIsConnected(false) - } - } + // const chatRoomId = 1 + // const member = 1 + // const [messages, setMessages] = useState([]) + // const [input, setInput] = useState('') + // const [isConnected, setIsConnected] = useState(false) + // const socketRef = useRef(null) + // useEffect(() => { + // const socket = new WebSocket( + // `wss://lc3cc1cnma.execute-api.ap-northeast-2.amazonaws.com/mssaem?chatRoomId=${chatRoomId}&member=${member}`, + // ) + // socket.onopen = () => { + // console.log('WebSocket Opened') + // setIsConnected(true) + // } + // socket.onmessage = (event: MessageEvent) => { + // console.log('WebSocket Message:', event.data) + // setMessages((prev) => [...prev, event.data]) + // } + // socket.onerror = (error: Event) => { + // console.error('WebSocket Error:', error) + // } + // socket.onclose = () => { + // console.log('WebSocket is closed') + // setIsConnected(false) + // } + // socketRef.current = socket + // return () => { + // socket.close() + // } + // }, [chatRoomId, member]) + // const sendMessage = () => { + // if (socketRef.current && input.trim() !== '') { + // const message = { + // action: 'sendMessage', + // chatRoomId: 1, + // message: input, + // } + // socketRef.current.send(JSON.stringify(message)) + // setInput('') + // } + // } + // const disconnect = () => { + // if (socketRef.current) { + // socketRef.current.close() + // socketRef.current = null + // setIsConnected(false) + // } + // } + // return ( + //
+ //

Chatting

+ //
+ // {messages.map((msg, index) => ( + //
{msg}
+ // ))} + //
+ // setInput(e.target.value)} + // onKeyPress={(e) => { + // if (e.key === 'Enter') { + // sendMessage() + // } + // }} + // /> + // {/* + // {isConnected && } */} + //
+ // ) - return ( -
-

Chatting

-
- {messages.map((msg, index) => ( -
{msg}
- ))} -
- setInput(e.target.value)} - onKeyPress={(e) => { - if (e.key === 'Enter') { - sendMessage() - } - }} - /> - - {isConnected && } -
- ) + return
test
} export default Chatting diff --git a/src/components/home/HotBoardBox.tsx b/src/components/home/HotBoardBox.tsx index 2fe2555..6f61576 100644 --- a/src/components/home/HotBoardBox.tsx +++ b/src/components/home/HotBoardBox.tsx @@ -20,7 +20,7 @@ const HotBoardBox = () => { {data && ( <> {data.map((board) => ( - + ))} )}