Skip to content

Commit

Permalink
Merge pull request #132 from yura0302/develop
Browse files Browse the repository at this point in the history
fix : 채팅 로직 수정
  • Loading branch information
yura0302 authored May 23, 2024
2 parents 116a2e4 + b76b6df commit 16413db
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 19 deletions.
4 changes: 1 addition & 3 deletions src/components/ChatContainer/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,7 @@ const ChatContainer = ({ chatList, setChatList }: IChatContainer) => {
fetchUserId();
}, []);

useEffect(() => {

}, [chatList]);
useEffect(() => {}, [chatList]);

const formatDate = (date: string) => moment(date).format('YYYY년 MM월 DD일');

Expand Down
50 changes: 34 additions & 16 deletions src/pages/ItemDetail/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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 <Loading />;
console.log(productId);
Expand Down Expand Up @@ -187,7 +205,7 @@ const ItemDetail: React.FC = () => {
</S.ButtonsBox>
<S.ChatButton
onClick={() => {
goToChat();
handleChat();
}}
>
채팅하기
Expand Down
1 change: 1 addition & 0 deletions src/pages/WritePost/styles.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 16413db

Please sign in to comment.