Skip to content

Commit 54965f3

Browse files
committed
[FE] FIX: 타입 추가
1 parent dadf61e commit 54965f3

File tree

1 file changed

+48
-31
lines changed
  • src/frontend/src/components/Sidebar/UserList

1 file changed

+48
-31
lines changed

src/frontend/src/components/Sidebar/UserList/index.tsx

Lines changed: 48 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -41,18 +41,27 @@ export const UserList = () => {
4141
treeRef.current = new RedBlackTree<IUser>(compareUsers);
4242
roomApi
4343
.getParticipants(roomId.toString())
44-
.then(participants => {
45-
participants.forEach((participant: any) => {
46-
const user: IUser = {
47-
id: participant.userId,
48-
role: participant.role,
49-
nickname: participant.nickname,
50-
profileImg: participant.profileImageUrl || DefaultProfile,
51-
};
52-
treeRef.current?.insert(user);
53-
});
54-
setVersion(v => v + 1);
55-
})
44+
.then(
45+
(
46+
participants: {
47+
userId: number;
48+
role: number;
49+
nickname: string;
50+
profileImageUrl: string;
51+
}[],
52+
) => {
53+
participants.forEach(participant => {
54+
const user: IUser = {
55+
id: participant.userId,
56+
role: participant.role,
57+
nickname: participant.nickname,
58+
profileImg: participant.profileImageUrl || DefaultProfile,
59+
};
60+
treeRef.current?.insert(user);
61+
});
62+
setVersion(v => v + 1);
63+
},
64+
)
5665
.catch(error => {
5766
console.error('Error fetching participants', error);
5867
});
@@ -62,29 +71,37 @@ export const UserList = () => {
6271
// 신규 유저 정보 받기
6372
useEffect(() => {
6473
if (!roomId) return;
65-
subTopic(`/topic/room/${roomId}/user-info`, (data: any) => {
66-
console.log('📥 웹소켓 수신 (user-info):', data);
67-
if (data && data.userInfo) {
68-
const userInfo = data.userInfo;
69-
const newUser: IUser = {
70-
id: userInfo.userId,
71-
role: userInfo.role,
72-
nickname: userInfo.nickname,
73-
profileImg: userInfo.profileImageUrl || DefaultProfile,
74-
};
75-
addUser(newUser);
76-
}
77-
});
74+
subTopic(
75+
`/topic/room/${roomId}/user-info`,
76+
(data: {
77+
userInfo: { userId: number; role: number; nickname: string; profileImageUrl: string };
78+
}) => {
79+
console.log('📥 웹소켓 수신 (user-info):', data);
80+
if (data && data.userInfo) {
81+
const userInfo = data.userInfo;
82+
const newUser: IUser = {
83+
id: userInfo.userId,
84+
role: userInfo.role,
85+
nickname: userInfo.nickname,
86+
profileImg: userInfo.profileImageUrl || DefaultProfile,
87+
};
88+
addUser(newUser);
89+
}
90+
},
91+
);
7892
}, [roomId, subTopic]);
7993

8094
useEffect(() => {
8195
if (!roomId) return;
82-
subTopic(`/topic/room/${roomId}/role-change`, (data: any) => {
83-
console.log('📥 웹소켓 수신 (role-change):', data);
84-
if (data && data.targetUserId !== undefined && data.newRole !== undefined) {
85-
updateUserRole(data.targetUserId, data.newRole);
86-
}
87-
});
96+
subTopic(
97+
`/topic/room/${roomId}/role-change`,
98+
(data: { targetUserId: number; newRole: number }) => {
99+
console.log('📥 웹소켓 수신 (role-change):', data);
100+
if (data && data.targetUserId !== undefined && data.newRole !== undefined) {
101+
updateUserRole(data.targetUserId, data.newRole);
102+
}
103+
},
104+
);
88105
}, [roomId, subTopic]);
89106

90107
// 유저 추가 함수

0 commit comments

Comments
 (0)