-
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.
Merge pull request #176 from KNU-HAEDAL/Feat/issue-#175
최근 챌린지 리뷰
- Loading branch information
Showing
3 changed files
with
136 additions
and
41 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>; |
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