Skip to content

Commit 9b67b28

Browse files
authored
fix(web): unify profile badge with mentor boolean (#486)
1 parent 1d50ae6 commit 9b67b28

File tree

6 files changed

+34
-10
lines changed

6 files changed

+34
-10
lines changed

apps/web/src/app/mentor/chat/[chatId]/_ui/ChatContent/_ui/ChatMessageBox/index.tsx

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,15 @@ interface ChatMessageBoxProps {
99
message: ChatMessage;
1010
currentUserId?: number; // 현재 사용자 ID
1111
partnerNickname?: string; // 상대방 닉네임
12+
isPartnerMentor?: boolean;
1213
}
1314

14-
const ChatMessageBox = ({ message, currentUserId = 1, partnerNickname = "상대방" }: ChatMessageBoxProps) => {
15+
const ChatMessageBox = ({
16+
message,
17+
currentUserId = 1,
18+
partnerNickname = "상대방",
19+
isPartnerMentor = false,
20+
}: ChatMessageBoxProps) => {
1521
const isMine = message.senderId === Number(currentUserId);
1622

1723
const messageType = getMessageType(message);
@@ -83,7 +89,7 @@ const ChatMessageBox = ({ message, currentUserId = 1, partnerNickname = "상대
8389
) : (
8490
<div className="flex justify-start">
8591
<div className="flex max-w-xs flex-row gap-2">
86-
<ProfileWithBadge width={32} height={32} />
92+
<ProfileWithBadge isMentor={isPartnerMentor} width={32} height={32} />
8793
<div className="flex flex-col items-start">
8894
<span className="mb-1 text-k-900 typo-medium-5">{partnerNickname}</span>
8995
<div className="flex items-end gap-1">

apps/web/src/app/mentor/chat/[chatId]/_ui/ChatContent/index.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ const ChatContent = ({ chatId }: ChatContentProps) => {
2727
const userId = Number(parsedData?.sub ?? 0) || 0;
2828

2929
const isMentor = parsedData?.role === UserRole.MENTOR || parsedData?.role === UserRole.ADMIN;
30+
const isPartnerMentor = !isMentor;
3031

3132
// 채팅 읽음 상태 업데이트 훅 진입시 자동으로
3233
usePutChatReadHandler(chatId);
@@ -72,7 +73,7 @@ const ChatContent = ({ chatId }: ChatContentProps) => {
7273
)}
7374
>
7475
<div className="flex items-center gap-2">
75-
<ProfileWithBadge profileImageUrl={profileUrl} width={30} height={30} />
76+
<ProfileWithBadge profileImageUrl={profileUrl} isMentor={isPartnerMentor} width={30} height={30} />
7677
<div className="flex h-full items-center">
7778
<span className="text-k-700 typo-sb-7">{nickname}</span>
7879
<div className="mx-4 h-10 w-[1px] bg-k-100"></div>
@@ -158,6 +159,7 @@ const ChatContent = ({ chatId }: ChatContentProps) => {
158159
message={message}
159160
currentUserId={userId}
160161
partnerNickname={nickname}
162+
isPartnerMentor={isPartnerMentor}
161163
/>
162164
</div>
163165
);

apps/web/src/app/mentor/chat/[chatId]/_ui/ChatNavBar/index.tsx

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ const ChatNavBar = ({ chatId }: ChatNavBarProps) => {
2323
const accessToken = useAuthStore((state) => state.accessToken);
2424
const result = tokenParse(accessToken);
2525
const isMentor = result?.role === UserRole.MENTOR || result?.role === UserRole.ADMIN;
26+
const isPartnerMentor = !isMentor;
2627

2728
// 파트너 정보 가져오기
2829
const { data: partnerInfo } = useGetPartnerInfo(chatId);
@@ -91,7 +92,12 @@ const ChatNavBar = ({ chatId }: ChatNavBarProps) => {
9192
</button>
9293
</div>
9394
<div className="mb-6 flex flex-col items-center">
94-
<ProfileWithBadge profileImageUrl={partnerInfo?.profileUrl} width={64} height={64} />
95+
<ProfileWithBadge
96+
profileImageUrl={partnerInfo?.profileUrl}
97+
isMentor={isPartnerMentor}
98+
width={64}
99+
height={64}
100+
/>
95101
<h3 className="text-gray-800 typo-sb-5">{partnerInfo?.nickname || "상대방"}</h3>
96102
<p className={clsx("typo-medium-2", { "text-sub-c-500": isMentor, "text-primary-500": !isMentor })}>
97103
{partnerInfo?.university || "예비솔커"}
@@ -136,7 +142,7 @@ const ChatNavBar = ({ chatId }: ChatNavBarProps) => {
136142
<div className="mt-2 space-y-3">
137143
{/* 현재 사용자 */}
138144
<div className="flex items-center gap-3">
139-
<ProfileWithBadge profileImageUrl={myInfo?.profileImageUrl} width={24} height={24} />
145+
<ProfileWithBadge profileImageUrl={myInfo?.profileImageUrl} isMentor={isMentor} width={24} height={24} />
140146
{/* '나' 표시 div */}
141147
<div className="flex h-3 w-3 items-center justify-center rounded-full bg-pink-200">
142148
<span className="text-center text-pink-600 typo-medium-5"></span>
@@ -150,7 +156,12 @@ const ChatNavBar = ({ chatId }: ChatNavBarProps) => {
150156

151157
{/* 상대방 */}
152158
<div className="flex items-center gap-3">
153-
<ProfileWithBadge profileImageUrl={partnerInfo?.profileUrl} width={24} height={24} />
159+
<ProfileWithBadge
160+
profileImageUrl={partnerInfo?.profileUrl}
161+
isMentor={isPartnerMentor}
162+
width={24}
163+
height={24}
164+
/>
154165
<span className="text-k-800 typo-medium-2">
155166
{partnerInfo?.nickname || "상대방"} ({isMentor ? "멘티" : "멘토"})
156167
</span>

apps/web/src/app/mentor/chat/_ui/ChatPageClient/index.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ const ChatPageClient = () => {
1313
const { data: myInfo } = useGetMyInfo();
1414

1515
const isMentee = myInfo?.role === UserRole.MENTEE;
16+
const isPartnerMentor = isMentee;
1617

1718
// 연결된 멘토가 없을 때의 처리 (멘티만)
1819
if (chatRooms.length === 0 && isMentee) {
@@ -90,7 +91,7 @@ const ChatPageClient = () => {
9091
className="flex items-center justify-between border-b border-k-50 py-2"
9192
>
9293
<div className="flex items-center gap-2">
93-
<ProfileWithBadge profileImageUrl={profileUrl} width={48} height={48} />
94+
<ProfileWithBadge profileImageUrl={profileUrl} isMentor={isPartnerMentor} width={48} height={48} />
9495
<div className="flex flex-col items-start">
9596
<h3 className="text-k-900 typo-sb-9">{nickname}</h3>
9697
<p className="truncate text-k-600 typo-regular-2">{lastChatMessage}</p>

apps/web/src/app/my/_ui/MyProfileContent/index.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ const MyProfileContent = () => {
7979
{/* Profile Card */}
8080
<div className="mb-4 rounded-lg bg-k-50 p-4">
8181
<div className="mb-3 flex items-center space-x-3">
82-
<ProfileWithBadge profileImageUrl={profileImageUrl} width={48} height={48} />
82+
<ProfileWithBadge profileImageUrl={profileImageUrl} isMentor={viewAsMentor} width={48} height={48} />
8383
<div>
8484
<div className="flex items-center gap-3 space-x-2">
8585
<h3 className="text-primary typo-sb-5">{nickname}</h3>

apps/web/src/components/ui/ProfileWithBadge.tsx

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import { IconGraduation } from "@/public/svgs/mentor";
44

55
interface ProfileWithBadgeProps {
66
profileImageUrl?: string | null;
7+
isMentor?: boolean;
78
hasBadge?: boolean;
89
width?: number;
910
height?: number;
@@ -12,11 +13,14 @@ interface ProfileWithBadgeProps {
1213

1314
const ProfileWithBadge = ({
1415
profileImageUrl,
16+
isMentor,
1517
hasBadge = false,
1618
width = 86,
1719
height = 86,
1820
isBadgeUp = true,
1921
}: ProfileWithBadgeProps) => {
22+
const showMentorBadge = isMentor ?? hasBadge;
23+
2024
// 배지 크기를 전체 크기에 비례해서 계산
2125
const badgeSize = Math.round(width * 0.35);
2226
const iconSize = Math.round(badgeSize * 0.67);
@@ -26,7 +30,7 @@ const ProfileWithBadge = ({
2630
{/* 프로필 이미지 */}
2731
<div
2832
className={`h-full w-full overflow-hidden rounded-full ${
29-
hasBadge ? "border-2 border-primary-1" : "border border-gray-200"
33+
showMentorBadge ? "border-2 border-primary-1" : "border border-gray-200"
3034
}`}
3135
>
3236
<Image
@@ -42,7 +46,7 @@ const ProfileWithBadge = ({
4246
</div>
4347

4448
{/* 학습 상태 배지 */}
45-
{hasBadge && (
49+
{showMentorBadge && (
4650
<div
4751
className={`absolute -right-1 flex items-center justify-center rounded-full bg-primary-1 ${
4852
isBadgeUp ? "-top-1" : "-bottom-1"

0 commit comments

Comments
 (0)