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;