-
Notifications
You must be signed in to change notification settings - Fork 0
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: 입덕 포인트 추가, 조회 구현 #311
Merged
Merged
Changes from 9 commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
0b23a05
feat: 입덕 포인트 타입 추가 #303
imdaxsz 626c0b3
feat: 입덕 포인트 추가, 조회 api 추가 #303
imdaxsz 805ec32
feat: 입덕 포인트 조회 query, 추가 mutation 구현 #303
imdaxsz 76614e1
cleanup: 입덕 포인트 mock data 제거 #303
imdaxsz 086b043
refactor: ShortReviewModal props 및 입덕포인트 property 이름 변경 #303
imdaxsz e633ec2
feat: 입덕 포인트 추가, 조회 구현 #303
imdaxsz 6d56210
Merge branch 'develop' of https://github.com/oduck-team/oduck-client …
imdaxsz 0a48988
fix: attractionPoints name 수정 #303
imdaxsz 0e3f5ed
refactor: ShortReviewModal 별점 수정 debounce 적용 #286
imdaxsz 5889ec0
refactor: ShortReviewModal defer 적용
imdaxsz File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
import { useMutation, useQuery, useQueryClient } from "@tanstack/react-query"; | ||
import { AxiosError } from "axios"; | ||
|
||
import useAuth from "@/features/auth/hooks/useAuth"; | ||
import { useApi } from "@/hooks/useApi"; | ||
import { useCommonToastError } from "@/libs/error"; | ||
|
||
import { AttractionType } from "../api/review"; | ||
|
||
export default function useAttractionPoint(animeId: number) { | ||
const { reviewApi } = useApi(); | ||
const { user } = useAuth(); | ||
const { toastAuthError, toastDefaultError } = useCommonToastError(); | ||
const queryClient = useQueryClient(); | ||
|
||
// 사용자가 남긴 입덕 포인트 조회 | ||
const { data: userAttraction } = useQuery({ | ||
queryKey: ["attraction", animeId, user?.name], | ||
queryFn: () => reviewApi.getUserAttractionPoint(animeId, user?.name ?? ""), | ||
enabled: Boolean(user?.name), | ||
}); | ||
|
||
// 사용자의 입덕 포인트 존재 여부 조회 | ||
const { data: status } = useQuery({ | ||
queryKey: ["attraction", animeId, "status", user?.memberId], | ||
queryFn: () => reviewApi.getUserAttractionPointStatus(animeId), | ||
}); | ||
|
||
// 입덕 포인트 추가 | ||
const addAttraction = useMutation({ | ||
mutationFn: (attractions: AttractionType[]) => | ||
reviewApi.addAttractionPoint(animeId, attractions), | ||
onSuccess: () => { | ||
queryClient.invalidateQueries(["attraction", animeId]); | ||
// TODO: 애니 입덕 포인트 통계 query 무효화 | ||
}, | ||
onError: (error) => { | ||
if (error instanceof AxiosError && error.response?.status) { | ||
const status = error.response.status; | ||
switch (status) { | ||
case 401: | ||
toastAuthError(); | ||
break; | ||
default: | ||
toastDefaultError(); | ||
break; | ||
} | ||
} | ||
}, | ||
}); | ||
|
||
return { userAttraction, status, addAttraction }; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
콘솔로그는 제거 부탁드립니다~
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
요거는 입덕 포인트 수정까지 구현한 후에 제거하려고 합니다..!