From 3e92e8a105cbd4ed041706074bee4185e40a525e Mon Sep 17 00:00:00 2001 From: Dobbymin Date: Sun, 29 Sep 2024 19:32:27 +0900 Subject: [PATCH 1/2] =?UTF-8?q?Feat:=20=EC=B1=8C=EB=A6=B0=EC=A7=80=20?= =?UTF-8?q?=EC=83=81=EC=84=B8=EB=B3=B4=EA=B8=B0=20=ED=8E=98=EC=9D=B4?= =?UTF-8?q?=EC=A7=80=20=EC=9D=B4=EB=8F=99=20=EA=B8=B0=EB=8A=A5=20=EA=B5=AC?= =?UTF-8?q?=ED=98=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../components/contents/index.tsx | 5 +++++ src/pages/challenge-list/index.tsx | 9 +++++++++ src/pages/shorts/components/info/index.tsx | 6 ++++-- src/pages/shorts/index.tsx | 18 ++++++++++++++++-- 4 files changed, 34 insertions(+), 4 deletions(-) diff --git a/src/pages/challenge-list/components/contents/index.tsx b/src/pages/challenge-list/components/contents/index.tsx index 2aa0b64..b9e4f11 100644 --- a/src/pages/challenge-list/components/contents/index.tsx +++ b/src/pages/challenge-list/components/contents/index.tsx @@ -9,6 +9,8 @@ type Props = { startDate: string; endDate: string; participantCount: number; + id: number; + onClick: (id: number) => void; }; const Contents = ({ @@ -17,11 +19,14 @@ const Contents = ({ startDate, endDate, participantCount, + onClick, + id, }: Props) => { const [isClicked, setIsClicked] = useState(false); const handleBoxClick = () => { setIsClicked(!isClicked); + onClick(id); }; const date = `${startDate} ~ ${endDate}`; diff --git a/src/pages/challenge-list/index.tsx b/src/pages/challenge-list/index.tsx index 4ea2249..8d0da1c 100644 --- a/src/pages/challenge-list/index.tsx +++ b/src/pages/challenge-list/index.tsx @@ -1,4 +1,5 @@ import { useCallback, useEffect, useMemo, useState } from 'react'; +import { useNavigate } from 'react-router-dom'; import Contents from './components/contents'; import { useGetChallengeList } from '@/apis/challenge-list/getChallengeList.api'; @@ -23,6 +24,12 @@ const ChallengeList = () => { const [allData, setAllData] = useState([]); const [page, setPage] = useState(0); + const navigate = useNavigate(); + + const handleNavigate = (id: number) => { + navigate(`/challenge/${id}`); + }; + const categoryList = useMemo( () => [ { label: '에코', data: 'ECHO' }, @@ -102,6 +109,8 @@ const ChallengeList = () => { startDate={challenge.startDate} endDate={challenge.endDate} participantCount={challenge.participantCount} + onClick={() => handleNavigate(challenge.id)} + id={challenge.id} /> ))} diff --git a/src/pages/shorts/components/info/index.tsx b/src/pages/shorts/components/info/index.tsx index b0247ae..e2df693 100644 --- a/src/pages/shorts/components/info/index.tsx +++ b/src/pages/shorts/components/info/index.tsx @@ -10,9 +10,11 @@ type Info = { type Props = { info?: Info; + onClick: (id: number) => void; + id: number; }; -const ShortsInfo = ({ info }: Props) => { +const ShortsInfo = ({ info, id, onClick }: Props) => { return ( <> @@ -36,7 +38,7 @@ const ShortsInfo = ({ info }: Props) => { : '정보 없음'} - + onClick(id)}> diff --git a/src/pages/shorts/index.tsx b/src/pages/shorts/index.tsx index 7323566..e67b4eb 100644 --- a/src/pages/shorts/index.tsx +++ b/src/pages/shorts/index.tsx @@ -1,4 +1,5 @@ import { useEffect, useState } from 'react'; +import { useNavigate } from 'react-router-dom'; import ShortsContents from './components/contents'; import ShortsImage from './components/image'; @@ -13,6 +14,7 @@ import { Mousewheel, Pagination } from 'swiper/modules'; import { Swiper, SwiperSlide } from 'swiper/react'; type Short = { + id: number; title: string; content: string; participantCount: number; @@ -33,7 +35,8 @@ const Shorts = () => { const [allData, setAllData] = useState([]); const { data, isLoading } = useGetShorts(page, 20); - console.log(data); + const navigate = useNavigate(); + useEffect(() => { if (data) { setAllData((prevData) => [...prevData, ...data.data.data]); @@ -48,18 +51,25 @@ const Shorts = () => { const contentsData = shuffleArray( allData.map((item) => ({ + id: item.id, title: item.title, content: item.content, })) ); + const handleNavigate = (id: number) => { + navigate(`/challenge/${id}`); + }; + const infoData = shuffleArray( allData.map((item) => ({ participantCount: item.participantCount, category: item.category, + id: item.id, })) ); + console.log(data?.data.data); return ( <> @@ -81,7 +91,11 @@ const Shorts = () => { {infoData && infoData[index] && ( - + handleNavigate(infoData[index].id)} + id={infoData[index].id} + info={infoData[index]} + /> )} ))} From c94d6bb824bb771ec8efde80c6f41be000381a6c Mon Sep 17 00:00:00 2001 From: Dobbymin Date: Sun, 29 Sep 2024 19:56:18 +0900 Subject: [PATCH 2/2] =?UTF-8?q?Fix(record):=20api=20=EC=BD=94=EB=93=9C=20t?= =?UTF-8?q?ype=20=EA=B4=80=EB=A0=A8=20=EC=98=A4=EB=A5=98=20=EC=88=98?= =?UTF-8?q?=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/apis/challenge-record/challenge.record.api.ts | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/apis/challenge-record/challenge.record.api.ts b/src/apis/challenge-record/challenge.record.api.ts index c6578e7..a788695 100644 --- a/src/apis/challenge-record/challenge.record.api.ts +++ b/src/apis/challenge-record/challenge.record.api.ts @@ -12,7 +12,7 @@ export async function postVerification( id: number, image: File, content: string -): Promise { +): Promise<{ data: ChallengeVerificationData; status: number }> { const formData = new FormData(); formData.append( 'body', @@ -25,7 +25,8 @@ export async function postVerification( formData ); console.log('postVerification response: ', response.data); - return response.data; + // return response.data; + return { data: response.data, status: response.status }; } // GET: /api/challenges/{challengeId}/record