Skip to content

Commit

Permalink
Chore: 배포오류 수정
Browse files Browse the repository at this point in the history
  • Loading branch information
LeHiHo committed Jan 3, 2024
1 parent 9e38fec commit 8cf0099
Show file tree
Hide file tree
Showing 10 changed files with 1,080 additions and 1,040 deletions.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
"prettier": "^3.1.1",
"prettier-plugin-tailwindcss": "^0.5.9",
"tailwindcss": "^3.4.0",
"terser": "^5.26.0",
"typescript": "^5.2.2",
"vite": "^5.0.8"
}
Expand Down
48 changes: 45 additions & 3 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

162 changes: 81 additions & 81 deletions src/components/DetailSectionBottom/DetailReview.tsx
Original file line number Diff line number Diff line change
@@ -1,85 +1,85 @@
import { getToursReviews } from '@api/tours';
import { useEffect, useState } from 'react';
import InfiniteScroll from 'react-infinite-scroller';
import { useInfiniteQuery } from '@tanstack/react-query';
import ReviewItem from './ReviewItem';
import { StarIcon } from '@components/common/icons/Icons';
// import { getToursReviews } from '@api/tours';
// import { useEffect, useState } from 'react';
// import InfiniteScroll from 'react-infinite-scroller';
// import { useInfiniteQuery } from '@tanstack/react-query';
// import ReviewItem from './ReviewItem';
// import { StarIcon } from '@components/common/icons/Icons';

export default function DetailReview() {
const [reviewDataLength, setReviewDataLength] = useState<number>(0);
const tourItemId = 1;
// export default function DetailReview() {
// const [reviewDataLength, setReviewDataLength] = useState<number>(0);
// const tourItemId = 1;

const {
data: toursReviews,
fetchNextPage,
hasNextPage,
} = useInfiniteQuery({
queryKey: ['toursReviews'],
queryFn: ({ pageParam }) => getToursReviews(tourItemId),
initialPageParam: 0,
getNextPageParam: (lastPage, allPages, lastPageParam) => {
const lastData = lastPage?.data?.data?.reviewInfos;
return lastData && lastData.length === 4 ? lastPageParam + 1 : undefined;
},
});
// const {
// data: toursReviews,
// fetchNextPage,
// hasNextPage,
// } = useInfiniteQuery({
// queryKey: ['toursReviews'],
// queryFn: ({ pageParam }) => getToursReviews(tourItemId),
// initialPageParam: 0,
// getNextPageParam: (lastPage, allPages, lastPageParam) => {
// const lastData = lastPage?.data?.data?.reviewInfos;
// return lastData && lastData.length === 4 ? lastPageParam + 1 : undefined;
// },
// });

useEffect(() => {
if (toursReviews) {
const totalCount = toursReviews.pages.reduce(
(accumulator, page) =>
accumulator + (page?.data?.data?.reviewInfos?.length || 0),
0,
);
setReviewDataLength(totalCount);
}
}, [toursReviews]);
// useEffect(() => {
// if (toursReviews) {
// const totalCount = toursReviews.pages.reduce(
// (accumulator, page) =>
// accumulator + (page?.data?.data?.reviewInfos?.length || 0),
// 0,
// );
// setReviewDataLength(totalCount);
// }
// }, [toursReviews]);

return (
<>
<div className="mb-4 mt-2 text-lg font-bold">
리뷰 <span className="text-gray3">{reviewDataLength}</span>
</div>
{reviewDataLength > 0 && (
<InfiniteScroll
hasMore={hasNextPage}
loadMore={() => fetchNextPage()}
initialLoad={false}>
{toursReviews?.pages?.map((page, pageIndex) => (
<div key={pageIndex}>
{page?.data?.data?.reviewInfos?.map(
(item: any, index: number) => (
<ReviewItem
key={item.reviewId}
authorNickname={item.authorNickname}
authorProfileImageUrl={item.authorProfileImageUrl}
rating={item.rating}
createdTime={item.createdTime}
content={item.content}
keywords={item.keywords} // keywordId, content, type
commentCount={2} //commentCount가 swagger에는 있는데 response에는 없음
/>
),
)}
</div>
))}
</InfiniteScroll>
)}
{reviewDataLength == 0 && (
<div className="flex flex-col items-center justify-center">
<div className="mb-2 flex">
{Array.from({ length: 5 }, (_, index) => (
<StarIcon
key={index}
size={30}
color="none"
fill={'#EDEDED'}
className="cursor-pointer"
/>
))}
</div>
<div className="text-sm text-gray3">첫번째 리뷰를 남겨주세요!</div>
</div>
)}
</>
);
}
// return (
// <>
// <div className="mb-4 mt-2 text-lg font-bold">
// 리뷰 <span className="text-gray3">{reviewDataLength}</span>
// </div>
// {reviewDataLength > 0 && (
// <InfiniteScroll
// hasMore={hasNextPage}
// loadMore={() => fetchNextPage()}
// initialLoad={false}>
// {toursReviews?.pages?.map((page, pageIndex) => (
// <div key={pageIndex}>
// {page?.data?.data?.reviewInfos?.map(
// (item: any, index: number) => (
// <ReviewItem
// key={item.reviewId}
// authorNickname={item.authorNickname}
// authorProfileImageUrl={item.authorProfileImageUrl}
// rating={item.rating}
// createdTime={item.createdTime}
// content={item.content}
// keywords={item.keywords} // keywordId, content, type
// commentCount={2} //commentCount가 swagger에는 있는데 response에는 없음
// />
// ),
// )}
// </div>
// ))}
// </InfiniteScroll>
// )}
// {reviewDataLength == 0 && (
// <div className="flex flex-col items-center justify-center">
// <div className="mb-2 flex">
// {Array.from({ length: 5 }, (_, index) => (
// <StarIcon
// key={index}
// size={30}
// color="none"
// fill={'#EDEDED'}
// className="cursor-pointer"
// />
// ))}
// </div>
// <div className="text-sm text-gray3">첫번째 리뷰를 남겨주세요!</div>
// </div>
// )}
// </>
// );
// }
2 changes: 1 addition & 1 deletion src/components/DetailSectionBottom/DetailSectionBottom.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { DetailReviewStats, DetailReview } from '.';
import { DetailReviewStats } from '.';

// 담당 컴포넌트들 호출하는 컴포넌트(분업 때문에 페이지 느낌으로 나눠봤습니다), API 호출 컴포넌트,
export default function DetailSectionBottom() {
Expand Down
2 changes: 1 addition & 1 deletion src/components/DetailSectionBottom/ReviewItem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ interface ItemProps {
const Item: React.FC<ItemProps> = (props: ItemProps) => {
const {
authorNickname,
authorProfileImageUrl,
// authorProfileImageUrl,
rating,
createdTime,
content,
Expand Down
3 changes: 1 addition & 2 deletions src/components/DetailSectionBottom/index.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import DetailReviewStats from './DetailReviewStats';
import DetailReview from './DetailReview';

export { DetailReviewStats, DetailReview };
export { DetailReviewStats };
2 changes: 1 addition & 1 deletion src/components/Review/ReviewRating.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, { useState } from 'react';
import { useState } from 'react';
import { StarIcon } from '@components/common/icons/Icons';

const ReviewRating = () => {
Expand Down
8 changes: 4 additions & 4 deletions src/main.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ import ReactDOM from 'react-dom/client';
import App from './App.tsx';
import './index.css';

if (import.meta.env.DEV) {
const { worker } = await import('./mocks/browser.ts');
await worker.stop();
}
// if (import.meta.env.DEV) {
// const { worker } = await import('./mocks/browser.ts');
// await worker.stop();
// }

ReactDOM.createRoot(document.getElementById('root')!).render(<App />);
6 changes: 3 additions & 3 deletions src/mocks/browser.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { setupWorker } from 'msw';
import { handlers } from './handlers';
// import { setupWorker } from 'msw';
// // import { handlers } from './handlers';

export const worker = setupWorker(...handlers);
// export const worker = setupWorker(...handlers);
Loading

0 comments on commit 8cf0099

Please sign in to comment.