/*! ========================================================= * Argon Dashboard Chakra PRO - v1.0.0 ========================================================= * Product Page: https://www.creative-tim.com/product/argon-dashboard-chakra-pro * Copyright 2022 Creative Tim (https://www.creative-tim.com/) * Designed and Coded by Simmmple & Creative Tim ========================================================= * The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. */ import { Button, Flex, Icon, Input, NumberDecrementStepper, NumberIncrementStepper, NumberInput, NumberInputField, NumberInputStepper, Select, Stack, Table, Tbody, Td, Text, Th, Thead, Tr, } from "@chakra-ui/react"; import React, { useMemo } from "react"; import { GrFormNext, GrFormPrevious } from "react-icons/gr"; import { TiArrowSortedDown, TiArrowSortedUp, TiArrowUnsorted, } from "react-icons/ti"; import { useGlobalFilter, usePagination, useSortBy, useTable, } from "react-table"; function SearchTable1(props) { const { columnsData, tableData } = props; const columns = useMemo(() => columnsData, []); const data = useMemo(() => tableData, []); const tableInstance = useTable( { columns, data, }, useGlobalFilter, useSortBy, usePagination ); const { getTableProps, getTableBodyProps, headerGroups, page, gotoPage, pageCount, prepareRow, nextPage, previousPage, canNextPage, canPreviousPage, setPageSize, setGlobalFilter, state, } = tableInstance; const createPages = (count) => { let arrPageCount = []; for (let i = 1; i <= count; i++) { arrPageCount.push(i); } return arrPageCount; }; const { pageIndex, pageSize, globalFilter } = state; return ( <> entries per page setGlobalFilter(e.target.value)} /> {headerGroups.map((headerGroup, index) => ( {headerGroup.headers.map((column, index) => ( ))} ))} {page.map((row, index) => { prepareRow(row); return ( {row.cells.map((cell, index) => { return ( ); })} ); })}
{column.render("Header")}
{cell.render("Cell")}
Showing {pageSize * pageIndex + 1} to{" "} {pageSize * (pageIndex + 1) <= tableData.length ? pageSize * (pageIndex + 1) : tableData.length}{" "} of {tableData.length} entries {pageSize === 5 ? ( gotoPage(e)} > nextPage()} /> previousPage()} /> ) : ( createPages(pageCount).map((pageNumber, index) => { return ( ); }) )}
); } export default SearchTable1;