Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

대기실 페이지 2차 작업 #114

Open
wants to merge 37 commits into
base: dev
Choose a base branch
from

Conversation

kim-hyunjoo
Copy link
Contributor

@kim-hyunjoo kim-hyunjoo commented Feb 4, 2025

📝작업 내용

  • css 수정 내용
    • 방장 아니면 댓글 창 높이 100%로 변경
    • 사용자 본인 이름 색 primary-400
    • 게임 시작 시 UserInfoCard 색상 원래대로 수정
    • FinalResultChart bar 0보이던 현상, 삐뚤어진 css 수정
    • BalanceGameQuestionCard 박스 padding 부여
    • 횡스크롤 적용
  • 디렉토리 리팩토링
    • page 단위가 너무 커져서 _component 안으로 정리 완료
app
ㄴbalance-game/[roomId]
 ㄴ_component
    ㄴGamePanel.tsx(가운데, PrevGame을 제외하고는 게임마다 달라질 예정이라 구조 고민이 필요함)
    ㄴPrevGame.tsx(Panel에 들어감, 모든 게임에서 사용)
    ㄴRoomControl.tsx(모든 게임에서 사용 될 것 같으나 세부 내용은 달라짐)
    ㄴUserList.tsx(왼쪽, 모든 게임에서 사용)
 ㄴpage.tsx
  • 플레이어 전원 선택 시 바로 결과창으로 넘어가는 로직 추가
  • 게임 종료 후 대기실로 돌아갈 때 채팅 초기화 로직 추가
  • 닉네임 변경 아이콘 및 로직 추가

이슈 내역

  • 닉네임 변경 후 방 상세 조회 시 변경 전 이름의 유저가 사라지지 않는 현상(백엔드 확인 필요)
  • players를 store로 관리하는 것에 대한 고민
    • state는 바로 변하지 않는다.
    • 생각보다 많은 곳에서 동기화가 필요함. (모든 걸 수동으로 하기 힘들다.)

📷스크린샷(필요 시)

2025-02-04.9.29.12.mov

전원 선택 시 바로 결과 창으로 이동한다.

2025-02-04.9.34.12.mov

게임 종료 시 채팅창을 초기화 한다.

✨PR Point

  • 반영해야할 사항 또 생기면 말씀해주세요!

- add, reset 함수도 추가
- 선택을 완료한 플레이어들의 이름을 저장한다.
- 게임 시작 시 UserInfoCard 색상 원래대로 변경
- handleEnterNextRound로 함수 통합
- useEffect문에 if문 추가
- api 폴더 생성 및 기존 roomDetail 훅 이동
- 중복 로직 쿼리로 통합
- refetch 이용해 쿼리 데이터 업데이트
- 다음 라운드 이동 시 쿼리 데이터 삭제
- 겹치는 로직 하나로 통일
- 쿼리 불필요해져서 다시 삭제
- page가 너무 커져서 분리
- 추후에 새로운 게임 추가되면 그에 맞춰 변경 될 예정
- UserList section 디자인 이관
@kim-hyunjoo kim-hyunjoo added ✨기능 새로운 기능 추가 ♻️리팩토링 코드 리팩토링 (성능 및 코드 로직 개선) labels Feb 4, 2025
@kim-hyunjoo kim-hyunjoo requested review from ksjdev and joyswim February 4, 2025 12:35
@kim-hyunjoo kim-hyunjoo self-assigned this Feb 4, 2025
@kim-hyunjoo kim-hyunjoo linked an issue Feb 4, 2025 that may be closed by this pull request
6 tasks
Comment on lines +54 to +57
<div className="fixed w-full h-screen -z-10">
<StarsBackground />
<ShootingStars />
</div>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[기록용] 별똥별 배경이 다른 컴포넌트 위로 올라오는 이슈 수정

/>
{votes1 !== 0 && (
<BarItem
className={clsx('bg-primary', votes2 === 0 && 'rounded-r-full')}
Copy link
Contributor

@joyswim joyswim Feb 13, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

clsx 사용보다 cn 유틸함수를 사용해보는 건 어떨까요? cn 유틸함수는 clsx, twMerge를 조합한 함수입니다.

  • clsx는 조건부 className을 하나로 합쳐주는 역할입니다.
  • twMerge는 중복되거나 불필요한 TailwindCSS className을 제거하여 최적화합니다.

Comment on lines +170 to +175
setChatMessages(() => [
{
sender: SOCKET.SYSTEM,
content: '게임이 종료되었습니다.',
},
]);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

디테일 좋아요! 👍

Comment on lines +181 to +187
case SOCKET.TYPE.ERROR:
toast({
variant: 'destructive',
title: '문제가 생겼습니다. 다시 시도해주세요.',
});
router.push(PATH.HOME);
break;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

에러 챙겨주셔서 감사합니다👍

Copy link
Contributor

@joyswim joyswim left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

고생하셨습니다!

플레이어 전원 선택 시 바로 결과창으로 넘어가는 로직 추가 아이디어가 좋다고 생각합니다!
그런데 우려되는 점은 무의미한 선택하면서 고민하는 사람도 있을 것 같다는 생각이 들어요. 선택은 바꿀 수 있으니까요. 타이머가 있으니 충분히 고민할 시간을 주고, 방장에게만 모두 선택 시 결과로 가는 버튼을 보여주는 건 어떨까요? 채팅이 있으니 팀원 간에 소통도 가능하구요!

Copy link
Member

@ksjdev ksjdev left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

고생하셨어요 현주님! 리뷰 내용 한 번 봐주세요~~

Comment on lines +18 to +28
const handleEnterNextRound = async () => {
sendMessage({
destination: `${SOCKET.ENDPOINT.BALANCE_GAME.NEXT}`,
});
};

const handleMoveToWaitingRoom = () => {
sendMessage({
destination: `${SOCKET.ENDPOINT.BALANCE_GAME.END}`,
});
};
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P3;
async 키워드가 사용되지 않아도 되는 곳에 붙어있는 것 같습니다.
만약 client.current?.publish 로직을 사용하는데에 async 키워드가 필요하다면 통일해주시면 좋을 것 같아요~

/>
{votes2 !== 0 && (
<BarItem
className={clsx('bg-secondary', votes1 === 0 && 'rounded-l-full')}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

36번쨰 줄 리뷰와 동일합니다.

)}
{players.map((data, index) => (
<UserInfoCard
key={index}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1;
생각해보니 키값으로 인덱스를 사용해도 괜찮을까요? 유저 목록의 변동이 잦은 경우, 잘못된 값을 재사용할 가능성이 존재할 것 같다고 느껴지는데 어떻게 생각하시나요?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
♻️리팩토링 코드 리팩토링 (성능 및 코드 로직 개선) ✨기능 새로운 기능 추가
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[GRPHI-133] 대기실 페이지 2차 작업
3 participants