From f0c48266f9bd27e5d6be838fbbb40e03daab7eae Mon Sep 17 00:00:00 2001 From: iOdiO89 <117376841+iOdiO89@users.noreply.github.com> Date: Tue, 2 Jul 2024 01:59:51 +0900 Subject: [PATCH] =?UTF-8?q?feat:=20/challenges/attendance=20post=20API=20?= =?UTF-8?q?=EC=97=B0=EA=B2=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apis/challenge.ts | 13 +++++++++++++ apis/hooks/challenge.ts | 13 +++++++++++++ 2 files changed, 26 insertions(+) diff --git a/apis/challenge.ts b/apis/challenge.ts index 3ea3c3b..40afdc3 100644 --- a/apis/challenge.ts +++ b/apis/challenge.ts @@ -25,6 +25,11 @@ interface getChallengeSearchResponse extends ResponseBody2 { result: Challenge[]; } +export interface AttendanceRequestBody { + challengeIdx: number; + attendanceCode: string; +} + async function getMyChallengeList(): Promise { const { data } = await client.get(`/challenges`); return data; @@ -49,9 +54,17 @@ async function postNewChallenge(challengeIdx: number): Promise { return data; } +async function postAttendance( + body: AttendanceRequestBody, +): Promise { + const { data } = await client.post(`/challenges/attendance`, body); + return data; +} + export { getMyChallengeList, getChallengeAds, getChallengeSearch, postNewChallenge, + postAttendance, }; diff --git a/apis/hooks/challenge.ts b/apis/hooks/challenge.ts index 3055a43..e990c9a 100644 --- a/apis/hooks/challenge.ts +++ b/apis/hooks/challenge.ts @@ -1,7 +1,9 @@ import { + AttendanceRequestBody, getChallengeAds, getChallengeSearch, getMyChallengeList, + postAttendance, postNewChallenge, } from "../challenge"; import { useMutation, useQuery, useQueryClient } from "@tanstack/react-query"; @@ -54,9 +56,20 @@ function usePostNewChallenge( return { mutate }; } +function usePostAttendance() { + const queryClient = useQueryClient(); + const { mutate } = useMutation({ + mutationKey: ["postAttendance"], + mutationFn: (body: AttendanceRequestBody) => postAttendance(body), + }); + + return { mutate }; +} + export { useGetMyChallengeList, useGetChallengeAds, useGetChallengeSearch, usePostNewChallenge, + usePostAttendance, };