diff --git a/src/pages/product/ProductsPage.js b/src/pages/product/ProductsPage.js
index f95d309..cc9ef00 100644
--- a/src/pages/product/ProductsPage.js
+++ b/src/pages/product/ProductsPage.js
@@ -1,41 +1,22 @@
-import { getPublishedPosts } from "@/api/marketApi";
-import ProductList from "./components/ProductList";
import styled from "@emotion/styled";
-import { useState } from "react";
+import ProductList from "./components/ProductList";
// 처음 진입하면 보이는 메인 페이지
// api를 호출하여 ProcudtList에 정보를 넘겨서 보여주도록 함
// 스크롤을 통해 더 많은 상품을 동적으로 로드
export default function ProductsPage() {
- const [productList, setProductList] = useState([]);
- const keyword = null;
- const getProductList = async ({ pageParam = 1 }) => {
- // pageParam : useInfiniteQuery의 getNextPageParam에서 반환해준 값 (=다음 불러올 페이지)
- const resData = await getPublishedPosts({
- page: pageParam !== 1 ? pageParam : 1, // 1 페이지가 아니면 nextPage(현재+1 된 값)을 호출
- limit: 20,
- query: keyword ? keyword : "",
- orderBy: "createdAt",
- direction: "asc"
- });
-
- const { page, lastPage, data: responseData } = resData.data;
- setProductList((prevList) => [...prevList, ...responseData]);
-
- // return은 아래 useInfiniteQuery에서 getNextPageParam으로 전달
- // page 뜻을 전달하기 위해 이름 curPage로 전달
- return { curPage: page, lastPage };
- };
-
return (
diff --git a/src/pages/product/components/ProductList.js b/src/pages/product/components/ProductList.js
index ec9f932..656a64e 100644
--- a/src/pages/product/components/ProductList.js
+++ b/src/pages/product/components/ProductList.js
@@ -1,13 +1,26 @@
+import { getPublishedPosts } from "@/api/marketApi";
import Loading from "@/components/Loading";
import useModalStore from "@/utils/hooks/store/useModalStore";
-import styled from "@emotion/styled";
import { css } from "@emotion/react";
+import styled from "@emotion/styled";
import { useInfiniteQuery, useQueryClient } from "@tanstack/react-query";
import { useCallback, useEffect, useRef, useState } from "react";
import { useNavigate } from "react-router-dom";
// 상품 리스트를 보여주는 공용 컴포넌트
-const ProductList = ({ getProductList, productList, keyword, queryKey }) => {
+const ProductList = ({ param, queryKey }) => {
+ const [productList, setProductList] = useState([]);
+ const getProductList = async ({ pageParam = 1 }) => {
+ // pageParam : useInfiniteQuery의 getNextPageParam에서 반환해준 값 (=다음 불러올 페이지)
+ const resData = await getPublishedPosts(param);
+
+ const { page, lastPage, data: responseData } = resData.data;
+ setProductList((prevList) => [...prevList, ...responseData]);
+
+ // return은 아래 useInfiniteQuery에서 getNextPageParam으로 전달
+ // page 뜻을 전달하기 위해 이름 curPage로 전달
+ return { curPage: page, lastPage };
+ };
const queryClient = useQueryClient();
const navigate = useNavigate();
const [showTopButton, setShowTopButton] = useState(false); // "맨 위로 가기" 버튼의 표시 여부를 제어하는 상태
@@ -22,7 +35,6 @@ const ProductList = ({ getProductList, productList, keyword, queryKey }) => {
// 마지막 페이지인 경우에는 더 이상 호출 불필요 , 마지막 페이지보다 전이면 +1 해준다
// 여기서 return 하는 값은 pageParam으로 전달 됨
return curPage < lastPage ? curPage + 1 : null;
- ㅉ;
}
});
@@ -89,7 +101,7 @@ const ProductList = ({ getProductList, productList, keyword, queryKey }) => {
window.removeEventListener("scroll", handleTop);
};
}
- }, [keyword]);
+ }, [param.keyword]);
useEffect(() => {
return () => {
@@ -159,7 +171,7 @@ const ProductList = ({ getProductList, productList, keyword, queryKey }) => {
{!productList?.length && !isFetching && (
- {`${keyword ? "검색 결과가" : "상품이"} 없습니다.`}
+ {`${param.keyword ? "검색 결과가" : "상품이"} 없습니다.`}
)}
diff --git a/src/router.js b/src/router.js
index 1c15d2a..997d18f 100644
--- a/src/router.js
+++ b/src/router.js
@@ -3,14 +3,13 @@ import Header from "@/components/header";
import NotFoundPage from "@/pages/NotFoundPage";
import ProductsPage from "@/pages/product/ProductsPage";
import { ROUTES } from "@/utils/constants/routePaths";
-import { createBrowserRouter } from "react-router-dom";
+import { Navigate, createBrowserRouter } from "react-router-dom";
import { JoinPage } from "./pages/join/JoinPage";
import { LoginPage } from "./pages/login/LoginPage";
import ProductDetailPage from "./pages/product/ProductDetailPage";
-import ProductsSearchPage from "./pages/product/ProductsSearchPage";
import ProductSearchResultPage from "./pages/product/ProductSearchResultPage";
+import ProductsSearchPage from "./pages/product/ProductsSearchPage";
import { ProfilePage } from "./pages/profile/ProfilePage";
-import { Navigate } from "react-router-dom";
import useAuthStore from "./utils/hooks/store/useAuthStore";
// 코드 스플리팅을 위해 React.lazy를 사용하는 주석 처리된 예시입니다.
@@ -24,7 +23,7 @@ export const routeConfig = [
// 홈 페이지 경로, ProductPage 컴포넌트를 렌더링합니다.
// `index: true`는 이 라우트가 자식 라우트보다 우선순위가 높음을 나타냅니다.
{ path: ROUTES.HOME, element:
, index: true },
- { path: ROUTES.PRODUCT, element:
},
+ { path: ROUTES.PRODUCT, element:
, authRequire: false },
{ path: ROUTES.SEARCH, element:
},
{ path: ROUTES.SEARCH_RESULT, element:
},
{ path: ROUTES.LOGIN, element:
},
From 881cda76877a8eb5d7dd8476fd79c6b504cb897e Mon Sep 17 00:00:00 2001
From: nakjun <111031253+nakjun12@users.noreply.github.com>
Date: Tue, 6 Feb 2024 19:59:14 +0900
Subject: [PATCH 28/46] =?UTF-8?q?Revert=20"fix=20:=20=EC=9E=84=EC=8B=9C=20?=
=?UTF-8?q?=EC=BB=A4=EB=B0=8B"?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
This reverts commit a66ee1a4a17a06d2b368ec51f0e7889ab736818f.
---
src/components/carousel/ImageSwiperSlide.js | 1 -
src/pages/product/ProductsPage.js | 35 ++++++++++++++++-----
src/pages/product/components/ProductList.js | 22 +++----------
src/router.js | 7 +++--
4 files changed, 36 insertions(+), 29 deletions(-)
diff --git a/src/components/carousel/ImageSwiperSlide.js b/src/components/carousel/ImageSwiperSlide.js
index fe2114b..506d3f3 100644
--- a/src/components/carousel/ImageSwiperSlide.js
+++ b/src/components/carousel/ImageSwiperSlide.js
@@ -27,7 +27,6 @@ export default ImageSwiperSlide;
const containerStyle = css`
width: 100%; // 컨테이너 너비를 100%로 설정
padding-top: 56.25%; // 16:9 비율의 높이를 설정
- min-height: 200px; // 이미지 높이를 100%로 설정
position: relative; // 자식 요소를 절대 위치로 배치하기 위한 상대 위치 설정
`;
diff --git a/src/pages/product/ProductsPage.js b/src/pages/product/ProductsPage.js
index cc9ef00..f95d309 100644
--- a/src/pages/product/ProductsPage.js
+++ b/src/pages/product/ProductsPage.js
@@ -1,22 +1,41 @@
-import styled from "@emotion/styled";
+import { getPublishedPosts } from "@/api/marketApi";
import ProductList from "./components/ProductList";
+import styled from "@emotion/styled";
+import { useState } from "react";
// 처음 진입하면 보이는 메인 페이지
// api를 호출하여 ProcudtList에 정보를 넘겨서 보여주도록 함
// 스크롤을 통해 더 많은 상품을 동적으로 로드
export default function ProductsPage() {
+ const [productList, setProductList] = useState([]);
+ const keyword = null;
+ const getProductList = async ({ pageParam = 1 }) => {
+ // pageParam : useInfiniteQuery의 getNextPageParam에서 반환해준 값 (=다음 불러올 페이지)
+ const resData = await getPublishedPosts({
+ page: pageParam !== 1 ? pageParam : 1, // 1 페이지가 아니면 nextPage(현재+1 된 값)을 호출
+ limit: 20,
+ query: keyword ? keyword : "",
+ orderBy: "createdAt",
+ direction: "asc"
+ });
+
+ const { page, lastPage, data: responseData } = resData.data;
+ setProductList((prevList) => [...prevList, ...responseData]);
+
+ // return은 아래 useInfiniteQuery에서 getNextPageParam으로 전달
+ // page 뜻을 전달하기 위해 이름 curPage로 전달
+ return { curPage: page, lastPage };
+ };
+
return (
diff --git a/src/pages/product/components/ProductList.js b/src/pages/product/components/ProductList.js
index 656a64e..ec9f932 100644
--- a/src/pages/product/components/ProductList.js
+++ b/src/pages/product/components/ProductList.js
@@ -1,26 +1,13 @@
-import { getPublishedPosts } from "@/api/marketApi";
import Loading from "@/components/Loading";
import useModalStore from "@/utils/hooks/store/useModalStore";
-import { css } from "@emotion/react";
import styled from "@emotion/styled";
+import { css } from "@emotion/react";
import { useInfiniteQuery, useQueryClient } from "@tanstack/react-query";
import { useCallback, useEffect, useRef, useState } from "react";
import { useNavigate } from "react-router-dom";
// 상품 리스트를 보여주는 공용 컴포넌트
-const ProductList = ({ param, queryKey }) => {
- const [productList, setProductList] = useState([]);
- const getProductList = async ({ pageParam = 1 }) => {
- // pageParam : useInfiniteQuery의 getNextPageParam에서 반환해준 값 (=다음 불러올 페이지)
- const resData = await getPublishedPosts(param);
-
- const { page, lastPage, data: responseData } = resData.data;
- setProductList((prevList) => [...prevList, ...responseData]);
-
- // return은 아래 useInfiniteQuery에서 getNextPageParam으로 전달
- // page 뜻을 전달하기 위해 이름 curPage로 전달
- return { curPage: page, lastPage };
- };
+const ProductList = ({ getProductList, productList, keyword, queryKey }) => {
const queryClient = useQueryClient();
const navigate = useNavigate();
const [showTopButton, setShowTopButton] = useState(false); // "맨 위로 가기" 버튼의 표시 여부를 제어하는 상태
@@ -35,6 +22,7 @@ const ProductList = ({ param, queryKey }) => {
// 마지막 페이지인 경우에는 더 이상 호출 불필요 , 마지막 페이지보다 전이면 +1 해준다
// 여기서 return 하는 값은 pageParam으로 전달 됨
return curPage < lastPage ? curPage + 1 : null;
+ ㅉ;
}
});
@@ -101,7 +89,7 @@ const ProductList = ({ param, queryKey }) => {
window.removeEventListener("scroll", handleTop);
};
}
- }, [param.keyword]);
+ }, [keyword]);
useEffect(() => {
return () => {
@@ -171,7 +159,7 @@ const ProductList = ({ param, queryKey }) => {
{!productList?.length && !isFetching && (
- {`${param.keyword ? "검색 결과가" : "상품이"} 없습니다.`}
+ {`${keyword ? "검색 결과가" : "상품이"} 없습니다.`}
)}
diff --git a/src/router.js b/src/router.js
index 997d18f..1c15d2a 100644
--- a/src/router.js
+++ b/src/router.js
@@ -3,13 +3,14 @@ import Header from "@/components/header";
import NotFoundPage from "@/pages/NotFoundPage";
import ProductsPage from "@/pages/product/ProductsPage";
import { ROUTES } from "@/utils/constants/routePaths";
-import { Navigate, createBrowserRouter } from "react-router-dom";
+import { createBrowserRouter } from "react-router-dom";
import { JoinPage } from "./pages/join/JoinPage";
import { LoginPage } from "./pages/login/LoginPage";
import ProductDetailPage from "./pages/product/ProductDetailPage";
-import ProductSearchResultPage from "./pages/product/ProductSearchResultPage";
import ProductsSearchPage from "./pages/product/ProductsSearchPage";
+import ProductSearchResultPage from "./pages/product/ProductSearchResultPage";
import { ProfilePage } from "./pages/profile/ProfilePage";
+import { Navigate } from "react-router-dom";
import useAuthStore from "./utils/hooks/store/useAuthStore";
// 코드 스플리팅을 위해 React.lazy를 사용하는 주석 처리된 예시입니다.
@@ -23,7 +24,7 @@ export const routeConfig = [
// 홈 페이지 경로, ProductPage 컴포넌트를 렌더링합니다.
// `index: true`는 이 라우트가 자식 라우트보다 우선순위가 높음을 나타냅니다.
{ path: ROUTES.HOME, element:
, index: true },
- { path: ROUTES.PRODUCT, element:
, authRequire: false },
+ { path: ROUTES.PRODUCT, element:
},
{ path: ROUTES.SEARCH, element:
},
{ path: ROUTES.SEARCH_RESULT, element:
},
{ path: ROUTES.LOGIN, element:
},
From 07be6cc5537e1614e3e487f9ec7f8fb6f77c5b67 Mon Sep 17 00:00:00 2001
From: nakjun <111031253+nakjun12@users.noreply.github.com>
Date: Tue, 6 Feb 2024 20:00:02 +0900
Subject: [PATCH 29/46] =?UTF-8?q?fix=20:=20=EB=A1=A4=EB=B0=B1?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
src/pages/product/components/ProductList.js | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/src/pages/product/components/ProductList.js b/src/pages/product/components/ProductList.js
index ec9f932..b6eb3cd 100644
--- a/src/pages/product/components/ProductList.js
+++ b/src/pages/product/components/ProductList.js
@@ -1,7 +1,7 @@
import Loading from "@/components/Loading";
import useModalStore from "@/utils/hooks/store/useModalStore";
-import styled from "@emotion/styled";
import { css } from "@emotion/react";
+import styled from "@emotion/styled";
import { useInfiniteQuery, useQueryClient } from "@tanstack/react-query";
import { useCallback, useEffect, useRef, useState } from "react";
import { useNavigate } from "react-router-dom";
@@ -22,7 +22,6 @@ const ProductList = ({ getProductList, productList, keyword, queryKey }) => {
// 마지막 페이지인 경우에는 더 이상 호출 불필요 , 마지막 페이지보다 전이면 +1 해준다
// 여기서 return 하는 값은 pageParam으로 전달 됨
return curPage < lastPage ? curPage + 1 : null;
- ㅉ;
}
});
From 6b356da8e053868235255b542d3c3161242c8343 Mon Sep 17 00:00:00 2001
From: nakjun <111031253+nakjun12@users.noreply.github.com>
Date: Tue, 6 Feb 2024 20:08:59 +0900
Subject: [PATCH 30/46] =?UTF-8?q?feat=20:=20=EC=83=81=ED=92=88=20=EC=83=81?=
=?UTF-8?q?=EC=84=B8=20=EC=A0=95=EB=B3=B4=20api=20=EC=97=B0=EA=B2=B0?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
src/pages/product/ProductDetailPage.js | 9 ++-------
1 file changed, 2 insertions(+), 7 deletions(-)
diff --git a/src/pages/product/ProductDetailPage.js b/src/pages/product/ProductDetailPage.js
index 54defdd..cd9a9b8 100644
--- a/src/pages/product/ProductDetailPage.js
+++ b/src/pages/product/ProductDetailPage.js
@@ -1,14 +1,9 @@
-import { getPostById } from "@/api/marketApi";
+import { getPostById, getPublishedPosts } from "@/api/marketApi";
import ProductImageCarousel from "@/components/carousel/ProductImageCarousel";
import useModalStore from "@/utils/hooks/store/useModalStore";
import { useEffect, useState } from "react";
import { useParams } from "react-router-dom";
-
-const images = [
- "https://i.pinimg.com/550x/a9/f1/2a/a9f12ad9bfe0baa4f6e629d1e0fa439c.jpg",
- "https://species.nibr.go.kr/UPLOAD/digital/species/12000009/120000095823/BIMGMM0000386036_20221116112438319509.jpg",
- "https://mblogthumb-phinf.pstatic.net/MjAxODAyMDJfMTcx/MDAxNTE3NTUxOTIxNDcz.4p7O7MZoKYKwd9FSAVZBdJQEayDerw9nzUCPKNzfSL4g.Cx4zwz5E5GiYeUS1EGelbBU4Z2gPj9jn0ZjCQxD55gsg.JPEG.phjphk12/image_3575628891517551874701.jpg?type=w800"
-];
+import ProductsListComponent from "./components/ProductListComponent";
export default function ProductDetailPage() {
const { openModal } = useModalStore();
From 352510fc77375448523371941d1554add61e87a8 Mon Sep 17 00:00:00 2001
From: nakjun <111031253+nakjun12@users.noreply.github.com>
Date: Tue, 6 Feb 2024 20:09:26 +0900
Subject: [PATCH 31/46] =?UTF-8?q?feat=20:=20=EC=83=81=ED=92=88=20=EC=A0=95?=
=?UTF-8?q?=EB=B3=B4=EC=97=90=20=EC=83=81=ED=92=88=20=EB=A6=AC=EC=8A=A4?=
=?UTF-8?q?=ED=8A=B8=20=ED=8E=98=EC=9D=B4=EC=A7=80=20=EC=B6=94=EA=B0=80?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
src/pages/product/ProductDetailPage.js | 58 ++++---------------
.../components/ProductListComponent.js | 49 ++++++++++++++++
2 files changed, 61 insertions(+), 46 deletions(-)
create mode 100644 src/pages/product/components/ProductListComponent.js
diff --git a/src/pages/product/ProductDetailPage.js b/src/pages/product/ProductDetailPage.js
index cd9a9b8..49516d4 100644
--- a/src/pages/product/ProductDetailPage.js
+++ b/src/pages/product/ProductDetailPage.js
@@ -55,52 +55,18 @@ export default function ProductDetailPage() {
장바구니에 넣기