From 23fb3ee27ee3e242fac10664d4c400faca0d4da8 Mon Sep 17 00:00:00 2001 From: Sungu Kim <108677235+haegu97@users.noreply.github.com> Date: Sun, 5 Jan 2025 17:29:03 +0900 Subject: [PATCH 1/7] =?UTF-8?q?=EB=A9=94=EC=8B=9C=EC=A7=80=20=EC=9E=85?= =?UTF-8?q?=EB=A0=A5=20input=20=ED=95=98=EB=8B=A8=EC=97=90=20=EA=B3=A0?= =?UTF-8?q?=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/app/chat/[id]/page.tsx | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/app/chat/[id]/page.tsx b/src/app/chat/[id]/page.tsx index f3d7d151..940f664f 100644 --- a/src/app/chat/[id]/page.tsx +++ b/src/app/chat/[id]/page.tsx @@ -181,7 +181,7 @@ function ChatRoomPage() { }; return ( -
+
@@ -192,7 +192,7 @@ function ChatRoomPage() { className="bg-gray-light-02" />

채팅

- +
{}} />
-
+
From 0c18142ef0490d810f379c56fe0484b9c171f27f Mon Sep 17 00:00:00 2001 From: Sungu Kim <108677235+haegu97@users.noreply.github.com> Date: Sun, 5 Jan 2025 18:37:15 +0900 Subject: [PATCH 2/7] =?UTF-8?q?=EC=B5=9C=EC=A2=85=20=EB=B0=9C=ED=91=9C=20?= =?UTF-8?q?=EC=A0=84=20=EB=A6=AC=ED=8E=99=ED=86=A0=EB=A7=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/app/chat/[id]/page.tsx | 2 +- src/constants/navigation.ts | 2 +- src/features/bookclub/components/BookClubMainPage.tsx | 1 + src/features/bookclub/components/ClubListSection.tsx | 2 +- .../components/chat-bubble/components/OpponentBubble.tsx | 6 +++--- .../components/chat-bubble/components/atoms/atoms.tsx | 5 +++-- src/features/chat-room/types/chatBubbleList.ts | 1 + src/features/chat/components/chat-card/ChatCard.tsx | 4 ++-- .../chat/components/chat-card/types/variantChatCard.ts | 3 ++- src/features/chat/container/BookClubChatContainer.tsx | 4 ++++ src/features/profile/container/JoinedClubList.tsx | 5 ++++- src/features/profile/container/MyJoinedClubList.tsx | 5 ++++- 12 files changed, 27 insertions(+), 13 deletions(-) diff --git a/src/app/chat/[id]/page.tsx b/src/app/chat/[id]/page.tsx index 940f664f..fc884556 100644 --- a/src/app/chat/[id]/page.tsx +++ b/src/app/chat/[id]/page.tsx @@ -192,7 +192,7 @@ function ChatRoomPage() { className="bg-gray-light-02" />

채팅

- +
void; isConsecutive?: boolean; @@ -14,7 +14,7 @@ function OpponentBubble({ content, time, name, - profileImage, + image, isHost, onProfileClick, isConsecutive, @@ -25,7 +25,7 @@ function OpponentBubble({ {!isConsecutive && ( diff --git a/src/features/chat-room/components/chat-bubble/components/atoms/atoms.tsx b/src/features/chat-room/components/chat-bubble/components/atoms/atoms.tsx index f8a3a1b9..557394ac 100644 --- a/src/features/chat-room/components/chat-bubble/components/atoms/atoms.tsx +++ b/src/features/chat-room/components/chat-bubble/components/atoms/atoms.tsx @@ -80,12 +80,13 @@ export function ChatBubbleTime({ interface ChatBubbleProfileProps extends HTMLAttributes { name: string; - imageUrl: string; + image?: string; isHost?: boolean; } export function ChatBubbleProfile({ name, + image, isHost, className, onClick, @@ -98,7 +99,7 @@ export function ChatBubbleProfile({ onClick={onClick} data-testid="profile-image" > - + {isHost && (
diff --git a/src/features/chat-room/types/chatBubbleList.ts b/src/features/chat-room/types/chatBubbleList.ts index e5178116..7710f91c 100644 --- a/src/features/chat-room/types/chatBubbleList.ts +++ b/src/features/chat-room/types/chatBubbleList.ts @@ -9,6 +9,7 @@ export interface ChatMessageType extends BaseMessage { userNickname: string; userId: number; content: string; + image?: string; } export interface SystemMessageType extends BaseMessage { diff --git a/src/features/chat/components/chat-card/ChatCard.tsx b/src/features/chat/components/chat-card/ChatCard.tsx index 4d20f415..804b245b 100644 --- a/src/features/chat/components/chat-card/ChatCard.tsx +++ b/src/features/chat/components/chat-card/ChatCard.tsx @@ -185,7 +185,7 @@ function ChatCard({ imageUrl, isHost, title, - currentParticipants, + memberCount, lastMessage, lastMessageTime, unreadCount, @@ -202,7 +202,7 @@ function ChatCard({
{title} - +
{unreadCount && unreadCount > 0 && ( <> diff --git a/src/features/chat/components/chat-card/types/variantChatCard.ts b/src/features/chat/components/chat-card/types/variantChatCard.ts index f80e7de0..c85f7f1d 100644 --- a/src/features/chat/components/chat-card/types/variantChatCard.ts +++ b/src/features/chat/components/chat-card/types/variantChatCard.ts @@ -8,10 +8,11 @@ interface CommonProps extends React.HTMLAttributes { } export interface BookClubProps extends CommonProps { - currentParticipants: number; + memberCount: number; lastMessage?: string; lastMessageTime?: string; unreadCount?: number; + hostId: number; } export interface ChatRoomHeaderProps extends CommonProps { diff --git a/src/features/chat/container/BookClubChatContainer.tsx b/src/features/chat/container/BookClubChatContainer.tsx index 66e7cb2b..b2d25b73 100644 --- a/src/features/chat/container/BookClubChatContainer.tsx +++ b/src/features/chat/container/BookClubChatContainer.tsx @@ -9,6 +9,7 @@ import Link from 'next/link'; import { getRecentChats, getStompClient } from '@/features/chat/utils/socket'; import { findRecentMessage } from '@/features/chat/utils/chatRoom'; import { formatDateForUI } from '@/lib/utils/formatDateForUI'; +import { useAuthStore } from '@/store/authStore'; export default function BookClubChatContainer() { const [recentMessages, setRecentMessages] = useState< @@ -23,6 +24,8 @@ export default function BookClubChatContainer() { bookClubs.my()._ctx.joined({ order: 'DESC', page: 1, size: 10 }), ); + const { user } = useAuthStore(); + useEffect(() => { const fetchRecentChats = async () => { try { @@ -63,6 +66,7 @@ export default function BookClubChatContainer() { variant="bookClub" props={{ ...bookClub, + isHost: user?.id === bookClub.hostId, lastMessage: recentMessage?.content || '', lastMessageTime: recentMessage?.date ? formatDateForUI(recentMessage.date, 'CHAT_ROOM') diff --git a/src/features/profile/container/JoinedClubList.tsx b/src/features/profile/container/JoinedClubList.tsx index 066e4c28..c06ec317 100644 --- a/src/features/profile/container/JoinedClubList.tsx +++ b/src/features/profile/container/JoinedClubList.tsx @@ -57,7 +57,10 @@ export default function JoinedClubList({ order }: ClubListProps) {
) : ( JoinedList?.filter( - (bookClub) => !bookClub.isInactive && bookClub.hostId !== user.id, + (bookClub) => + !bookClub.isInactive && + bookClub.hostId !== user.id && + bookClub.isJoined === true, )?.map((bookClub) => (
) : ( myJoinedList - ?.filter((bookClub) => bookClub.hostId !== user?.id) + ?.filter( + (bookClub) => + bookClub.hostId !== user?.id && bookClub.isJoined === true, + ) ?.map((bookClub) => (
Date: Sun, 5 Jan 2025 18:41:20 +0900 Subject: [PATCH 3/7] =?UTF-8?q?=EC=B5=9C=EC=A2=85=20=EB=B0=9C=ED=91=9C=20?= =?UTF-8?q?=EC=A0=84=20=EB=A6=AC=ED=8E=99=ED=86=A0=EB=A7=812?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/app/chat/[id]/page.tsx | 2 +- src/features/chat/container/BookClubChatContainer.tsx | 2 +- src/features/chat/utils/socket.ts | 5 +++-- src/features/club-details/components/ReviewSection.tsx | 2 +- src/features/club-wish/mocks/wishPageMockData.ts | 2 +- src/features/profile/container/CreatedClubList.tsx | 2 +- src/features/profile/container/JoinedClubList.tsx | 2 +- src/features/profile/container/MyCreatedClubList.tsx | 2 +- src/features/profile/container/MyJoinedClubList.tsx | 2 +- src/features/profile/container/MyWrittenReviewList.tsx | 2 +- src/features/profile/container/WrittenReviewList.tsx | 2 +- src/lib/constants/filters.ts | 2 +- 12 files changed, 14 insertions(+), 13 deletions(-) diff --git a/src/app/chat/[id]/page.tsx b/src/app/chat/[id]/page.tsx index fc884556..5f1bc9d9 100644 --- a/src/app/chat/[id]/page.tsx +++ b/src/app/chat/[id]/page.tsx @@ -39,7 +39,7 @@ function ChatRoomPage() { const [isConnected, setIsConnected] = useState(false); const { data } = useQuery( - bookClubs.my()._ctx.joined({ order: 'DESC', page: 1, size: 10 }), + bookClubs.my()._ctx.joined({ order: 'DESC', page: 1, size: 100 }), ); const bookClubDetail = data?.bookClubs?.find( diff --git a/src/features/chat/container/BookClubChatContainer.tsx b/src/features/chat/container/BookClubChatContainer.tsx index b2d25b73..c75bb051 100644 --- a/src/features/chat/container/BookClubChatContainer.tsx +++ b/src/features/chat/container/BookClubChatContainer.tsx @@ -21,7 +21,7 @@ export default function BookClubChatContainer() { >([]); const { data, isLoading, error } = useQuery( - bookClubs.my()._ctx.joined({ order: 'DESC', page: 1, size: 10 }), + bookClubs.my()._ctx.joined({ order: 'DESC', page: 1, size: 100 }), ); const { user } = useAuthStore(); diff --git a/src/features/chat/utils/socket.ts b/src/features/chat/utils/socket.ts index de1d5cb4..87ca018b 100644 --- a/src/features/chat/utils/socket.ts +++ b/src/features/chat/utils/socket.ts @@ -13,7 +13,8 @@ export interface ChatMessage { userNickname: string; type: 'CHAT' | 'JOIN' | 'LEAVE'; content: string; - user?: string; + user: string; + image?: string; } export interface HistoryResponse { @@ -35,7 +36,7 @@ export const initializeSocket = async (token: string) => { const response = await apiClient.get('/book-clubs/my-joined', { params: { order: 'DESC', - size: 10, + size: 100, page: 1, }, }); diff --git a/src/features/club-details/components/ReviewSection.tsx b/src/features/club-details/components/ReviewSection.tsx index 6d4dad53..43f8378b 100644 --- a/src/features/club-details/components/ReviewSection.tsx +++ b/src/features/club-details/components/ReviewSection.tsx @@ -10,7 +10,7 @@ function ReviewSection({ idAsNumber }: { idAsNumber: number }) { const [filters, setFilters] = useState({ order: 'DESC', page: 1, - size: 10, + size: 100, }); const { data, isLoading, error } = useQuery({ diff --git a/src/features/club-wish/mocks/wishPageMockData.ts b/src/features/club-wish/mocks/wishPageMockData.ts index 3ce8c944..a586ee0e 100644 --- a/src/features/club-wish/mocks/wishPageMockData.ts +++ b/src/features/club-wish/mocks/wishPageMockData.ts @@ -5,6 +5,6 @@ export const filters: BookClubParams = { meetingType: 'ALL', order: 'DESC', page: 1, - size: 10, + size: 100, searchKeyword: '', }; diff --git a/src/features/profile/container/CreatedClubList.tsx b/src/features/profile/container/CreatedClubList.tsx index 9300ba39..d71db2e1 100644 --- a/src/features/profile/container/CreatedClubList.tsx +++ b/src/features/profile/container/CreatedClubList.tsx @@ -19,7 +19,7 @@ export default function CreatedClubList({ order }: ClubListProps) { const defaultClubImage = '/images/defaultBookClub.jpg'; const { data, isLoading, error } = useQuery( - bookClubs.user(user?.id)._ctx.created({ order, page: 1, size: 10 }), + bookClubs.user(user?.id)._ctx.created({ order, page: 1, size: 100 }), ); const { onConfirmUnLike } = useUnLikeClub(); diff --git a/src/features/profile/container/JoinedClubList.tsx b/src/features/profile/container/JoinedClubList.tsx index c06ec317..6200773c 100644 --- a/src/features/profile/container/JoinedClubList.tsx +++ b/src/features/profile/container/JoinedClubList.tsx @@ -21,7 +21,7 @@ export default function JoinedClubList({ order }: ClubListProps) { const defaultClubImage = '/images/defaultBookClub.jpg'; const { data, isLoading, error } = useQuery( - bookClubs.user(user?.id)._ctx.joined({ order, page: 1, size: 10 }), + bookClubs.user(user?.id)._ctx.joined({ order, page: 1, size: 100 }), ); const { onConfirmUnLike } = useUnLikeClub(); diff --git a/src/features/profile/container/MyCreatedClubList.tsx b/src/features/profile/container/MyCreatedClubList.tsx index b5564797..995e0f81 100644 --- a/src/features/profile/container/MyCreatedClubList.tsx +++ b/src/features/profile/container/MyCreatedClubList.tsx @@ -21,7 +21,7 @@ export default function MyCreatedClubList({ order }: ClubListProps) { useCancelClub(); const { data, isLoading, error } = useQuery( - bookClubs.my()._ctx.created({ order, page: 1, size: 10 }), + bookClubs.my()._ctx.created({ order, page: 1, size: 100 }), ); const myCreatedList: BookClub[] = data?.bookClubs || []; diff --git a/src/features/profile/container/MyJoinedClubList.tsx b/src/features/profile/container/MyJoinedClubList.tsx index 1aa277b6..6176b401 100644 --- a/src/features/profile/container/MyJoinedClubList.tsx +++ b/src/features/profile/container/MyJoinedClubList.tsx @@ -32,7 +32,7 @@ export default function MyJoinedClubList({ order }: ClubListProps) { const today = new Date(); const defaultClubImage = '/images/defaultBookClub.jpg'; const { data, isLoading, error } = useQuery( - bookClubs.my()._ctx.joined({ order, page: 1, size: 10 }), + bookClubs.my()._ctx.joined({ order, page: 1, size: 100 }), ); const { mutateAsync: leaveClub } = useLeaveBookClub(); diff --git a/src/features/profile/container/MyWrittenReviewList.tsx b/src/features/profile/container/MyWrittenReviewList.tsx index b7faf989..80fce149 100644 --- a/src/features/profile/container/MyWrittenReviewList.tsx +++ b/src/features/profile/container/MyWrittenReviewList.tsx @@ -10,7 +10,7 @@ import ProfileWrittenReview from '../components/clubs/ProfileWrittenReview'; export default function MyWrittenReviewList({ order }: ClubListProps) { const { data, isLoading, error } = useQuery( - bookClubs.my()._ctx.reviews({ order, page: 1, size: 10 }), + bookClubs.my()._ctx.reviews({ order, page: 1, size: 100 }), ); const myReviewList: Review[] = data?.reviews || []; diff --git a/src/features/profile/container/WrittenReviewList.tsx b/src/features/profile/container/WrittenReviewList.tsx index 94b80ca8..f1b52c00 100644 --- a/src/features/profile/container/WrittenReviewList.tsx +++ b/src/features/profile/container/WrittenReviewList.tsx @@ -13,7 +13,7 @@ export default function WrittenReviewList({ order }: ClubListProps) { const user = useGetUserByPath(); const { data, isLoading, error } = useQuery( - bookClubs.user(user?.id)._ctx.reviews({ order, page: 1, size: 10 }), + bookClubs.user(user?.id)._ctx.reviews({ order, page: 1, size: 100 }), ); const ReviewList: Review[] = data?.reviews || []; diff --git a/src/lib/constants/filters.ts b/src/lib/constants/filters.ts index 0ee948a3..98505373 100644 --- a/src/lib/constants/filters.ts +++ b/src/lib/constants/filters.ts @@ -5,6 +5,6 @@ export const DEFAULT_FILTERS: BookClubParams = { meetingType: 'ALL', order: 'DESC', page: 1, - size: 10, + size: 100, searchKeyword: '', }; From 2083659bdf535e3233af765bf40b92a9e6542e57 Mon Sep 17 00:00:00 2001 From: Sungu Kim <108677235+haegu97@users.noreply.github.com> Date: Sun, 5 Jan 2025 18:58:08 +0900 Subject: [PATCH 4/7] =?UTF-8?q?console.log=20=EC=82=AD=EC=A0=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/app/chat/[id]/page.tsx | 6 +--- src/features/auth/api/auth.ts | 2 +- src/features/auth/api/refreshAccessToken.ts | 1 - .../bookclub/hooks/useFetchBookClubList.ts | 2 -- .../chat/container/BookClubChatContainer.tsx | 3 +- src/features/chat/container/ChatContainer.tsx | 1 - .../chat/container/ExchangeChatContainer.tsx | 31 ++----------------- src/features/chat/utils/socket.ts | 28 +++-------------- 8 files changed, 11 insertions(+), 63 deletions(-) diff --git a/src/app/chat/[id]/page.tsx b/src/app/chat/[id]/page.tsx index 5f1bc9d9..74df14f6 100644 --- a/src/app/chat/[id]/page.tsx +++ b/src/app/chat/[id]/page.tsx @@ -64,17 +64,13 @@ function ChatRoomPage() { await new Promise((resolve, reject) => { const checkConnection = setInterval(() => { - console.log(`소켓 연결 시도 ${attempts + 1}회`); - if (client?.connected) { - console.log('소켓 연결 성공!'); clearInterval(checkConnection); resolve(true); } attempts++; if (attempts >= maxAttempts) { - console.log('소켓 연결 최대 시도 횟수 초과'); clearInterval(checkConnection); reject(new Error('소켓 연결 타임아웃')); } @@ -197,7 +193,7 @@ function ChatRoomPage() {
} - onClick={() => console.log('메뉴 열기 버튼 클릭')} + onClick={() => {}} className="bg-gray-light-02" />
diff --git a/src/features/auth/api/auth.ts b/src/features/auth/api/auth.ts index 01abd80b..41db7216 100644 --- a/src/features/auth/api/auth.ts +++ b/src/features/auth/api/auth.ts @@ -30,7 +30,7 @@ export const login = async (data: LoginFormData) => { await getUserInfo(); const token = getCookie('auth_token'); - console.log('token', token); + if (token) { initializeSocket(token); } diff --git a/src/features/auth/api/refreshAccessToken.ts b/src/features/auth/api/refreshAccessToken.ts index 453566c9..f5b9c73d 100644 --- a/src/features/auth/api/refreshAccessToken.ts +++ b/src/features/auth/api/refreshAccessToken.ts @@ -15,7 +15,6 @@ export const refreshAccessToken = async (refreshToken: string) => { throw new Error('토큰 갱신 실패'); } - console.log('리프레시 성공'); return response.json(); } catch (error) { console.error('토큰 갱신 에러:', error); diff --git a/src/features/bookclub/hooks/useFetchBookClubList.ts b/src/features/bookclub/hooks/useFetchBookClubList.ts index 8d72f6a1..2b70ca45 100644 --- a/src/features/bookclub/hooks/useFetchBookClubList.ts +++ b/src/features/bookclub/hooks/useFetchBookClubList.ts @@ -13,8 +13,6 @@ const useBookClubList = () => { const clubList = data?.bookClubs; - // console.log('useQuery 데이터:', clubList); - const updateFilters = (newFilters: Partial) => { setFilters((prevFilters) => ({ ...prevFilters, ...newFilters })); }; diff --git a/src/features/chat/container/BookClubChatContainer.tsx b/src/features/chat/container/BookClubChatContainer.tsx index c75bb051..6aa99cdc 100644 --- a/src/features/chat/container/BookClubChatContainer.tsx +++ b/src/features/chat/container/BookClubChatContainer.tsx @@ -30,7 +30,7 @@ export default function BookClubChatContainer() { const fetchRecentChats = async () => { try { const response = await getRecentChats(); - console.log('최근 채팅 내용 조회 성공:', response); + setRecentMessages(response || []); } catch (error) { console.error('최근 채팅 내용 조회 실패:', error); @@ -46,7 +46,6 @@ export default function BookClubChatContainer() { }, []); const bookClubChats = data?.bookClubs || []; - console.log('bookClubChats', bookClubChats); if (isLoading) return
로딩중...
; if (error) return
에러가 발생했습니다
; diff --git a/src/features/chat/container/ChatContainer.tsx b/src/features/chat/container/ChatContainer.tsx index 8400ba97..2de2a76c 100644 --- a/src/features/chat/container/ChatContainer.tsx +++ b/src/features/chat/container/ChatContainer.tsx @@ -17,7 +17,6 @@ export default function ChatContainer() { const connectSocket = async () => { try { await initializeSocket(token); - console.log('채팅 페이지에서 소켓 재연결 성공'); } catch (error) { console.error('채팅 페이지에서 소켓 재연결 실패:', error); } diff --git a/src/features/chat/container/ExchangeChatContainer.tsx b/src/features/chat/container/ExchangeChatContainer.tsx index b330c466..b3661841 100644 --- a/src/features/chat/container/ExchangeChatContainer.tsx +++ b/src/features/chat/container/ExchangeChatContainer.tsx @@ -1,39 +1,14 @@ import React from 'react'; -import ChatCard from '../components/chat-card/ChatCard'; - -interface BookClubChatData { - imageUrl: string; - isHost: boolean; - title: string; - currentParticipants: number; - lastMessage: string; - lastMessageTime: string; - unreadCount: number; -} export default function ExchangeChatContainer() { const message = '아직 참여중인 채팅이 없어요.'; - const mockBookClubChats: BookClubChatData[] = []; return (
- {mockBookClubChats.length === 0 ? ( -
- {message} -
- ) : ( - mockBookClubChats.map((chat, index) => ( - console.log('채팅방 클릭'), - }} - /> - )) - )} +
+ {message} +
); diff --git a/src/features/chat/utils/socket.ts b/src/features/chat/utils/socket.ts index 87ca018b..11420edd 100644 --- a/src/features/chat/utils/socket.ts +++ b/src/features/chat/utils/socket.ts @@ -28,7 +28,6 @@ export interface ChatHistoryResponse { export const initializeSocket = async (token: string) => { if (stompClient?.connected) { - console.log('이미 연결된 소켓이 있습니다.'); return stompClient; } @@ -52,20 +51,14 @@ export const initializeSocket = async (token: string) => { }); client.onConnect = () => { - console.log('소켓 연결 성공'); - bookClubs.forEach((club: BookClub) => { - console.log('구독 시도:', club.id); - client.subscribe(`/topic/group-chat/${club.id}`, (message) => { - const chatMessage: ChatMessage = JSON.parse(message.body); - console.log(`모임 ${club.title}의 새 메시지 수신:`, chatMessage); + client.subscribe(`/topic/group-chat/${club.id}`, () => { + // const chatMessage: ChatMessage = JSON.parse(message.body); }); }); }; - client.onDisconnect = () => { - console.log('소켓 연결 끊김'); - }; + client.onDisconnect = () => {}; client.onStompError = (frame) => { console.error('Stomp 에러:', frame); @@ -102,13 +95,10 @@ export const sendMessage = (roomId: number, content: string) => { return; } - console.log(`메시지 전송 시도: roomId=${roomId}, content=${content}`); - client.publish({ destination: `/app/group-chat/${roomId}/sendMessage`, body: JSON.stringify({ content }), }); - console.log('메시지 전송 성공'); }; export const getChatHistory = (roomId: number) => { @@ -120,7 +110,7 @@ export const getChatHistory = (roomId: number) => { (message) => { try { const historyData: ChatHistoryResponse = JSON.parse(message.body); - console.log('채팅 히스토리 수신:', historyData); + resolve(historyData); subscription.unsubscribe(); } catch (error) { @@ -136,7 +126,6 @@ export const getChatHistory = (roomId: number) => { destination: `/app/group-chat/history/${roomId}`, body: JSON.stringify({}), }); - console.log('채팅 히스토리 요청 전송'); } catch (error) { console.error('채팅 히스토리 요청 실패:', error); subscription.unsubscribe(); @@ -147,17 +136,12 @@ export const getChatHistory = (roomId: number) => { export const getRecentChats = () => { const client = getStompClient(); - console.log('getRecentChats - 클라이언트 상태:', { - connected: client.connected, - active: client.active, - }); return new Promise((resolve, reject) => { const subscription = client.subscribe('/user/queue/recent', (message) => { - console.log('구독 콜백 실행됨'); try { const recentData: ChatMessage[] = JSON.parse(message.body); - console.log('최신 채팅 데이터:', recentData); + resolve(recentData); subscription.unsubscribe(); } catch (error) { @@ -168,12 +152,10 @@ export const getRecentChats = () => { }); try { - console.log('서버로 요청 전송 시도'); client.publish({ destination: '/app/group-chat/recent', body: JSON.stringify({}), }); - console.log('서버로 요청 전송 완료'); } catch (error) { console.error('최신 채팅 요청 실패:', error); subscription.unsubscribe(); From 4efde5b4a70361bb99dd4abcbf1bd7f44fa9c372 Mon Sep 17 00:00:00 2001 From: Sungu Kim <108677235+haegu97@users.noreply.github.com> Date: Sun, 5 Jan 2025 19:06:02 +0900 Subject: [PATCH 5/7] =?UTF-8?q?=EB=A1=9C=EB=94=A9=EC=BB=B4=ED=8F=AC?= =?UTF-8?q?=EB=84=8C=ED=8A=B8=EB=A1=9C=20=EA=B5=90=EC=B2=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../chat/container/BookClubChatContainer.tsx | 54 ++++++++++--------- 1 file changed, 29 insertions(+), 25 deletions(-) diff --git a/src/features/chat/container/BookClubChatContainer.tsx b/src/features/chat/container/BookClubChatContainer.tsx index 6aa99cdc..e12518f7 100644 --- a/src/features/chat/container/BookClubChatContainer.tsx +++ b/src/features/chat/container/BookClubChatContainer.tsx @@ -10,6 +10,7 @@ import { getRecentChats, getStompClient } from '@/features/chat/utils/socket'; import { findRecentMessage } from '@/features/chat/utils/chatRoom'; import { formatDateForUI } from '@/lib/utils/formatDateForUI'; import { useAuthStore } from '@/store/authStore'; +import Loading from '@/components/loading/Loading'; export default function BookClubChatContainer() { const [recentMessages, setRecentMessages] = useState< @@ -47,35 +48,38 @@ export default function BookClubChatContainer() { const bookClubChats = data?.bookClubs || []; - if (isLoading) return
로딩중...
; if (error) return
에러가 발생했습니다
; return ( -
-
- {bookClubChats.map((bookClub: BookClubProps, id: number) => { - const recentMessage = findRecentMessage( - recentMessages, - Number(bookClub.id), - ); +
+ {isLoading ? ( + + ) : ( +
+ {bookClubChats.map((bookClub: BookClubProps, id: number) => { + const recentMessage = findRecentMessage( + recentMessages, + Number(bookClub.id), + ); - return ( - - - - ); - })} -
+ return ( + + + + ); + })} +
+ )}
); } From 42ac92f7c313a95e9b45b11e43165ba2f1d9c9d1 Mon Sep 17 00:00:00 2001 From: Sungu Kim <108677235+haegu97@users.noreply.github.com> Date: Sun, 5 Jan 2025 19:09:29 +0900 Subject: [PATCH 6/7] =?UTF-8?q?=EB=B9=8C=EB=93=9C=EC=97=90=EB=9F=AC=20?= =?UTF-8?q?=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../chat-room/components/chat-bubble/ChatBubble.stories.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/features/chat-room/components/chat-bubble/ChatBubble.stories.tsx b/src/features/chat-room/components/chat-bubble/ChatBubble.stories.tsx index cdfe9b75..dddb7ba5 100644 --- a/src/features/chat-room/components/chat-bubble/ChatBubble.stories.tsx +++ b/src/features/chat-room/components/chat-bubble/ChatBubble.stories.tsx @@ -39,7 +39,7 @@ export const OpponentMessage: Story = { * 늦게 오시는 분은 미리 말씀 부탁드려요!`, time: '오후 2:31', name: '김철수', - profileImage: 'https://picsum.photos/200', + image: 'https://picsum.photos/200', isHost: true, }, }, From 818bf8a7076a94de32434341a56776e65663ab31 Mon Sep 17 00:00:00 2001 From: Sungu Kim <108677235+haegu97@users.noreply.github.com> Date: Sun, 5 Jan 2025 19:20:53 +0900 Subject: [PATCH 7/7] =?UTF-8?q?=EB=B9=8C=EB=93=9C=EC=97=90=EB=9F=AC=20?= =?UTF-8?q?=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../components/atoms/atoms.stories.tsx | 2 +- .../chat/components/chat-card/ChatCard.tsx | 2 +- .../chat-card/types/variantChatCard.ts | 4 +- src/mocks/mockDatas.ts | 70 ++++++++++--------- 4 files changed, 40 insertions(+), 38 deletions(-) diff --git a/src/features/chat-room/components/chat-bubble/components/atoms/atoms.stories.tsx b/src/features/chat-room/components/chat-bubble/components/atoms/atoms.stories.tsx index a9bcda96..00fae048 100644 --- a/src/features/chat-room/components/chat-bubble/components/atoms/atoms.stories.tsx +++ b/src/features/chat-room/components/chat-bubble/components/atoms/atoms.stories.tsx @@ -33,7 +33,7 @@ export const Time: StoryObj = { export const Profile: StoryObj = { render: () => ( diff --git a/src/features/chat/components/chat-card/ChatCard.tsx b/src/features/chat/components/chat-card/ChatCard.tsx index 804b245b..ec47f3f9 100644 --- a/src/features/chat/components/chat-card/ChatCard.tsx +++ b/src/features/chat/components/chat-card/ChatCard.tsx @@ -202,7 +202,7 @@ function ChatCard({
{title} - +
{unreadCount && unreadCount > 0 && ( <> diff --git a/src/features/chat/components/chat-card/types/variantChatCard.ts b/src/features/chat/components/chat-card/types/variantChatCard.ts index c85f7f1d..19cebbaf 100644 --- a/src/features/chat/components/chat-card/types/variantChatCard.ts +++ b/src/features/chat/components/chat-card/types/variantChatCard.ts @@ -8,11 +8,11 @@ interface CommonProps extends React.HTMLAttributes { } export interface BookClubProps extends CommonProps { - memberCount: number; + memberCount?: number; lastMessage?: string; lastMessageTime?: string; unreadCount?: number; - hostId: number; + hostId?: number; } export interface ChatRoomHeaderProps extends CommonProps { diff --git a/src/mocks/mockDatas.ts b/src/mocks/mockDatas.ts index ed2cb21e..55224133 100644 --- a/src/mocks/mockDatas.ts +++ b/src/mocks/mockDatas.ts @@ -2,6 +2,8 @@ import { BookClub } from '@/types/bookclubs'; import { Review } from '@/types/review'; import { User } from '@/types/user'; +const defaultBookClub = '/images/defaultBookClub.jpg'; +const defaultProfile = '/images/profile.png'; export const mockBookClubs: BookClub[] = [ { id: 1, @@ -11,7 +13,7 @@ export const mockBookClubs: BookClub[] = [ bookClubType: 'FREE', targetDate: '2025-02-10', endDate: '2025-01-30', - imageUrl: 'https://example.com/images/club1.jpg', + imageUrl: defaultBookClub, memberLimit: 20, memberCount: 15, city: '서울', @@ -20,7 +22,7 @@ export const mockBookClubs: BookClub[] = [ detailAddress: '5층', hostId: 101, hostNickname: '진영', - hostProfileImage: 'https://example.com/images/host1.jpg', + hostProfileImage: defaultProfile, averageScore: 4.5, clubStatus: 'confirmed', isLiked: true, @@ -35,7 +37,7 @@ export const mockBookClubs: BookClub[] = [ bookClubType: 'FREE', targetDate: '2025-03-01', endDate: '2025-02-25', - imageUrl: 'https://example.com/images/club2.jpg', + imageUrl: defaultBookClub, memberLimit: 15, memberCount: 10, city: '부산', @@ -44,7 +46,7 @@ export const mockBookClubs: BookClub[] = [ detailAddress: "커피숍 '북카페'", hostId: 102, hostNickname: '민지', - hostProfileImage: 'https://example.com/images/host2.jpg', + hostProfileImage: defaultProfile, averageScore: 4.8, clubStatus: 'pending', isLiked: false, @@ -59,7 +61,7 @@ export const mockBookClubs: BookClub[] = [ bookClubType: 'FIXED', targetDate: '2025-04-10', endDate: '2025-03-30', - imageUrl: 'https://example.com/images/club3.jpg', + imageUrl: defaultBookClub, memberLimit: 25, memberCount: 18, city: '서울', @@ -68,7 +70,7 @@ export const mockBookClubs: BookClub[] = [ detailAddress: '도서관 3층', hostId: 103, hostNickname: '수연', - hostProfileImage: 'https://example.com/images/host3.jpg', + hostProfileImage: defaultProfile, averageScore: 4.2, clubStatus: 'confirmed', isLiked: true, @@ -83,7 +85,7 @@ export const mockBookClubs: BookClub[] = [ bookClubType: 'FREE', targetDate: '2025-05-15', endDate: '2025-05-01', - imageUrl: 'https://example.com/images/club4.jpg', + imageUrl: defaultBookClub, memberLimit: 30, memberCount: 25, city: '대구', @@ -92,7 +94,7 @@ export const mockBookClubs: BookClub[] = [ detailAddress: '역사 박물관 앞', hostId: 104, hostNickname: '지훈', - hostProfileImage: 'https://example.com/images/host4.jpg', + hostProfileImage: defaultProfile, averageScore: 4.7, clubStatus: 'closed', isLiked: false, @@ -107,7 +109,7 @@ export const mockBookClubs: BookClub[] = [ bookClubType: 'FIXED', targetDate: '2025-06-01', endDate: '2025-05-20', - imageUrl: 'https://example.com/images/club5.jpg', + imageUrl: defaultBookClub, memberLimit: 12, memberCount: 10, city: '서울', @@ -116,7 +118,7 @@ export const mockBookClubs: BookClub[] = [ detailAddress: '온라인 Zoom', hostId: 105, hostNickname: '정민', - hostProfileImage: 'https://example.com/images/host5.jpg', + hostProfileImage: defaultProfile, averageScore: 5.0, clubStatus: 'confirmed', isLiked: true, @@ -131,7 +133,7 @@ export const mockBookClubs: BookClub[] = [ bookClubType: 'FREE', targetDate: '2025-07-10', endDate: '2025-06-30', - imageUrl: 'https://example.com/images/club6.jpg', + imageUrl: defaultBookClub, memberLimit: 20, memberCount: 16, city: '인천', @@ -140,7 +142,7 @@ export const mockBookClubs: BookClub[] = [ detailAddress: '송도 도서관', hostId: 106, hostNickname: '현수', - hostProfileImage: 'https://example.com/images/host6.jpg', + hostProfileImage: defaultProfile, averageScore: 3.8, clubStatus: 'pending', isLiked: false, @@ -155,7 +157,7 @@ export const mockBookClubs: BookClub[] = [ bookClubType: 'FIXED', targetDate: '2025-08-01', endDate: '2025-07-20', - imageUrl: 'https://example.com/images/club7.jpg', + imageUrl: defaultBookClub, memberLimit: 18, memberCount: 14, city: '서울', @@ -164,7 +166,7 @@ export const mockBookClubs: BookClub[] = [ detailAddress: '온라인 Zoom', hostId: 107, hostNickname: '태영', - hostProfileImage: 'https://example.com/images/host7.jpg', + hostProfileImage: defaultProfile, averageScore: 4.1, clubStatus: 'confirmed', isLiked: true, @@ -179,7 +181,7 @@ export const mockBookClubs: BookClub[] = [ bookClubType: 'FREE', targetDate: '2025-09-05', endDate: '2025-08-30', - imageUrl: 'https://example.com/images/club8.jpg', + imageUrl: defaultBookClub, memberLimit: 10, memberCount: 8, city: '서울', @@ -188,7 +190,7 @@ export const mockBookClubs: BookClub[] = [ detailAddress: "홍대 카페 '여행자'", hostId: 108, hostNickname: '수아', - hostProfileImage: 'https://example.com/images/host8.jpg', + hostProfileImage: defaultProfile, averageScore: 3.9, clubStatus: 'pending', isLiked: false, @@ -203,7 +205,7 @@ export const mockBookClubs: BookClub[] = [ bookClubType: 'FREE', targetDate: '2025-10-10', endDate: '2025-09-30', - imageUrl: 'https://example.com/images/club9.jpg', + imageUrl: defaultBookClub, memberLimit: 30, memberCount: 20, city: '대전', @@ -212,7 +214,7 @@ export const mockBookClubs: BookClub[] = [ detailAddress: '온라인 Discord', hostId: 109, hostNickname: '정호', - hostProfileImage: 'https://example.com/images/host9.jpg', + hostProfileImage: defaultProfile, averageScore: 4.6, clubStatus: 'closed', isLiked: true, @@ -227,7 +229,7 @@ export const mockBookClubs: BookClub[] = [ bookClubType: 'FREE', targetDate: '2025-11-01', endDate: '2025-10-25', - imageUrl: 'https://example.com/images/club10.jpg', + imageUrl: defaultBookClub, memberLimit: 25, memberCount: 20, city: '서울', @@ -236,7 +238,7 @@ export const mockBookClubs: BookClub[] = [ detailAddress: '강북 도서관', hostId: 110, hostNickname: '지은', - hostProfileImage: 'https://example.com/images/host10.jpg', + hostProfileImage: defaultProfile, averageScore: 4.3, clubStatus: 'confirmed', isLiked: false, @@ -253,9 +255,9 @@ export const mockReviews: Review[] = [ rating: 5, content: '이 책클럽은 정말 좋았습니다. 책 선정도 훌륭하고, 참여자들 간의 토론도 활발했어요.', - userImage: 'https://example.com/images/review1.jpg', + userImage: defaultProfile, createdAt: '2025-01-10T14:30:00Z', - bookClubImageUrl: 'https://example.com/images/club1.jpg', + bookClubImageUrl: defaultBookClub, nickname: '진영', bookClubTitle: '문학 사랑 모임', bookClubType: 'FREE', @@ -267,9 +269,9 @@ export const mockReviews: Review[] = [ rating: 4, content: '모임 분위기는 좋았지만, 책의 주제가 조금 어려웠어요. 그래도 유익한 시간이었어요.', - userImage: 'https://example.com/images/review2.jpg', + userImage: defaultBookClub, createdAt: '2025-01-12T16:45:00Z', - bookClubImageUrl: 'https://example.com/images/club2.jpg', + bookClubImageUrl: defaultBookClub, nickname: '민지', bookClubTitle: '책과 커피 모임', bookClubType: 'FREE', @@ -282,7 +284,7 @@ export const mockReviews: Review[] = [ content: '책은 좋았지만, 온라인 모임이라 참여자들과의 소통이 부족했던 것 같아요.', createdAt: '2025-01-14T17:00:00Z', - bookClubImageUrl: 'https://example.com/images/club3.jpg', + bookClubImageUrl: defaultBookClub, nickname: '수연', bookClubTitle: 'SF 소설 모임', bookClubType: 'FIXED', @@ -295,7 +297,7 @@ export const mockReviews: Review[] = [ content: '좋은 모임이었지만, 장소가 조금 좁았어요. 그 외엔 정말 유익한 시간이었습니다.', createdAt: '2025-01-15T18:10:00Z', - bookClubImageUrl: 'https://example.com/images/club4.jpg', + bookClubImageUrl: defaultBookClub, nickname: '지훈', bookClubTitle: '역사 탐방 모임', bookClubType: 'FREE', @@ -307,9 +309,9 @@ export const mockReviews: Review[] = [ rating: 5, content: '시집에 대한 다양한 해석을 나누어서 매우 흥미로운 모임이었어요. 다음 모임이 기대됩니다.', - userImage: 'https://example.com/images/review5.jpg', + userImage: defaultBookClub, createdAt: '2025-01-16T12:00:00Z', - bookClubImageUrl: 'https://example.com/images/club5.jpg', + bookClubImageUrl: defaultBookClub, nickname: '정민', bookClubTitle: '시집 독서 모임', bookClubType: 'FIXED', @@ -322,7 +324,7 @@ export const mockReviews: Review[] = [ content: '경제학 토론이 매우 유익했고, 다른 사람들의 의견을 들을 수 있어 좋았습니다.', createdAt: '2025-01-17T13:30:00Z', - bookClubImageUrl: 'https://example.com/images/club6.jpg', + bookClubImageUrl: defaultBookClub, nickname: '현수', bookClubTitle: '경제학 토론 모임', bookClubType: 'FREE', @@ -335,7 +337,7 @@ export const mockReviews: Review[] = [ content: '영화와 책을 비교하는 재미는 있었으나, 일부 영화가 책의 내용을 잘 반영하지 못한 것 같아요.', createdAt: '2025-01-18T19:00:00Z', - bookClubImageUrl: 'https://example.com/images/club7.jpg', + bookClubImageUrl: defaultBookClub, nickname: '태영', bookClubTitle: '문학과 영화 모임', bookClubType: 'FIXED', @@ -347,9 +349,9 @@ export const mockReviews: Review[] = [ rating: 5, content: '여행 사진과 이야기를 나누는 모임은 정말 즐거웠어요. 다른 사람들의 경험을 듣는 것이 너무 흥미로웠습니다.', - userImage: 'https://example.com/images/review8.jpg', + userImage: defaultBookClub, createdAt: '2025-01-19T20:30:00Z', - bookClubImageUrl: 'https://example.com/images/club8.jpg', + bookClubImageUrl: defaultBookClub, nickname: '수아', bookClubTitle: '여행 사진 모임', bookClubType: 'FREE', @@ -362,7 +364,7 @@ export const mockReviews: Review[] = [ content: '디지털 기술에 대한 최신 정보를 나눌 수 있어 좋았고, 많은 토론이 이루어졌습니다.', createdAt: '2025-01-20T21:45:00Z', - bookClubImageUrl: 'https://example.com/images/club9.jpg', + bookClubImageUrl: defaultBookClub, nickname: '정호', bookClubTitle: '디지털 기술 토론 모임', bookClubType: 'FREE', @@ -375,7 +377,7 @@ export const mockReviews: Review[] = [ content: '고전 문학을 다시 한번 되새길 수 있는 좋은 시간이었어요. 다만, 책 선정이 조금 아쉬웠습니다.', createdAt: '2025-01-21T22:30:00Z', - bookClubImageUrl: 'https://example.com/images/club10.jpg', + bookClubImageUrl: defaultBookClub, nickname: '지은', bookClubTitle: '고전 문학 독서 모임', bookClubType: 'FREE',