-
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 #196 from KNU-HAEDAL/develop
완료한 챌린지 api 호출 기능 수정
- Loading branch information
Showing
11 changed files
with
140 additions
and
79 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 { axiosClient } from '../AxiosClient'; | ||
import { ChallengeCompletesResponse } from './challenge-completes.response'; | ||
import { useQuery } from '@tanstack/react-query'; | ||
|
||
export const challengeCompletesPath = () => '/api/user/challenges/completes'; | ||
|
||
export const ChallengeCompletesQueryKey = [challengeCompletesPath()]; | ||
|
||
export const getChallengeCompletes = async ( | ||
page: number, | ||
size: number | ||
): Promise<ChallengeCompletesResponse> => { | ||
const response = await axiosClient.get(challengeCompletesPath(), { | ||
params: { | ||
page, | ||
size, | ||
}, | ||
}); | ||
return response.data; | ||
}; | ||
|
||
export const useGetChallengeCompletes = (page: number, size: number) => { | ||
return useQuery<ChallengeCompletesResponse, Error>({ | ||
queryKey: [ChallengeCompletesQueryKey, page, size], | ||
queryFn: () => getChallengeCompletes(page, size), | ||
}); | ||
}; |
18 changes: 18 additions & 0 deletions
18
src/apis/challenge-completes/challenge-completes.response.ts
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,18 @@ | ||
import ApiResponse from '../ApiResponse'; | ||
|
||
export type ChallengeData = { | ||
id: number; | ||
challengeGroupId: number; | ||
title: string; | ||
successDate: string; | ||
category: 'HEALTH' | 'ECHO' | 'SHARE' | 'VOLUNTEER'; | ||
reviewWritten: boolean; | ||
}; | ||
|
||
export type ChallengeCompletes = { | ||
totalPage: number; | ||
hasNext: boolean; | ||
data: ChallengeData[]; | ||
}; | ||
|
||
export type ChallengeCompletesResponse = ApiResponse<ChallengeCompletes>; |
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
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
Oops, something went wrong.