Skip to content

Commit

Permalink
[fix] boostcampwm-2022#85 friendlist 수정 및 컴포넌트 호출 수정
Browse files Browse the repository at this point in the history
- 함수로 잘못 불렀던 로직 수정
- friendlist 내부 id 추가
  • Loading branch information
ktmihs committed Dec 4, 2022
1 parent a862da5 commit 1cf04df
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 10 deletions.
4 changes: 3 additions & 1 deletion frontend/src/component/Sidebar/Friends/callingList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,9 @@ const CallingList = () => {
<Content>
<h2 className="srOnly">전화연결 목록</h2>
<ul css={callingList} onDragOver={handleDragOver}>
{friendList.map((friend: friendType) => FriendItem(friend))}
{friendList.map((friend: friendType) => (
<FriendItem friend={friend} key={friend.id} />
))}
</ul>
</Content>
);
Expand Down
4 changes: 3 additions & 1 deletion frontend/src/component/Sidebar/Friends/friendList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,9 @@ const FriendList = () => {
onDragStart={handleDrag}
onDragEnd={handleDrag}>
{friendList.length ? (
friendList.map((friend: friendType) => FriendItem(friend))
friendList.map((friend: friendType) => (
<FriendItem friend={friend} key={friend.id} />
))
) : (
<div>
친구를 추가하고 <br />
Expand Down
3 changes: 2 additions & 1 deletion frontend/src/component/Sidebar/Friends/friends.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
export type friendType = {
id: string;
isCalling: boolean;
isOnline: boolean;
name: string;
nickname: string;
};
18 changes: 11 additions & 7 deletions frontend/src/guard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { useNavigate } from 'react-router-dom';
import { useEffect } from 'react';

type friendList = {
userId: string;
nickname: string;
characterName: string;
};
Expand All @@ -24,13 +25,16 @@ export const routerGuard = () => {
const friendList: friendList[] = data;
const initialList: friendsProps = {};

friendList.forEach(({ nickname }: { nickname: string }) => {
initialList[nickname] = {
isOnline: false,
name: nickname,
isCalling: false,
};
});
friendList.forEach(
({ userId, nickname }: { userId: string; nickname: string }) => {
initialList[nickname] = {
id: userId,
isOnline: false,
nickname: nickname,
isCalling: false,
};
}
);

setFriends(initialList);
} catch (e) {
Expand Down

0 comments on commit 1cf04df

Please sign in to comment.