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

feat: talkPick, vote, bookmark API 함수 및 react query hook 작성 #132

Merged
merged 9 commits into from
Jul 13, 2024

Conversation

kwaksj329
Copy link
Member

💡 작업 내용

  • endpoint 파일 내 주석 추가
  • talkPick, vote, bookmark API endpoint 수정
  • talkPick, vote API 관련 type 정리
  • talkPick, vote, bookmark API 함수 작성
  • talkPick, vote, bookmark react query 작성

💡 자세한 설명

✅ 투표 API - invalidateQueries (talkPick & games)

// useCreateGameVoteMutation.ts
return useMutation({
    mutationFn: (data: VoteOption) => postGameVoteResult(gameId, data),
    onSuccess: () =>
      Promise.all([
        queryClient.invalidateQueries({
          queryKey: ['gameVote', gameId],
        }),
        queryClient.invalidateQueries({
          queryKey: ['games', gameId],
        }),
      ]),
  });
  • talkPick 투표 API 성공 시 talkPickVote & talkPickId, talkPick & talkPickId key로 캐싱된 데이터 무효화
  • game 투표 API 성공 시 gameVote & gameId, games & gameId key로 캐싱된 데이터 무효화

✅ 북마크 API - invalidateQueries (talkPick & games)

// useCreateGameBookmarkMutation.ts
return useMutation({
    mutationFn: () => postGameBookmark(gameId),
    onSuccess: async () => {
      await queryClient.invalidateQueries({
        queryKey: ['games', gameId],
      });
    },
  });
  • talkPick 북마크 API 성공 시 talkPick & talkPickId key로 캐싱된 데이터 무효화
  • game 북마크 API 성공 시 games & gameId key로 캐싱된 데이터 무효화

📗 참고 자료 (선택)

📢 리뷰 요구 사항 (선택)

🚩 후속 작업 (선택)

✅ 톡픽 좋아요 관련 API 확인 및 invalidate 필요

현재 배포된 API 중 좋아요 기능을 가진 API는 댓글과 관련된 API만 있는 것으로 확인했습니다.
톡픽 상세조회에도 좋아요 속성이 있기 때문에 백엔드 측에 톡픽 좋아요 관련 API 아직 개발 중인지, 누락된 것인지 확인한 이후에 톡픽 좋아요 API 추가 & 'talkPick' invalidate가 필요할 것 같습니다.

✅ 셀프 체크리스트

  • PR 제목을 형식에 맞게 작성했나요?
  • 브랜치 전략에 맞는 브랜치에 PR을 올리고 있나요? (master/main이 아닙니다.)
  • 이슈는 close 했나요?
  • Reviewers, Labels, Projects를 등록했나요?
  • 작업 도중 문서 수정이 필요한 경우 잘 수정했나요?
  • 테스트는 잘 통과했나요?
  • 불필요한 코드는 제거했나요?

closes #130

@kwaksj329 kwaksj329 added ✔︎pull requests pull requests 코드 체크 요청 👩🏻‍💻 frontend 프론트엔드 작업 ✅feature labels Jul 6, 2024
@kwaksj329 kwaksj329 requested review from hsgh085 and areumH July 6, 2024 18:32
@kwaksj329 kwaksj329 self-assigned this Jul 6, 2024
Copy link
Collaborator

@hsgh085 hsgh085 left a comment

Choose a reason for hiding this comment

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

talkPick, vote, bookmark API 함수 작성하시고, 리액트 쿼리로 분리하시느라 고생 많으셨어요~! 👏

src/constants/api.ts Outdated Show resolved Hide resolved
@kwaksj329 kwaksj329 merged commit 6697b68 into dev Jul 13, 2024
3 checks passed
@kwaksj329 kwaksj329 deleted the feat/130-talk-api-hook branch July 13, 2024 15:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
✅feature 👩🏻‍💻 frontend 프론트엔드 작업 ✔︎pull requests pull requests 코드 체크 요청
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

talk api 관련 react query hook 작성
2 participants