From 3844e6186a9c13a4c8f94e7858feb4f805671331 Mon Sep 17 00:00:00 2001 From: soosoo22 Date: Fri, 26 Jul 2024 09:48:10 +0900 Subject: [PATCH] =?UTF-8?q?[FE]=20msw=20=EB=AA=A8=ED=82=B9=EC=9D=84=20?= =?UTF-8?q?=EC=9C=84=ED=95=9C=20=EB=A6=AC=EB=B7=B0=20=EB=8D=B0=EC=9D=B4?= =?UTF-8?q?=ED=84=B0=20=ED=95=98=EB=93=9C=EC=BD=94=EB=94=A9=20(#130)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * refactor: msw 모킹을 위한 리뷰 데이터 하드코딩 Co-Authored-By: ImxYJL <111052302+ImxYJL@users.noreply.github.com> * refactor: 2차 데모데이를 위한 멤버 아이디 상수화 Co-Authored-By: ImxYJL <111052302+ImxYJL@users.noreply.github.com> Co-Authored-By: badahertz52 Co-Authored-By: Fe <64690761+chysis@users.noreply.github.com> * chore: 불필요한 콘솔 로그 제거 Co-Authored-By: ImxYJL <111052302+ImxYJL@users.noreply.github.com> Co-Authored-By: badahertz52 Co-Authored-By: Fe <64690761+chysis@users.noreply.github.com> --------- Co-authored-by: ImxYJL <111052302+ImxYJL@users.noreply.github.com> Co-authored-by: badahertz52 Co-authored-by: Fe <64690761+chysis@users.noreply.github.com> --- frontend/src/apis/review.ts | 2 +- frontend/src/mocks/handlers/review.ts | 2 +- frontend/src/pages/ReviewPreviewListPage/index.tsx | 10 ++++++---- 3 files changed, 8 insertions(+), 6 deletions(-) diff --git a/frontend/src/apis/review.ts b/frontend/src/apis/review.ts index 84c23550d..9790f0df0 100644 --- a/frontend/src/apis/review.ts +++ b/frontend/src/apis/review.ts @@ -70,7 +70,7 @@ export const getReviewListApi = async ({ if (!response.ok) { throw new Error('리뷰 리스트를 불러오는 데 실패했습니다.'); } - console.log(response); + const data = await response.json(); return data; }; diff --git a/frontend/src/mocks/handlers/review.ts b/frontend/src/mocks/handlers/review.ts index 151afca6c..2c065c259 100644 --- a/frontend/src/mocks/handlers/review.ts +++ b/frontend/src/mocks/handlers/review.ts @@ -7,7 +7,7 @@ import { REVIEW_PREVIEW_LIST } from '../mockData/reviewPreviewList'; import { REVIEW_WRITING_DATA } from '../mockData/reviewWritingData'; const getDetailedReview = () => - http.get(endPoint.gettingDetailedReview(0, 1), async ({ request }) => { + http.get(endPoint.gettingDetailedReview(123456, 123456), async ({ request }) => { return HttpResponse.json(DETAILED_REVIEW_MOCK_DATA); }); diff --git a/frontend/src/pages/ReviewPreviewListPage/index.tsx b/frontend/src/pages/ReviewPreviewListPage/index.tsx index c6b7cfdec..7b81cd73f 100644 --- a/frontend/src/pages/ReviewPreviewListPage/index.tsx +++ b/frontend/src/pages/ReviewPreviewListPage/index.tsx @@ -9,7 +9,8 @@ import SearchSection from './components/SearchSection'; import * as S from './styles'; const USER_SEARCH_PLACE_HOLDER = '레포지토리명을 검색하세요.'; -const options = ['최신순', '오래된순']; +const OPTIONS = ['최신순', '오래된순']; +const MEMBER_ID = 2; const ReviewPreviewListPage = () => { const [reviews, setReviews] = useState([]); @@ -21,7 +22,7 @@ const ReviewPreviewListPage = () => { useEffect(() => { const fetchReviews = async () => { try { - const data = await getReviewListApi({ revieweeId: 1, lastReviewId: 3, memberId: 1 }); + const data = await getReviewListApi({ revieweeId: 1, lastReviewId: 5, memberId: MEMBER_ID }); setReviews(data.reviews); setLoading(false); } catch (error) { @@ -34,13 +35,14 @@ const ReviewPreviewListPage = () => { }, []); const handleReviewClick = (id: number) => { - navigate(`/user/detailed-review/${id}?memberId=${4}`); + navigate(`/user/detailed-review/${id}?memberId=${MEMBER_ID}`); + // navigate(`/user/detailed-review/${123456}?memberId=${123456}`); // NOTE: MSW용 하드코딩 }; return ( <> - {}} options={options} placeholder={USER_SEARCH_PLACE_HOLDER} /> + {}} options={OPTIONS} placeholder={USER_SEARCH_PLACE_HOLDER} /> {loading &&

로딩 중...

} {error &&

{error}

}