From 44fe461f885e7a7a7f6ec15cfb59149213f0f844 Mon Sep 17 00:00:00 2001 From: Dobbymin Date: Tue, 15 Oct 2024 23:18:58 +0900 Subject: [PATCH] =?UTF-8?q?Feat(challenge-completes):=20=EC=99=84=EB=A3=8C?= =?UTF-8?q?=ED=95=9C=20=EC=B1=8C=EB=A6=B0=EC=A7=80=20api=20=ED=98=B8?= =?UTF-8?q?=EC=B6=9C=20=EA=B8=B0=EB=8A=A5=20=EA=B5=AC=ED=98=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../challenge-completes.api.ts | 27 +++++++++++++++++++ .../challenge-completes.response.ts | 18 +++++++++++++ 2 files changed, 45 insertions(+) create mode 100644 src/apis/challenge-completes/challenge-completes.api.ts create mode 100644 src/apis/challenge-completes/challenge-completes.response.ts diff --git a/src/apis/challenge-completes/challenge-completes.api.ts b/src/apis/challenge-completes/challenge-completes.api.ts new file mode 100644 index 0000000..0b956bf --- /dev/null +++ b/src/apis/challenge-completes/challenge-completes.api.ts @@ -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 => { + const response = await axiosClient.get(challengeCompletesPath(), { + params: { + page, + size, + }, + }); + return response.data; +}; + +export const useGetChallengeCompletes = (page: number, size: number) => { + return useQuery({ + queryKey: [ChallengeCompletesQueryKey, page, size], + queryFn: () => getChallengeCompletes(page, size), + }); +}; diff --git a/src/apis/challenge-completes/challenge-completes.response.ts b/src/apis/challenge-completes/challenge-completes.response.ts new file mode 100644 index 0000000..feec96c --- /dev/null +++ b/src/apis/challenge-completes/challenge-completes.response.ts @@ -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;