Skip to content

Conversation

@kyungkiK
Copy link

요구사항

기본

  • 자유 게시판 페이지 주소는 “/boards” 입니다.
  • 전체 게시글에서 드롭 다운으로 “최신 순” 또는 “좋아요 순”을 선택해서 정렬을 할 수 있습니다.
  • 게시글 목록 조회 api를 사용하여 베스트 게시글, 게시글을 구현합니다.
  • 게시글 title에 검색어가 일부 포함되면 검색이 됩니다.

심화

  • 반응형으로 보여지는 베스트 게시판 개수를 다르게 설정할때 서버에 보내는 pageSize값을 적절하게 설정합니다.
  • next의 data prefetch 기능을 사용해봅니다.

멘토에게

  • 시간이 부족해서 스프린트 미션 9 의 /board는 구현하지 못했습니다. 다음주에 이어서 계속 해보겠습니다..
  • 셀프 코드 리뷰를 통해 질문 이어가겠습니다.

@kyungkiK kyungkiK self-assigned this Jan 19, 2025
@kyungkiK kyungkiK requested a review from devToram January 19, 2025 18:45
Copy link
Collaborator

@devToram devToram left a comment

Choose a reason for hiding this comment

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

수고하셨습니다 :)

function getPageSize(width: number): number {
if (width <= PAGE_SIZES.small.max) {
return PAGE_SIZES.small.size;
} else if (width <= PAGE_SIZES.medium.max) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

early return 이라 else 없어도 될 거 같아요~


const AllProducts = () => {
const [products, setProducts] = useState<Product[]>([]); // 상품 데이터 상태
const [pageSize, setPageSize] = useState<number>(4); // 초기 페이지 크기 설정 (10개로 설정)
Copy link
Collaborator

Choose a reason for hiding this comment

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

주석은 10개로 설정인데 실제 값은 4개네요😮

import ProductList from "./products";
import Pagination from "./pagination";
import styles from "./allProduct.module.css";
import windowView from "@/hooks/windowView"; // 커스텀 훅 임포트
Copy link
Collaborator

Choose a reason for hiding this comment

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

커스텀훅 네이밍은 use~ 로 해주셔요!

// Props 타입 정의
interface NavBarProps {
orderBy: "recent" | "favorite"; // 'recent' 또는 'favorite'만 가능
setOrderBy: (order: "recent" | "favorite") => void; // setOrderBy는 'recent' 또는 'favorite'만 받을 수 있음
Copy link
Collaborator

Choose a reason for hiding this comment

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

계속 쓰이는 type 이라 따로 타입을 만들어도 좋을 거 같아요!
type OrderBy = "recent" | "favorite"

</Link>
{/* 드롭다운 버튼 */}
<button className={styles.dropdown_btn} onClick={toggleDropdown}>
{orderBy === "recent" ? "최신순" : "좋아요순"}{" "}
Copy link
Collaborator

Choose a reason for hiding this comment

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

"recent", "최신순" 이 바로 참조가 가능하도록 상수를 만들어도 좋겠네요~

const ORDER = {
   recent: {
  displayName: "최신순",
  value: 'recent'   
}
}

요런 느낌으로요!

onPageChange: (page: number) => void; // 페이지 변경 시 호출되는 함수
}

const pageRange = 5; // 한 번에 보여줄 페이지 버튼 개수
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
const pageRange = 5; // 한 번에 보여줄 페이지 버튼 개수
const PAGE_RANGE = 5; // 한 번에 보여줄 페이지 버튼 개수


const pageRange = 5; // 한 번에 보여줄 페이지 버튼 개수

function Pagination({
Copy link
Collaborator

Choose a reason for hiding this comment

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

페이지네이션의 경우 다양한 곳에 쓰일 수 있어서 AllProdcuts 말고 Common 같은 곳에 묶어줘도 좋겠네요!

Comment on lines +13 to +17
const isItemsPage = router.pathname === "/items";
const isBoardPage = router.pathname === "/boards";
const isAddItemPage = router.pathname === "/additem";
const isMainPage = router.pathname === "/";
const isItemsDetailPage = router.pathname.startsWith("/items/");
Copy link
Collaborator

Choose a reason for hiding this comment

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

각 페이지에 있는지를 모두 체크하는 것보다 자유게시판으로 보여줄 url 배열, 중고마켓으로 보여줄 url 배열을 만들어서 여기에 해당하는지 체크하는 것도 고려해주세요~

async function fetchProduct() {
if (id) {
try {
const data = await getProductDetails(id as string); // id를 string으로 캐스팅
Copy link
Collaborator

Choose a reason for hiding this comment

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

id 가 기본적으로 string 으로 추정되지 않나요??

@devToram devToram merged commit 8cdc7ce into codeit-bootcamp-frontend:Next-김경기 Jan 20, 2025
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.

4 participants