All files / src/componentsV2/Table/components TablePaginationCount.tsx

83.33% Statements 5/6
77.77% Branches 7/9
100% Functions 1/1
100% Lines 5/5

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35                        34x             243x   243x 243x       243x                
import GiveText from "@shared/Text/GiveText";
 
interface TablePaginationCountProps {
  rowsPerPage: number;
  page: number;
  totalRows?: number;
  // TRA013 AC007: for infinite-scroll tables the range reflects how many rows
  // have been loaded so far (1 – loadedRows), updating as the user scrolls.
  loadedRows?: number;
  isInfiniteScroll?: boolean;
}
 
const TablePaginationCount = ({
  rowsPerPage,
  page,
  totalRows = 0,
  loadedRows = 0,
  isInfiniteScroll = false,
}: TablePaginationCountProps) => {
  Iif (totalRows === 0) return;
 
  const start = isInfiniteScroll ? 1 : (page - 1) * rowsPerPage + 1;
  const end = isInfiniteScroll
    ? Math.min(loadedRows, totalRows)
    : Math.min(page * rowsPerPage, totalRows);
 
  return (
    <GiveText variant="bodyS" color="secondary">
      Showing {start} – {end} of {totalRows}
    </GiveText>
  );
};
 
export default TablePaginationCount;