From 586d46e01b0028b3eb288d3a6b83aaf1f5f90497 Mon Sep 17 00:00:00 2001 From: hae-on Date: Thu, 19 Oct 2023 10:49:21 +0900 Subject: [PATCH] =?UTF-8?q?fix:=20=EB=A6=AC=EB=B7=B0=20=EC=83=81=EC=84=B8?= =?UTF-8?q?=20api=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../queries/review/useReviewDetailQuery.ts | 4 +- frontend/src/mocks/data/reviewDetail.json | 52 +++++++++---------- frontend/src/pages/ReviewDetailPage.tsx | 2 +- frontend/src/router/index.tsx | 18 +++---- frontend/src/types/response.ts | 4 +- 5 files changed, 38 insertions(+), 42 deletions(-) diff --git a/frontend/src/hooks/queries/review/useReviewDetailQuery.ts b/frontend/src/hooks/queries/review/useReviewDetailQuery.ts index a80914053..4b043a93b 100644 --- a/frontend/src/hooks/queries/review/useReviewDetailQuery.ts +++ b/frontend/src/hooks/queries/review/useReviewDetailQuery.ts @@ -1,11 +1,11 @@ import { useSuspendedQuery } from '../useSuspendedQuery'; import { reviewApi } from '@/apis'; -import type { ReviewDetailResponse } from '@/types/response'; +import type { ReviewDetail } from '@/types/review'; const fetchReviewDetail = async (reviewId: number) => { const response = await reviewApi.get({ params: `/${reviewId}` }); - const data: ReviewDetailResponse = await response.json(); + const data: ReviewDetail = await response.json(); return data; }; diff --git a/frontend/src/mocks/data/reviewDetail.json b/frontend/src/mocks/data/reviewDetail.json index 4439f7d43..9d0bcc097 100644 --- a/frontend/src/mocks/data/reviewDetail.json +++ b/frontend/src/mocks/data/reviewDetail.json @@ -1,29 +1,27 @@ { - "reviews": { - "id": 1, - "userName": "펀잇", - "profileImage": "https://github.com/woowacourse-teams/2023-fun-eat/assets/78616893/1f0fd418-131c-4cf8-b540-112d762b7c34", - "image": "https://i.namu.wiki/i/9wnvUaEa1EkDqG-M0Pbwfdf19FJQQXV_-bnlU2SYaNcG05y2wbabiIrfrGES1M4xSgDjY39RwOvLNggDd3Huuw.webp", - "rating": 4.5, - "tags": [ - { - "id": 5, - "name": "단짠단짠", - "tagType": "TASTE" - }, - { - "id": 1, - "name": "망고망고", - "tagType": "TASTE" - } - ], - "content": "맛있어용~!~!", - "rebuy": true, - "favoriteCount": 1320, - "favorite": true, - "createdAt": "2023-10-13T00:00:00", - "categoryType": "food", - "productId": 1, - "productName": "칠성 사이다" - } + "id": 1, + "userName": "펀잇", + "profileImage": "https://github.com/woowacourse-teams/2023-fun-eat/assets/78616893/1f0fd418-131c-4cf8-b540-112d762b7c34", + "image": "https://i.namu.wiki/i/9wnvUaEa1EkDqG-M0Pbwfdf19FJQQXV_-bnlU2SYaNcG05y2wbabiIrfrGES1M4xSgDjY39RwOvLNggDd3Huuw.webp", + "rating": 4.5, + "tags": [ + { + "id": 5, + "name": "단짠단짠", + "tagType": "TASTE" + }, + { + "id": 1, + "name": "망고망고", + "tagType": "TASTE" + } + ], + "content": "맛있어용~!~!", + "rebuy": true, + "favoriteCount": 1320, + "favorite": true, + "createdAt": "2023-10-13T00:00:00", + "categoryType": "food", + "productId": 1, + "productName": "칠성 사이다" } diff --git a/frontend/src/pages/ReviewDetailPage.tsx b/frontend/src/pages/ReviewDetailPage.tsx index 7447e88e2..9cc209bf5 100644 --- a/frontend/src/pages/ReviewDetailPage.tsx +++ b/frontend/src/pages/ReviewDetailPage.tsx @@ -24,7 +24,7 @@ export const ReviewDetailPage = () => { tags, content, favoriteCount, - } = reviewDetail.reviews; + } = reviewDetail; const theme = useTheme(); diff --git a/frontend/src/router/index.tsx b/frontend/src/router/index.tsx index d045e8dc3..d24db3150 100644 --- a/frontend/src/router/index.tsx +++ b/frontend/src/router/index.tsx @@ -51,15 +51,6 @@ const router = createBrowserRouter([ return { Component: MemberRecipePage }; }, }, - { - path: `${PATH.REVIEW}/:reviewId`, - async lazy() { - const { ReviewDetailPage } = await import( - /* webpackChunkName: "ReviewDetailPage" */ '@/pages/ReviewDetailPage' - ); - return { Component: ReviewDetailPage }; - }, - }, ], }, { @@ -78,6 +69,15 @@ const router = createBrowserRouter([ return { Component: HomePage }; }, }, + { + path: `${PATH.REVIEW}/:reviewId`, + async lazy() { + const { ReviewDetailPage } = await import( + /* webpackChunkName: "ReviewDetailPage" */ '@/pages/ReviewDetailPage' + ); + return { Component: ReviewDetailPage }; + }, + }, ], }, { diff --git a/frontend/src/types/response.ts b/frontend/src/types/response.ts index bac466ebf..b2935328a 100644 --- a/frontend/src/types/response.ts +++ b/frontend/src/types/response.ts @@ -63,9 +63,7 @@ export interface MemberRecipeResponse { page: Page; recipes: MemberRecipe[]; } -export interface ReviewDetailResponse { - reviews: ReviewDetail; -} + export interface CommentResponse { hasNext: boolean; totalElements: number | null;