diff --git a/src/apis/recently-review/getRecentlyReview.api.ts b/src/apis/recently-review/getRecentlyReview.api.ts new file mode 100644 index 0000000..ff46c42 --- /dev/null +++ b/src/apis/recently-review/getRecentlyReview.api.ts @@ -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 => { + const response = await axiosClient.get(getRecentlyReviewPath(), { + params: { + page, + size, + }, + }); + return response.data; +}; + +export const useGetRecentlyReview = (page: number, size: number) => { + return useQuery({ + queryKey: [recentlyReviewQueryKey, page, size], + queryFn: () => getRecentlyReview(page, size), + }); +}; diff --git a/src/apis/recently-review/getRecentlyReview.response.ts b/src/apis/recently-review/getRecentlyReview.response.ts new file mode 100644 index 0000000..3d69449 --- /dev/null +++ b/src/apis/recently-review/getRecentlyReview.response.ts @@ -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;