diff --git a/src/app/message/layout.tsx b/src/app/message/layout.tsx index 3fdd9532..109f7f30 100644 --- a/src/app/message/layout.tsx +++ b/src/app/message/layout.tsx @@ -1,15 +1,8 @@ -import { redirect } from 'next/navigation'; - interface Props { children: React.ReactNode; } const FollowPageLayout = async ({ children }: Props) => { - const { cookies } = await import('next/headers'); - const cookieStore = await cookies(); - const myId = Number(cookieStore.get('userId')?.value); - - if (!myId) redirect('/login'); return <>{children}; }; diff --git a/src/components/pages/chat/chat-list/index.tsx b/src/components/pages/chat/chat-list/index.tsx index 3b1cea71..b30b24bc 100644 --- a/src/components/pages/chat/chat-list/index.tsx +++ b/src/components/pages/chat/chat-list/index.tsx @@ -42,48 +42,50 @@ export const ChatList = ({ userId, accessToken }: IProps) => { {chatList?.chatRooms.length === 0 ? ( ) : ( - chatList?.chatRooms?.map((chat) => ( -
  • handleClick(chat.chatRoomId)} - > - {/* 프로필 이미지 - 이미지 수정 필요💥💥*/} -
    - 프로필 이미지 -
    + chatList?.chatRooms + ?.filter((chatRoom) => chatRoom.lastMessage !== null) + .map((chat) => ( +
  • handleClick(chat.chatRoomId)} + > + {/* 프로필 이미지 - 이미지 수정 필요💥💥*/} +
    + 프로필 이미지 +
    + + {/* 텍스트 영역 */} +
    + {chat.chatRoomName} + + {chat.lastMessage ? chat.lastMessage.content : '아직 대화가 없습니다.'} + +
    - {/* 텍스트 영역 */} -
    - {chat.chatRoomName} + {/* 안 읽은 메시지 수 */} = 10 && 'h-6 w-7', )} > - {chat.lastMessage ? chat.lastMessage.content : '아직 대화가 없습니다.'} + {chat.unreadCount > 99 ? '99' : chat.unreadCount} -
    - - {/* 안 읽은 메시지 수 */} - = 10 && 'h-6 w-7', - )} - > - {chat.unreadCount > 99 ? '99' : chat.unreadCount} - -
  • - )) + + )) )} ); diff --git a/src/components/pages/message/message-following-card/index.test.tsx b/src/components/pages/message/message-following-card/index.test.tsx index 3e65f23f..aa8ce850 100644 --- a/src/components/pages/message/message-following-card/index.test.tsx +++ b/src/components/pages/message/message-following-card/index.test.tsx @@ -81,7 +81,7 @@ describe('FollowingCard 컴포넌트 테스트', () => { fireEvent.click(screen.getByText('메세지')); await waitFor(() => { - expect(routerPush).toHaveBeenCalledWith('/chat/123'); + expect(routerPush).toHaveBeenCalledWith('/message/chat/123'); }); }); }); diff --git a/src/components/pages/message/message-following-card/index.tsx b/src/components/pages/message/message-following-card/index.tsx index 5c7cccb4..31ea6347 100644 --- a/src/components/pages/message/message-following-card/index.tsx +++ b/src/components/pages/message/message-following-card/index.tsx @@ -39,7 +39,7 @@ export const FollowingCard = ({ try { setIsLoading(true); const data = await mutateAsync({ targetUserId: userId }); - router.push(`/chat/${data.chatRoomId}`); + router.push(`/message/chat/${data.chatRoomId}`); } catch (error) { console.error('DM 생성 오류:', error); } finally { diff --git a/src/components/pages/message/message-following-modal/index.tsx b/src/components/pages/message/message-following-modal/index.tsx index cf906a9c..e03a9c01 100644 --- a/src/components/pages/message/message-following-modal/index.tsx +++ b/src/components/pages/message/message-following-modal/index.tsx @@ -26,8 +26,8 @@ export const FollowingModal = ({ userId }: { userId: number }) => { onSuccess: () => { close(); }, - onError: () => { - setErrorMessage('존재하지 않는 유저입니다.'); + onError: (e) => { + setErrorMessage(e.detail.slice(4)); }, }, ); diff --git a/src/types/service/chat.ts b/src/types/service/chat.ts index 94e2660d..eb6fec1d 100644 --- a/src/types/service/chat.ts +++ b/src/types/service/chat.ts @@ -11,6 +11,7 @@ export interface ChattingRoom { }; participants: ChatUser[]; unreadCount: number; + thumbnail: string; } export interface ChatMessage {