Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 0 additions & 7 deletions src/app/message/layout.tsx
Original file line number Diff line number Diff line change
@@ -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}</>;
};

Expand Down
74 changes: 38 additions & 36 deletions src/components/pages/chat/chat-list/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -42,48 +42,50 @@ export const ChatList = ({ userId, accessToken }: IProps) => {
{chatList?.chatRooms.length === 0 ? (
<ChattingNone />
) : (
chatList?.chatRooms?.map((chat) => (
<li
key={chat.chatRoomId}
className='flex cursor-pointer items-center gap-3 bg-white p-5 transition hover:bg-gray-50'
onClick={() => handleClick(chat.chatRoomId)}
>
{/* 프로필 이미지 - 이미지 수정 필요💥💥*/}
<div className='relative size-12 overflow-hidden rounded-full'>
<Image
className='object-cover'
alt='프로필 이미지'
fill
loading='eager'
src={DEFAULT_PROFILE_IMAGE}
/>
</div>
chatList?.chatRooms
?.filter((chatRoom) => chatRoom.lastMessage !== null)
.map((chat) => (
<li
key={chat.chatRoomId}
className='flex cursor-pointer items-center gap-3 bg-white p-5 transition hover:bg-gray-50'
onClick={() => handleClick(chat.chatRoomId)}
>
{/* 프로필 이미지 - 이미지 수정 필요💥💥*/}
<div className='relative size-12 overflow-hidden rounded-full'>
<Image
className='object-cover'
alt='프로필 이미지'
fill
loading='eager'
src={chat.thumbnail || DEFAULT_PROFILE_IMAGE}
/>
</div>

{/* 텍스트 영역 */}
<div className='flex flex-1 flex-col'>
<span className='text-text-md-bold text-gray-800'>{chat.chatRoomName}</span>
<span
className={cn(
'text-text-sm-medium line-clamp-1 overflow-hidden break-all text-gray-700',
)}
>
{chat.lastMessage ? chat.lastMessage.content : '아직 대화가 없습니다.'}
</span>
</div>

{/* 텍스트 영역 */}
<div className='flex flex-1 flex-col'>
<span className='text-text-md-bold text-gray-800'>{chat.chatRoomName}</span>
{/* 안 읽은 메시지 수 */}
<span
className={cn(
'text-text-sm-medium line-clamp-1 overflow-hidden break-all text-gray-700',
'text-mono-white text-text-xs-bold bg-mint-500 flex items-center justify-center rounded-full',
chat.unreadCount === 0 && 'opacity-0',
chat.unreadCount < 10 && 'size-6',
chat.unreadCount >= 10 && 'h-6 w-7',
)}
>
{chat.lastMessage ? chat.lastMessage.content : '아직 대화가 없습니다.'}
{chat.unreadCount > 99 ? '99' : chat.unreadCount}
</span>
</div>

{/* 안 읽은 메시지 수 */}
<span
className={cn(
'text-mono-white text-text-xs-bold bg-mint-500 flex items-center justify-center rounded-full',
chat.unreadCount === 0 && 'opacity-0',
chat.unreadCount < 10 && 'size-6',
chat.unreadCount >= 10 && 'h-6 w-7',
)}
>
{chat.unreadCount > 99 ? '99' : chat.unreadCount}
</span>
</li>
))
</li>
))
)}
</ul>
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ describe('FollowingCard 컴포넌트 테스트', () => {
fireEvent.click(screen.getByText('메세지'));

await waitFor(() => {
expect(routerPush).toHaveBeenCalledWith('/chat/123');
expect(routerPush).toHaveBeenCalledWith('/message/chat/123');
});
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ export const FollowingModal = ({ userId }: { userId: number }) => {
onSuccess: () => {
close();
},
onError: () => {
setErrorMessage('존재하지 않는 유저입니다.');
onError: (e) => {
setErrorMessage(e.detail.slice(4));
},
},
);
Expand Down
1 change: 1 addition & 0 deletions src/types/service/chat.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ export interface ChattingRoom {
};
participants: ChatUser[];
unreadCount: number;
thumbnail: string;
}

export interface ChatMessage {
Expand Down