From 62e7ef9388c0d63ee0c623370c34b8228b580d69 Mon Sep 17 00:00:00 2001 From: cindy Date: Sun, 12 Feb 2023 18:20:34 +0900 Subject: [PATCH] =?UTF-8?q?fix:=20feelStatus=20name=20feel=EB=A1=9C=20?= =?UTF-8?q?=EB=90=98=EC=96=B4=20=EC=9E=88=EB=8A=94=20=EA=B2=83=20field=20?= =?UTF-8?q?=EC=88=98=EC=A0=95=20=EB=B0=8F=20mock=20data=EB=A1=9C=20?= =?UTF-8?q?=ED=99=95=EC=9D=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/constants/dummy.ts | 8 ++++++ src/pages/reviews/create/[beerId].page.tsx | 28 +++++++++---------- .../ReviewDetailContainer.tsx | 6 ++-- .../ReviewFeelStatusContainer.tsx | 2 +- .../ReviewFlavorsContainer.tsx | 4 ++- 5 files changed, 29 insertions(+), 19 deletions(-) diff --git a/src/constants/dummy.ts b/src/constants/dummy.ts index 60af621..3676cb6 100644 --- a/src/constants/dummy.ts +++ b/src/constants/dummy.ts @@ -179,6 +179,14 @@ export const MOCK_FLAVORS: IFlavor[] = [ id: 3, content: '쓴 맛이 나요', }, + { + id: 4, + content: '쓴 맛이 나요', + }, + { + id: 5, + content: '쓴 맛이 나요', + }, ]; export const MOCK_COUNTRY: ICountry = { diff --git a/src/pages/reviews/create/[beerId].page.tsx b/src/pages/reviews/create/[beerId].page.tsx index 3a7484b..6c1e3ff 100644 --- a/src/pages/reviews/create/[beerId].page.tsx +++ b/src/pages/reviews/create/[beerId].page.tsx @@ -22,8 +22,8 @@ const CreateReviewPage: NextPage = ({ beer, review }) =>
} /> - - + + @@ -42,18 +42,18 @@ export const getServerSideProps: GetServerSideProps = async (context) => { const { beerId, reviewId } = context.query; const id = reviewId || beerId; - if (id && typeof id === 'string' && Number(id)) { - if (reviewId) { - const review = await getReview(Number(id)); - const beer = await getBeer(review.beer.id); - - return { props: { beer, review } }; - } - - const beer = await getBeer(Number(id)); - - return { props: { beer } }; - } + // if (id && typeof id === 'string' && Number(id)) { + // if (reviewId) { + // const review = await getReview(Number(id)); + // const beer = await getBeer(review.beer.id); + // + // return { props: { beer, review } }; + // } + // + // const beer = await getBeer(Number(id)); + // + // return { props: { beer } }; + // } return { props: {} }; }; diff --git a/src/pages/reviews/create/components/ReviewDetailContainer/ReviewDetailContainer.tsx b/src/pages/reviews/create/components/ReviewDetailContainer/ReviewDetailContainer.tsx index bb779dc..a7f1d6a 100644 --- a/src/pages/reviews/create/components/ReviewDetailContainer/ReviewDetailContainer.tsx +++ b/src/pages/reviews/create/components/ReviewDetailContainer/ReviewDetailContainer.tsx @@ -73,12 +73,12 @@ const ReviewDetailContainer: React.FC = ({ { ...reviewForm, ...data, - beerId: beer.id, + beerId: beer?.id, } as ICreateReviewPayload, { onSuccess: (_data) => router.push(`/record/ticket/${_data.id}?type=${NEW_TYPE}`) }, ); }, - [createReviewMutation, reviewForm, beer.id, router], + [createReviewMutation, reviewForm, beer?.id, router], ); // const handleUpdateSubmit = useCallback( @@ -112,7 +112,7 @@ const ReviewDetailContainer: React.FC = ({ >

{'당신만의 맥주 이야기도 들려주세요'}

-

{beer.korName}

+

{beer?.korName}

= ({ > 이번 맥주는 어땠나요? {beerName} - + diff --git a/src/pages/reviews/create/components/ReviewFlavorsContainer/ReviewFlavorsContainer.tsx b/src/pages/reviews/create/components/ReviewFlavorsContainer/ReviewFlavorsContainer.tsx index 9bd613d..d65c30a 100644 --- a/src/pages/reviews/create/components/ReviewFlavorsContainer/ReviewFlavorsContainer.tsx +++ b/src/pages/reviews/create/components/ReviewFlavorsContainer/ReviewFlavorsContainer.tsx @@ -12,6 +12,7 @@ import MultiSelectField from '@/components/formFields/MultiSelectField'; import FormSubmitButton from '@/components/FormSubmitButton'; import Icon from '@/components/Icon'; import { SwiperLayoutChildProps } from '@/components/layouts/SwiperLayout'; +import { MOCK_FLAVORS as flavors } from '@/constants/dummy'; import $reviewForm from '@/recoil/atoms/reviewForm'; import { IFeelStatus } from '@/types'; @@ -28,7 +29,8 @@ const ReviewFlavorsContainer: React.FC = ({ onMovePrev, onMoveNext, }) => { - const { data: flavors } = useGetFlavors(); + // @TODO: API 정상 호출되면 Mock data 제거 + // const { data: flavors } = useGetFlavors(); const [{ feelStatus }, setRecordForm] = useRecoilState($reviewForm); const flavorOptions = useMemo(