import React, { useState } from "react"; import { Select, HStack, Text, Box, IconButton } from "@chakra-ui/react"; import { ChevronLeftIcon, ChevronRightIcon } from "@chakra-ui/icons"; const Pagination = ({ pageSize, setPageSize, totalItems = 1, isLoading, setCurrentPage, currentPage, }) => { // const [] = useState(itemsPerPageOptions[0]); const totalPages = Math.ceil(totalItems / pageSize); const handlePageSizeChange = (e) => { setPageSize(Number(e.target.value)); setCurrentPage(1); // Reset to first page whenever page size changes }; const paginationPrev = () => { if (currentPage > 1) { setCurrentPage(currentPage - 1); } }; const paginationNext = () => { if (currentPage < totalPages) { setCurrentPage(currentPage + 1); } }; const displayRange = { start: (currentPage - 1) * pageSize + 1, end: Math.min(currentPage * pageSize, totalItems), }; return ( {/* Tanami v0.1 */} } onClick={paginationPrev} className="link pointer" isDisabled={currentPage === 1} aria-label="Previous Page" /> {isLoading ? "0" : displayRange?.start} -{" "} {isLoading ? "00" : displayRange?.end} of{" "} {isLoading ? "00" : totalItems} } size={"sm"} rounded="sm" onClick={paginationNext} className="link pointer" isDisabled={currentPage === totalPages} aria-label="Next Page" /> ); }; export default Pagination;