251201_01_ENH : datatable, autocomplete, user관리 완성

This commit is contained in:
2025-12-02 13:45:35 +09:00
parent 74de3d58f7
commit 310506d9ef
45 changed files with 5313 additions and 368 deletions

View File

@@ -0,0 +1,38 @@
import { useMemo } from 'react'
interface UsePaginationProps {
currentPage: number
totalPages: number
paginationItemsToDisplay?: number
}
export function usePagination({
currentPage,
totalPages,
paginationItemsToDisplay = 5
}: UsePaginationProps) {
const { pages, showLeftEllipsis, showRightEllipsis } = useMemo(() => {
const halfDisplay = Math.floor(paginationItemsToDisplay / 2)
let startPage = Math.max(1, currentPage - halfDisplay)
let endPage = Math.min(totalPages, currentPage + halfDisplay)
if (currentPage <= halfDisplay) {
endPage = Math.min(paginationItemsToDisplay, totalPages)
}
if (currentPage > totalPages - halfDisplay) {
startPage = Math.max(1, totalPages - paginationItemsToDisplay + 1)
}
const pages = Array.from({ length: endPage - startPage + 1 }, (_, i) => startPage + i)
return {
pages,
showLeftEllipsis: startPage > 1,
showRightEllipsis: endPage < totalPages
}
}, [currentPage, totalPages, paginationItemsToDisplay])
return { pages, showLeftEllipsis, showRightEllipsis }
}