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

[이태빈] Sprint5 #130

Conversation

De-cal
Copy link
Collaborator

@De-cal De-cal commented Mar 9, 2025

🐼판다마켓 : https://been-panda.vercel.app

요구사항

기본 요구사항

공통

  • 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값을 적절하게 설정합니다.

주요 변경사항

  • 중고마켓 페이지 구현
  • 반응형에 따른 리퀘스트 보내기
  • 반응형 디자인
  • 정렬 버튼 활성화

스크린샷

image
image
image

멘토에게

  • 현재 Router를 사용하지 않는 상태로 만든 것입니다. 그래서 개인적으로 다른 페이지 이동될 수 있도록 억지로 만들어두거라서 다른 페이지로 이동 하는 것은 a태그 사용, 자바스크립트 작동 X, reset.css 적용 안된 점 참고 부탁드립니다.
  • 처음 배포하니까 이미지가 깨진다는 것을 알고 폴더 경로에 따라서 deploy가 안된다는 것도 알게 되었습니다. 그래서 부랴부랴 옮겨놓긴 했는데 정확히 어떤 것들을 어디에 넣어야 할지 조금 헷갈려서 혹시 제가 만든 폴더들의 위치가 잘못되었다면 피드백 부탁드립니다. 그리고 index.html은 public에 두어야 하나요? 아니면 그냥 최상위 루트에 두어야 하나요?
  • hook을 한개 만들긴 했는데 제대로 한건지는 잘 모르겠습니다. 그냥 함수를 불러와서 사용한 느낌이긴 한데 이것도 hook이 맞는지 궁금합니다. 그리고 다른 코드들 중에서도 hook 으로 만들 수 있는 코드는 어떤 것이 있었는지도 알고 싶습니다.
  • hook을 어떤 방식으로 만드는지 감이 잘 잡히지 않아서 전반적으로만 설명 해주시면 감사하겠습니다.
  • 그리고 index.html에 head 쪽에 여러 코드를 적어두었는데 head에도 아무것도 적지 않고 기본적인 html로만 두어야 하나요?

@loquemedalagana
Copy link
Collaborator

전에 멘토링 때 React가 어렵다고 말씀하셨는데 우선 a태그로 접근을 먼저 하셔서 기능 구현부터 먼저 하신 것은 잘 하셨다고 생각합니다. React는 저도 여러번 강조드리다시피 생태계가 워낙 자주 바뀌고, 버전 앞자리가 바뀌면 현업 개발자들도 새로 러닝커브가 있습니다.

pageSize: bestProducts,
}));
}, [device]);
};
Copy link
Collaborator

Choose a reason for hiding this comment

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

제가 추후 더 상세히 리뷰를 달아드릴 예정인데 custom hook이 어떤 건지 처음에 어려우셨을텐데 잘 접근하려고 노력하신 점이 보입니다!

<img src="/assets/image/market/ic_arrow_left.svg" alt="왼쪽 화살표" />
</button>
{pages.map((page) => {
if (page > Math.ceil(totalCount / params.pageSize)) return;
Copy link
Collaborator

Choose a reason for hiding this comment

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

아이디어 괜찮은데 어떻게 접근하셨는지 설명 해주실 수 있을까요?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

그 코드리뷰 달아주시는거 어디부터 어디까지 해주신건지 범위를 볼줄 몰라서,, 처음부터 코멘트 달아주신 부분까지 보는건가요? 그리고 여기 pr코멘트에는 항상 4줄만 나오던데 코멘트해주신 코드로 들어가서 확인해야 하나요?

Copy link
Collaborator

Choose a reason for hiding this comment

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

네네~ 코멘트는 딱 해당 부분만 나와요. 그리고 해당 리뷰는 page > Math.ceil(totalCount / params.pageSize) 이 공식을 어떻게 유도하셨는지에 대해 여쭤본겁니다!

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

좀 많이 돌아가서 과정이 길고 기억이 정확하게 나지 않아서 간략하게 설명해보겠습니다!

처음에는 pages.map이 아니라 그냥 함수로 페이지 수를 조절하려는 시도를 했습니다. pages의 배열의 내용을 바꾸려고 시도를 했던 것 같은데 많은 버그가 있었고, 여러번 시도를 하다가 구현이 되질 않아서 잠시 뒤로 미뤘었습니다. 그러다가 이제 문득 실제로 page를 나타낼 때 사용하는 데이터는 pages라는 배열이고, 그것을 렌더링 해주는 함수가 pages.map이니까 배열을 바꾸지 말고 직접적으로 렌더링 해주는 함수에 조건을 달면 배열을 굳이 바꾸지 않더라도 구현할 수 있지 않을까라는 생각이 들었습니다. 그래서 실제로 코드를 작성해보니 되었습니다.

제가 어떻게 코드를 작성했는지 설명하는게 처음하다보니 제대로 말씀드리지 못하는 것 같네요.. 혹시 다른 내용이 궁금하셨던거라면 코멘트 달아주시면 그 부분에 대해서 더 자세히 설명해보겠습니다!

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

page > Math.ceil(totalCount / params.pageSize)

이 공식을 어떻게 유도했는지 물으신거라면

  1. 리스폰스의 객체에 totalCount값이 담긴걸 확인하고 활용하기로 결정
  2. 페이지 수는 총 컨텐츠 / 리퀘스트를 보내는 pageSize라는 것을 생각
  3. 소수점이 발생하는 경우 컨텐츠 유실이 발생하게 되어서 올림 처리를 하여서 모든 컨텐츠 유실 없도록 수정
  4. 디바이스의 크기에 따라 pageSize를 다르게 리퀘스트를 보내기 때문에 하드코딩에서 params.pageSize를 받도록 수정
  5. pages에는 다음으로 렌더링 할 page의 배열이 담겨있기 때문에 각 page가 page > Math.ceil(totalCount / params.pageSize) 조건에 부합하면 렌더링 되지 않도록 처리
    하였습니다. 설명이 부족했다면 말씀해주시면 자세히 설명드리겠습니다!

Copy link
Collaborator

Choose a reason for hiding this comment

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

유도과정 좋아요. 멋져요!!

@De-cal De-cal requested a review from loquemedalagana March 11, 2025 14:19
const instance = axios.create({ baseURL });

export const getProducts = async (params) => {
const res = await instance.get("/products", { params });
Copy link
Collaborator

Choose a reason for hiding this comment

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

지난 시간에 배운 dto 기억나세요? keyword= 값이 없으면 이 params는 빼도 되겠죠?

<img src="/assets/image/market/ic_arrow_left.svg" alt="왼쪽 화살표" />
</button>
{pages.map((page) => {
if (page > Math.ceil(totalCount / params.pageSize)) return;
Copy link
Collaborator

Choose a reason for hiding this comment

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

유도과정 좋아요. 멋져요!!

const [pages, setPages] = useState([1, 2, 3, 4, 5]);
const [currentPage, setCurrentPage] = useState(1);
const [active, setActive] = useState({ 1: true });

Copy link
Collaborator

Choose a reason for hiding this comment

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

나중에 pagination을 context로 표현하는 방법 고민해보세요!

const sortSelect = (orderBy) => {
sortLoad(orderBy);
};

Copy link
Collaborator

Choose a reason for hiding this comment

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

select를 custom hook으로 빼시면 어떨까요?

return (
<form
onSubmit={(e) => {
e.preventDefault();
Copy link
Collaborator

Choose a reason for hiding this comment

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

[심화학습] e.preventDefault()를 지우지 않고 활용하는 사례를 한번 생각해보세요! (선택)

import "./SelectSort.css";

export const SelectSort = ({ sortLoad }) => {
const [currentSort, setCurrentSort] = useState("최신순");
Copy link
Collaborator

Choose a reason for hiding this comment

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

이걸 영어로 바꿔보세요.

@loquemedalagana loquemedalagana merged commit 35dead2 into codeit-sprint-fullstack:react-이태빈 Mar 12, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants