Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[이지수A] Sprint5 #125

Merged

Conversation

afafmmm
Copy link
Collaborator

@afafmmm afafmmm commented Mar 6, 2025

요구사항

기본 요구사항

공통

  • Github에 스프린트 미션 PR을 만들어 주세요.
  • React를 사용해 진행합니다.

중고마켓 페이지

  • PC, Tablet, Mobile 디자인에 해당하는 중고마켓 페이지를 만들어 주세요.
  • 중고마켓 페이지 url path는 별도로 설정하지 않고, '/'에 보이도록 합니다.
  • 상단 네비게이션 바, 푸터는 랜딩 페이지와 동일한 스타일과 규칙으로 만들어주세요.
  • 상품 데이터는 https://panda-market-api.vercel.app/docs/에 명세된 GET 메소드 "/products" 를 활용해주세요.
  • 상품 목록 페이지네이션 기능을 구현합니다.
  • 드롭 다운으로 "최신 순" 또는 "좋아요 순"을 선택해서 정렬을 구현하세요.
  • 상품 목록 검색 기능을 구현합니다.
  • 베스트 상품 데이터는 https://panda-market-api.vercel.app/docs/에 명세된 GET 메소드 "/products"의 정렬 기준 favorite을 사용해주세요.

심화 요구사항

공통

  • 커스텀 hook을 만들어 필요한 곳에 활용해 보세요.

중고마켓 페이지

  • 중고 마켓의 카드 컴포넌트 반응형 기준은 다음과 같습니다.

  • 베스트 상품

  • Desktop : 4열

  • Tablet : 2열

  • Mobile : 1열

  • 전체 상품

  • Desktop : 5열

  • Tablet : 3열

  • Mobile : 2열

  • 반응형에 따른 페이지 네이션 기능을 구현합니다.

  • 반응형으로 보여지는 물품들의 개수를 다르게 설정할때 서버에 보내는 pageSize값을 적절하게 설정합니다.

주요 변경사항

배포 사이트 링크

https://6-sprint-mission-fe-re.vercel.app/

멘토에게

  • 셀프 코드 리뷰를 통해 질문 이어가겠습니다.

@afafmmm afafmmm requested a review from reach0908 March 11, 2025 05:48
Copy link
Collaborator

@reach0908 reach0908 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

제 코드리뷰 앞에 붙어있는 태그들의 의미는 아래와 같습니다.

  • P0 : 꼭 반영해 주세요 (Request Changes) - 이슈가 발생하거나 취약점이 발견되는 케이스 등
  • P1 : 반영을 적극적으로 고려해 주시면 좋을 것 같아요 (Comment)
  • P2 : 이런 방법도 있을 것 같아요~ 등의 사소한 의견입니다 (Chore)

전체적으로 깔끔한 코드 구조 인것 같네요.
useProduct 커스텀 훅을 만들어 로딩상태와 fetch한 데이터를 관리하는 점 잘 하신 것 같습니다!

react에 대한 이해도가 좀 있으신 것 같아, useCallback, useMemo 등을 통한 성능 최적화에 대해서도 슬쩍 공부해보시면 좋을 것 같습니다.
남긴 리뷰 코멘트들이 다른 파일들에서도 보이는 경우가 있습니다. 코멘트를 반영하실 때 해당되는 파일뿐만 아니라 다른 파일에서도 비슷한 부분이 보인다면 같이 고쳐보시면 좋을 것 같습니다.

Comment on lines +30 to +37
let sortedProducts = [...allProducts];
if (sort === "latest") {
sortedProducts.sort(
(a, b) => new Date(b.createdAt) - new Date(a.createdAt)
);
} else if (sort === "favorite") {
sortedProducts.sort((a, b) => b.favoriteCount - a.favoriteCount);
}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[P2]
매 렌더링때마다 정렬이 수행될 것 같습니다. useMemo등을 통해 성능 최적화를 해보면 좋을 것 같습니다.

const data = await response.json();
setAllProducts(data.list);
} catch (error) {
console.error("상품 불러오기 실패:", error);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[P2]
에러인 경우 사용자가 인지하고 재시도를 할 수 있도록 toast 등을 통해 알려주는 것도 좋습니다!

import "./Market.css";

const Market = () => {
const [sort, setSort] = useState("latest");
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[P1]
정해져있는 상수 값들은 별도의 constant 파일로 관리하는 것이 코드 유지보수 측면에서 좋습니다.

Comment on lines +15 to +18
if (window.innerWidth > 1024) {
setPageSize(10);
} else if (window.innerWidth > 768) {
setPageSize(6);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[P1]
미디어 쿼리들을 위한 상수값들도 마찬가지입니다!

Comment on lines +43 to +46
{products.map((product) => (
<ProductCard key={product.id} product={product} />
))}
</div>
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[P0]
프로덕트가 한개도 없을 경우에 대한 예외처리가 되면 좋을 것 같습니다.
배열이 있을 경우에는 꼭 비어있는 배열에 대한 예외처리가 있으면 좋습니다!

Comment on lines +10 to +12
for (let i = startPage; i <= endPage; i++) {
pages.push(i);
}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[P2]
Array.from 을 활용해서 배열을 한번에 만들 수 있습니다.

const pages = Array.from(
      { length: endPage - startPage + 1 },
      (_, i) => startPage + i
    );

Comment on lines +7 to +11
<img
src={product.images[0]}
alt={product.name}
className="product-image"
/>
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[P0]
images의 길이 0인경우에 대한 예외처리가 되면 좋을 것 같습니다.

@reach0908 reach0908 merged commit f9425b8 into codeit-sprint-fullstack:react-이지수A Mar 12, 2025
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants