-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Feat(recently-review): api 호출 기능 구현 및 response data type 지정
- Loading branch information
Showing
2 changed files
with
51 additions
and
0 deletions.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
import { RecentlyReviewResponse } from './getRecentlyReview.response'; | ||
import { axiosClient } from '@/apis/AxiosClient'; | ||
import { useQuery } from '@tanstack/react-query'; | ||
|
||
const getRecentlyReviewPath = () => '/api/challengeGroups/shorts'; | ||
|
||
const recentlyReviewQueryKey = [getRecentlyReviewPath()]; | ||
|
||
const getRecentlyReview = async ( | ||
page: number, | ||
size: number | ||
): Promise<RecentlyReviewResponse> => { | ||
const response = await axiosClient.get(getRecentlyReviewPath(), { | ||
params: { | ||
page, | ||
size, | ||
}, | ||
}); | ||
return response.data; | ||
}; | ||
|
||
export const useGetRecentlyReview = (page: number, size: number) => { | ||
return useQuery<RecentlyReviewResponse, Error>({ | ||
queryKey: [recentlyReviewQueryKey, page, size], | ||
queryFn: () => getRecentlyReview(page, size), | ||
}); | ||
}; |
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,24 @@ | ||
import ApiResponse from '@/apis/ApiResponse'; | ||
|
||
export type RecentlyReviewResponse = { | ||
totalPage: number; | ||
hasNext: boolean; | ||
data: { | ||
challengeId: number; | ||
challengeTitle: string; | ||
user: { | ||
id: number; | ||
nickname: string; | ||
profileImageUrl: string; | ||
tierInfo: { | ||
tier: string; | ||
totalExp: number; | ||
currentExp: number; | ||
}; | ||
}; | ||
content: string; | ||
rating: number; | ||
}[]; | ||
}; | ||
|
||
export type ChallengeListResponse = ApiResponse<RecentlyReviewResponse>; |