Skip to content

Commit

Permalink
Feat(recently-review): api 호출 기능 구현 및 response data type 지정
Browse files Browse the repository at this point in the history
  • Loading branch information
Dobbymin committed Sep 30, 2024
1 parent 667d79f commit 48b1244
Show file tree
Hide file tree
Showing 2 changed files with 51 additions and 0 deletions.
27 changes: 27 additions & 0 deletions src/apis/recently-review/getRecentlyReview.api.ts
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),
});
};
24 changes: 24 additions & 0 deletions src/apis/recently-review/getRecentlyReview.response.ts
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>;

0 comments on commit 48b1244

Please sign in to comment.