All files / src/apps/containers/components ContainerPagination.tsx

33.33% Statements 2/6
100% Branches 0/0
0% Functions 0/3
33.33% Lines 2/6

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 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54                      1x                       1x                                                            
import React from "react";
import { Grid, Theme, TablePagination } from "@mui/material";
import { createStyles, makeStyles } from "@mui/styles";
 
interface Props {
  num_found: number;
  per_page: number;
  page: number;
  onPageChange: Function;
}
 
const useStyles = makeStyles((theme: Theme) =>
  createStyles({
    pagination: {
      justifyItems: "center",
      display: "grid",
      position: "fixed",
      bottom: 0,
      background: theme.palette.background.default,
      width: "100%"
    }
  })
);
const ContainerPagination: React.FC<Props> = ({
  num_found,
  per_page,
  page,
  onPageChange
}) => {
  const classes = useStyles();
 
  return (
    <Grid item xs={12} className={classes.pagination}>
      <TablePagination
        rowsPerPageOptions={[per_page]}
        component="div"
        count={Number(num_found)}
        rowsPerPage={per_page}
        page={page - 1}
        backIconButtonProps={{
          "aria-label": "previous page"
        }}
        nextIconButtonProps={{
          "aria-label": "next page"
        }}
        onPageChange={(_: any, page: number) => onPageChange(page + 1)}
        data-testid="pagination"
      />
    </Grid>
  );
};
 
export default ContainerPagination;