diff --git a/apis/challenge.ts b/apis/challenge.ts index 8dea8d5..a7e55a2 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; @@ -66,10 +71,18 @@ 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, - getChallengDetail + postAttendance, + getChallengDetail, }; diff --git a/apis/hooks/challenge.ts b/apis/hooks/challenge.ts index 2242fa1..fa63eb8 100644 --- a/apis/hooks/challenge.ts +++ b/apis/hooks/challenge.ts @@ -1,13 +1,14 @@ import { + AttendanceRequestBody, getChallengeAds, getChallengeSearch, getMyChallengeList, + postAttendance, postNewChallenge, getChallengDetail, } from "../challenge"; import { useMutation, useQuery, useQueryClient } from "@tanstack/react-query"; - function useGetMyChallengeList() { const { data } = useQuery({ queryKey: ["getMyChallengeList"], @@ -64,11 +65,21 @@ 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, useGetChallengeDetail, }; - diff --git a/components/HeadFunction.tsx b/components/HeadFunction.tsx index 30c5a3f..4f91c3e 100644 --- a/components/HeadFunction.tsx +++ b/components/HeadFunction.tsx @@ -1,6 +1,5 @@ import { useRouter } from "next/router"; import FlexBox from "./Flexbox"; -import Image from "next/image"; import Head from "next/head"; import LeftArrowIcon from "@/public/svgs/LeftArrow.svg"; diff --git a/components/home/certifyModal.tsx b/components/home/certifyModal.tsx index 22c3532..6e5155e 100644 --- a/components/home/certifyModal.tsx +++ b/components/home/certifyModal.tsx @@ -2,7 +2,7 @@ import { InputError } from "@/pages/mypage/password"; import FlexBox from "../Flexbox"; import TextInput from "../Input"; import { useState } from "react"; -import Image from "next/image"; +import CloseIcon from "@/public/svgs/Close.svg"; interface CertifyModalProps { setIsModalVisible: React.Dispatch>; @@ -29,7 +29,7 @@ export default function CertifyModal({
챌린지 인증하기
setIsModalVisible(false)}> - +
diff --git a/components/home/challengeBox.tsx b/components/home/challengeBox.tsx index 98f6262..71b9521 100644 --- a/components/home/challengeBox.tsx +++ b/components/home/challengeBox.tsx @@ -8,7 +8,6 @@ import { useAtom } from "jotai"; import CertifyModal from "./certifyModal"; import { useState } from "react"; import ReactModal from "react-modal"; -import Image from "next/image"; import { useGetMyChallengeList } from "@/apis/hooks/challenge"; import AdminChallenge from "./adminChallenge"; diff --git a/components/home/header.tsx b/components/home/header.tsx deleted file mode 100644 index 05878a8..0000000 --- a/components/home/header.tsx +++ /dev/null @@ -1,10 +0,0 @@ -import { NextPage } from "next"; -import Image from "next/image"; - -export const HomeHeader: NextPage = () => { - return ( -
- -
- ); -}; diff --git a/components/home/searchBar.tsx b/components/home/searchBar.tsx index c8b3b25..c50090c 100644 --- a/components/home/searchBar.tsx +++ b/components/home/searchBar.tsx @@ -1,6 +1,7 @@ import { NextPage } from "next"; import FlexBox from "../Flexbox"; -import Image from "next/image"; +import SearchIcon from "@/public/svgs/Search.svg"; +import CloseIcon from "@/public/svgs/Close_Circle.svg"; import { ChangeEvent } from "react"; interface SearchBarProps { @@ -19,8 +20,8 @@ export default function SearchBar({ value, setValue }: SearchBarProps) { return (
- - + +
- +
diff --git a/components/mypage/profile.tsx b/components/mypage/profile.tsx index 18870f3..2fdbd0d 100644 --- a/components/mypage/profile.tsx +++ b/components/mypage/profile.tsx @@ -1,4 +1,3 @@ -import Image from "next/image"; import FlexBox from "../Flexbox"; import { useRouter } from "next/router"; import RightArrowIcon from "@/public/svgs/RightArrow.svg"; diff --git a/pages/challenge/join.tsx b/pages/challenge/join.tsx index 8df79f1..ccae235 100644 --- a/pages/challenge/join.tsx +++ b/pages/challenge/join.tsx @@ -5,7 +5,6 @@ import NavBar from "@/components/NavBar"; import SearchBar from "@/components/home/searchBar"; import SearchResult from "@/components/home/searchResult"; import { NextPage } from "next"; -import Image from "next/image"; import { useState } from "react"; import { toast, ToastContainer, Zoom } from "react-toastify"; import "react-toastify/dist/ReactToastify.css"; diff --git a/pages/index.tsx b/pages/index.tsx index 55531bd..f729a02 100644 --- a/pages/index.tsx +++ b/pages/index.tsx @@ -3,11 +3,9 @@ import { NextPage } from "next"; import NavBar from "@/components/NavBar"; import Challenge from "@/components/home/challenge"; import HomeCarousel from "@/components/home/carousel"; -import { HomeHeader } from "@/components/home/header"; import HomeChallenge from "@/components/home/challengeBox"; import FlexBox from "@/components/Flexbox"; import { ToastContainer, Zoom, toast } from "react-toastify"; -import Image from "next/image"; import "react-toastify/dist/ReactToastify.css"; import CheckIcon from "@/public/svgs/Check.svg"; import { atom, useAtomValue } from "jotai";