Skip to content

Conversation

@minimo-9
Copy link
Collaborator

@minimo-9 minimo-9 commented May 5, 2025

요구사항

https://sprint5-minimo.netlify.app/

기본

중고마켓

  • 중고마켓 페이지 주소는 “/items” 입니다.
  • 페이지 주소가 “/items” 일때 상단네비게이션바의 '중고마켓' 버튼의 색상은 “3692FF”입니다.
  • 상단 네비게이션 바는 이전 미션에서 구현한 랜딩 페이지와 동일한 스타일로 만들어 주세요.
  • 상품 데이터 정보는 https://panda-market-api.vercel.app/docs/#/ 에 명세된 GET 메소드 “/products” 를 사용해주세요.
  • '상품 등록하기' 버튼을 누르면 “/additem” 로 이동합니다. ( 빈 페이지 )
  • 전체 상품에서 드롭 다운으로 “최신 순” 또는 “좋아요 순”을 선택해서 정렬을 할 수 있습니다.

중고마켓 반응형

  • 베스트 상품

  • Desktop : 4개 보이기

  • Tablet : 2개 보이기

  • Mobile : 1개 보이기

  • 전체 상품

  • Desktop : 12개 보이기

  • Tablet : 6개 보이기

  • Mobile : 4개 보이기

심화

  • 페이지 네이션 기능을 구현합니다.

주요 변경사항

스크린샷

데스크탑

image

태블릿

image

모바일

image

멘토에게

  • 페이지네이션 기능은 UX 측면에서 한 페이지씩 이동하는 방식이 좋을지, 아니면 5페이지 단위로 이동하는 방식이 더 적절할지 궁금합니다.
  • UX 측면에서 사용자 편의성을 고려해 새로고침 시 세션스토리지를 활용해 현재 페이지를 유지하도록 구현했습니다.
    하지만 Sort 기준이 변경될 경우에는 1페이지로 이동하는 것이 더 자연스럽다고 판단해서
 useEffect(() => {
  setPage(1);
}, [orderBy]);

와 같이 처리했지만, 페이지 번호는 1로 변경되었음에도 불구하고 화면에는 이전 페이지의 데이터가 그대로 출력되는 문제가 발생합니다. 이럴 때는 어떤 방식으로 접근해야 할지 궁금합니다.

  • 모바일에서 검색창 부분의 구조가 바뀌어야 해서 현재는 window.resize를 이용해 조건에 따라 JSX 구조를 변경하고 있습니다.
    원래는 CSS로만 처리하려 했지만 원하는 형태가 나오지 않아 리사이즈 방식으로 구현했는데, 이런 방식이 괜찮은지, 혹시 더 나은 방법이 있을지도 궁금합니다.

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

minimo-9 added 30 commits April 9, 2025 20:21
minimo-9 added 23 commits May 5, 2025 04:05
@minimo-9 minimo-9 self-assigned this May 5, 2025
@minimo-9 minimo-9 requested a review from GANGYIKIM May 5, 2025 03:06
@minimo-9 minimo-9 added the 순한맛🐑 마음이 많이 여립니다.. label May 5, 2025
Copy link
Collaborator

@GANGYIKIM GANGYIKIM left a comment

Choose a reason for hiding this comment

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

광민님 5주차 미션 고생하셨습니다~
다음 미션도 화이팅입니다!


  • 배포 주소에서 확인해보니 전체 상품 영역에서 10개의 아이템이 보이고 있어요. 확인해보시고 수정하시면 좋겠습니다~

  • 페이지네이션 기능은 UX 측면에서 한 페이지씩 이동하는 방식이 좋을지, 아니면 5페이지 단위로 이동하는 방식이 더 적절할지 궁금합니다.: 이렇게 UX 가 궁금하실 경우, 이미 운영중인 서비스들에 가서 만져보시면서 분석해보시고 선택하시면 좋습니다~ 찾아보시면 페이지네이션도 디자인이 다 다르기때문에 그때그때 다를 수 있습니다.

  • UX 측면에서 사용자 편의성을 고려해 새로고침 시 세션스토리지를 활용해 현재 페이지를 유지하도록 구현했습니다.하지만 Sort 기준이 변경될 경우에는 1페이지로 이동하는 것이 더 자연스럽다고 판단해서 ... 와 같이 처리했지만, 페이지 번호는 1로 변경되었음에도 불구하고 화면에는 이전 페이지의 데이터가 그대로 출력되는 문제가 발생합니다. 이럴 때는 어떤 방식으로 접근해야 할지 궁금합니다.:
    지금 확인해보니 우선적으로 화면 사이즈에 따라 노출되는 아이템의 개수가 달라져야 하는데 이 부분이 제대로 동작하지 않는 것 같습니다. (저는 tablet 사이즈에서 접근시 PC에 해당하는 10개가 노출됩니다) 이 문제를 해결하시고 위에서 언급해주신 문제를 고치시면 더 좋을 것 같습니다. 질문에 적어주신 상황을 제가 확인하지 못해 더 자세한 답변은 어렵습니다~

  • 모바일에서 검색창 부분의 구조가 바뀌어야 해서 현재는 window.resize를 이용해 조건에 따라 JSX 구조를 변경하고 있습니다. 원래는 CSS로만 처리하려 했지만 원하는 형태가 나오지 않아 리사이즈 방식으로 구현했는데, 이런 방식이 괜찮은지, 혹시 더 나은 방법이 있을지도 궁금합니다.: 당연히 성능상 CSS 로만 처리하시는 것이 더 좋습니다. 다만 이렇게 하실 수 밖에 없다면 괜찮습니다.

Copy link
Collaborator

Choose a reason for hiding this comment

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

💊 제안
3번째 미션에서 추가하셨던 메타 태그도 추가하시면 더 좋을 것 같아요!

Copy link
Collaborator

Choose a reason for hiding this comment

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

💬 여담
React Router를 사용하고 계신데 향후 라우트가 많아지면 Route들을 별도의 파일로 분리하면 App 컴포넌트가 더 깔끔해지고, 라우트 관리도 쉬워집니다.

https://reactrouter.com/start/data/routing

Comment on lines +29 to +33
<NavLink
to="/items"
className={styles.menuLink}
style={getLinkStyle}
>
Copy link
Collaborator

Choose a reason for hiding this comment

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

👍 칭찬
NavLink 쓰신 거 좋아요!

Comment on lines +29 to +33
<button
disabled={currentPage === 1}
onClick={handlePrevPage}
className={styles.navButton}
>
Copy link
Collaborator

Choose a reason for hiding this comment

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

👍 칭찬
버튼이 동작되지 않는 조건 처리하신 점 좋습니다!

Comment on lines +15 to +19
const handlePrevPage = () => {
if (currentPage > 1) {
onPageChange(currentPage - 1);
}
};
Copy link
Collaborator

Choose a reason for hiding this comment

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

💊 제안
이미 button에서 currentPage가 1 일때 disabled 처리를 하셔서 조건문을 빼셔도 될 것 같아요~

Suggested change
const handlePrevPage = () => {
if (currentPage > 1) {
onPageChange(currentPage - 1);
}
};
const handlePrevPage = () => {
onPageChange(currentPage - 1);
};

{Array.from({ length: endPage - startPage + 1 }, (_, i) => {
const page = startPage + i;
return (
<button
Copy link
Collaborator

Choose a reason for hiding this comment

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

💊 제안
button type 명시해주시면 더 좋겠습니다~

Suggested change
<button
<button
type="button"

Comment on lines +56 to +59
const sortedProducts = [...products].sort((a, b) => {
if (orderBy === "likes") return b.favoriteCount - a.favoriteCount;
return new Date(b.recent) - new Date(a.recent);
});
Copy link
Collaborator

Choose a reason for hiding this comment

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

❗️ 수정요청
프론트에서 검색 인풋의 값에 따라 상품요소를 필터링하도록 작성하셨는데, 이렇게 되면 전체 상품 목록에서 필터링 되는 것이 아니라, 불러온 데이터 내에서 필터링하는 것이라 의도한 바와 다르게 동작할거에요!
이런 경우 Products api의 Param을 통해 구현하시면 됩니다.

스크린샷 2025-04-11 오후 1 39 06

검색 키워드는 search 값으로 넘겨서 서버에서 응답온 값을 이용해주세요.
이와 동일하게 상품 리스트 정렬은 orderBy 값을 이용해주세요!

Copy link
Collaborator

Choose a reason for hiding this comment

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

❗️ 수정요청
아래 검색어 입력시도 동일합니다~ 프론트에서 filter 하지 마시고 API를 통해 불러오세요~

Comment on lines +34 to +43
{products.slice(0, visibleCount).map((item) => (
<ProductCard
key={item.id}
imageUrl={item.images?.[0]}
title={item.name}
price={item.price}
likes={item.favoriteCount}
variant="best"
/>
))}
Copy link
Collaborator

Choose a reason for hiding this comment

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

💬 여담
아래 코드도 동일동작합니다~

Suggested change
{products.slice(0, visibleCount).map((item) => (
<ProductCard
key={item.id}
imageUrl={item.images?.[0]}
title={item.name}
price={item.price}
likes={item.favoriteCount}
variant="best"
/>
))}
{products.slice(0, visibleCount).map(({ id, images, name, price, favoriteCount }) => (
<ProductCard
key={id}
imageUrl={images?.[0]}
title={name}
price={price}
likes={favoriteCount}
variant="best"
/>
))}

Comment on lines +45 to +47
<li onClick={() => handleSelect("최신순")} className={styles.recent}>
최신순
</li>
Copy link
Collaborator

Choose a reason for hiding this comment

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

❗️ 수정요청
이런 클릭 가능한 요소의 경우 버튼을 사용해주세요. 더 적절한 태그가 있는데 이미지 태그에 onClick 을 주게되면 button에게 기대하는 동작을 제대로 수행하지 못합니다!

Suggested change
<li onClick={() => handleSelect("최신순")} className={styles.recent}>
최신순
</li>
<li className={styles.recent}>
<button type="button" value={sortMap["최신순"]} onClick={handleSelect}>최신순</button>
</li>

위에처럼 button 태그로 바꾸시고 onClick 시 event 객체에서 button 태그의 value를 받아오는 방식으로 구현하시는 것을 추천드려요!

@GANGYIKIM GANGYIKIM merged commit 9556cf3 into codeit-bootcamp-frontend:React-박광민 May 9, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

순한맛🐑 마음이 많이 여립니다..

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants