diff --git a/src/components/ui/index.ts b/src/components/ui/index.ts index fcd78fe..031face 100644 --- a/src/components/ui/index.ts +++ b/src/components/ui/index.ts @@ -14,3 +14,4 @@ export { Dropdown } from './dropdown'; export { Filter } from './filter'; export { Icon } from './icon'; export { Modal, Notification } from './modal'; +export { Pagination } from './pagination'; diff --git a/src/components/ui/input/TimeInput.tsx b/src/components/ui/input/TimeInput.tsx index aa637b8..bac386a 100644 --- a/src/components/ui/input/TimeInput.tsx +++ b/src/components/ui/input/TimeInput.tsx @@ -7,7 +7,7 @@ import { useCallback, useRef, useState } from 'react'; import Input from './input'; export default function TimeInput() { - const { value: open, toggle, setClose } = useToggle(false); + const { isOpen, toggle, setClose } = useToggle(false); const [period, setPeriod] = useState('오전'); const [selectedTime, setSelectedTime] = useState(null); const [inputValue, setInputValue] = useState(''); // typing 사용 @@ -15,7 +15,7 @@ export default function TimeInput() { const wrapperRef = useRef(null); useClickOutside(wrapperRef, () => { - if (open) setClose(); + if (isOpen) setClose(); }); // 시간 업데이트 중앙 관리 @@ -94,7 +94,7 @@ export default function TimeInput() { onChange={handleTimeInputChange} /> - {open && ( + {isOpen && (
void; + total: number; // 전체 개수 (count) + offset: number; // 현재 offset + limit: number; // 한 페이지당 아이템 수 + onPageChange: (next: number) => void; // 새 offset 전달 + className?: string; } -// totalItems 는 API 통신 시 Response 로 받는 """count""" 부모로부터 넘겨주기! -const Pagination = ({ totalItems, currentPage, itemsPerPage, onPageChange }: PaginationProps) => { +/* { const [pageGroup, setPageGroup] = useState(0); - const totalPages = totalItems ? Math.ceil(totalItems / itemsPerPage) : 0; + const totalPages = total ? Math.ceil(total / limit) : 0; + const currentPage = Math.floor(offset / limit) + 1; // offset → page 변환 useEffect(() => { const newGroup = Math.floor((currentPage - 1) / PAGE_GROUP_SIZE); @@ -29,45 +33,70 @@ const Pagination = ({ totalItems, currentPage, itemsPerPage, onPageChange }: Pag const isPrevDisabled = pageGroup === 0; const isNextDisabled = (pageGroup + 1) * PAGE_GROUP_SIZE >= totalPages; + /* 이전 그룹으로 이동 */ + const handlePrevPage = () => { + if (!isPrevDisabled) { + setPageGroup(prev => Math.max(prev - 1, 0)); + } + }; + + /* 다음 그룹으로 이동 */ + const handleNextPage = () => { + if (!isNextDisabled) { + setPageGroup(prev => ((prev + 1) * PAGE_GROUP_SIZE < totalPages ? prev + 1 : prev)); + } + }; + + /* 페이지 클릭 시 offset 계산 후 전달 */ + const handlePageClick = (page: number) => { + const newOffset = (page - 1) * limit; + onPageChange(newOffset); + }; + return ( - <> -
-
- - {pageNumbers.map(page => ( - - ))} - -
-
- +
+ {/* 이전 */} + + + {/* 페이지 번호 */} + {pageNumbers.map(page => ( + + ))} + + {/* 다음 */} + +
); };