-
Notifications
You must be signed in to change notification settings - Fork 37
[김경기] sprint9 #303
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
[김경기] sprint9 #303
The head ref may contain hidden characters: "Next-\uAE40\uACBD\uAE30-sprint9"
Conversation
…ithub-actions [Fix] delete merged branch github action
devToram
left a comment
There was a problem hiding this 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) { |
There was a problem hiding this comment.
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개로 설정) |
There was a problem hiding this comment.
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"; // 커스텀 훅 임포트 |
There was a problem hiding this comment.
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'만 받을 수 있음 |
There was a problem hiding this comment.
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" ? "최신순" : "좋아요순"}{" "} |
There was a problem hiding this comment.
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; // 한 번에 보여줄 페이지 버튼 개수 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
상수는 대문자로 적어주시는 걸 추천드려요!
| const pageRange = 5; // 한 번에 보여줄 페이지 버튼 개수 | |
| const PAGE_RANGE = 5; // 한 번에 보여줄 페이지 버튼 개수 |
|
|
||
| const pageRange = 5; // 한 번에 보여줄 페이지 버튼 개수 | ||
|
|
||
| function Pagination({ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
페이지네이션의 경우 다양한 곳에 쓰일 수 있어서 AllProdcuts 말고 Common 같은 곳에 묶어줘도 좋겠네요!
| 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/"); |
There was a problem hiding this comment.
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으로 캐스팅 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
id 가 기본적으로 string 으로 추정되지 않나요??
요구사항
기본
심화
멘토에게