From b76b6df7404c288ca4a7ae48967eff7b563ab93a Mon Sep 17 00:00:00 2001 From: yura Date: Thu, 23 May 2024 23:11:10 +0900 Subject: [PATCH] =?UTF-8?q?fix=20:=20=EC=B1=84=ED=8C=85=20=EB=A1=9C?= =?UTF-8?q?=EC=A7=81=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/ChatContainer/index.tsx | 4 +-- src/pages/ItemDetail/index.tsx | 50 +++++++++++++++++--------- src/pages/WritePost/styles.tsx | 1 + 3 files changed, 36 insertions(+), 19 deletions(-) diff --git a/src/components/ChatContainer/index.tsx b/src/components/ChatContainer/index.tsx index 120ced09..f03d739e 100644 --- a/src/components/ChatContainer/index.tsx +++ b/src/components/ChatContainer/index.tsx @@ -32,9 +32,7 @@ const ChatContainer = ({ chatList, setChatList }: IChatContainer) => { fetchUserId(); }, []); - useEffect(() => { - - }, [chatList]); + useEffect(() => {}, [chatList]); const formatDate = (date: string) => moment(date).format('YYYY년 MM월 DD일'); diff --git a/src/pages/ItemDetail/index.tsx b/src/pages/ItemDetail/index.tsx index cadeef96..0db09463 100644 --- a/src/pages/ItemDetail/index.tsx +++ b/src/pages/ItemDetail/index.tsx @@ -109,24 +109,42 @@ const ItemDetail: React.FC = () => { } }; - const goToChat = async () => { - const response = await restFetcher({ - method: 'POST', - path: `/chat/create/${parsedProductId}`, - }); - console.log(response.data); - navigate(`/chat/${response.data.chatRoomId}`); - }; - // const chatPath = `/chat/create/${parsedProductId}`; - // restFetcher({ + // const goToChat = async () => { + // const response = await restFetcher({ // method: 'POST', - // path: chatPath, - // }); - // navigate(chatPath, { - // // state: { productId }, + // path: `/chat/create/${parsedProductId}`, // }); + // console.log(response.data); + // console.log(parsedProductId); + // navigate(`/chat/${response.data.chatRoomId}`); // }; - // console.log(parsedProductId); + // // const chatPath = `/chat/create/${parsedProductId}`; + // // restFetcher({ + // // method: 'POST', + // // path: chatPath, + // // }); + // // navigate(chatPath, { + // // // state: { productId }, + // // }); + // // }; + // // console.log(parsedProductId); + const handleChat = async () => { + try { + const response = await restFetcher({ + method: 'POST', + path: `/chat/create/${parsedProductId}`, + params: { chatRoomId: 0 }, + }); + const { chatRoomId, productInfo, chatInfoList } = response.data; + navigate(`/chat/${chatRoomId}`), + { + state: { chatRoomId, productInfo, chatInfoList }, + }; + } catch (err) { + console.log(err); + } + }; + console.log(parsedProductId); if (isLoading) return ; console.log(productId); @@ -187,7 +205,7 @@ const ItemDetail: React.FC = () => { { - goToChat(); + handleChat(); }} > 채팅하기 diff --git a/src/pages/WritePost/styles.tsx b/src/pages/WritePost/styles.tsx index 90bf2199..435767cf 100644 --- a/src/pages/WritePost/styles.tsx +++ b/src/pages/WritePost/styles.tsx @@ -199,6 +199,7 @@ export const TextArea = styled.textarea` font-size: 2rem; padding: 2rem 1.5rem 0 2rem; outline: none; + white-space: pre; &:focus { border-color: orange;