All files / app/components CursorPagination.tsx

71.42% Statements 5/7
0% Branches 0/5
0% Functions 0/1
71.42% Lines 5/7

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 475x 5x 5x 5x 5x                                                                                    
import ChevronLeftIcon from "@mui/icons-material/ChevronLeft";
import ChevronRightIcon from "@mui/icons-material/ChevronRight";
import { Box, Button, Stack } from "@mui/material";
import { useTranslation } from "i18n";
import { GLOBAL } from "i18n/namespaces";
 
interface CursorPaginationProps {
  hasPreviousPage: boolean;
  hasNextPage: boolean | undefined;
  onPrevious: () => void;
  onNext: () => void;
  isLoading?: boolean;
}
 
export default function CursorPagination({
  hasPreviousPage,
  hasNextPage,
  onPrevious,
  onNext,
  isLoading = false,
}: CursorPaginationProps) {
  const { t } = useTranslation([GLOBAL]);
 
  return (
    <Box display="flex" justifyContent="center" mt={2}>
      <Stack direction="row" spacing={2}>
        <Button
          variant="outlined"
          startIcon={<ChevronLeftIcon />}
          onClick={onPrevious}
          disabled={!hasPreviousPage || isLoading}
        >
          {t("previous")}
        </Button>
        <Button
          variant="outlined"
          endIcon={<ChevronRightIcon />}
          onClick={onNext}
          disabled={!hasNextPage || isLoading}
        >
          {t("next")}
        </Button>
      </Stack>
    </Box>
  );
}