All files / src/components Pagination.tsx

100% Statements 5/5
100% Branches 6/6
100% Functions 2/2
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 36 37 38 39 40 41 42 43 44              66x 31x 31x                     4x                                           66x  
import { Popover, Space, TablePaginationConfig } from 'antd';
import React from 'react';
import { InfoCircleOutlined } from '@ant-design/icons';
import { Trans } from 'react-i18next';
import { RECORD_PER_PAGE_OPTIONS } from '@config/base';
import { PaginationProps } from '@props/RecordProps';
 
export const getTablePagination = (props: PaginationProps): TablePaginationConfig => {
  const { current, total, pageSize, showLessItems, showQuickJumper, showSizeChanger, onChange, instruction } = props;
  return {
    defaultCurrent: 1,
    position: ["bottomCenter"],
    size: "small",
    current,
    total,
    pageSize,
    showLessItems: showLessItems ?? false,
    showSizeChanger: showSizeChanger ?? true,
    showQuickJumper: showQuickJumper ?? true,
    showTotal: (total: number, range: Array<number>) => {
      return (<span className="list-paginiation-count" >
        <Popover
          title={undefined}
          content={<Space direction="vertical" style={{ minWidth: '400px' }}>
            <Trans
              i18nKey="PaginationMsg"
              values={{ start: range[0], end: range[1], total }}
            >
            </Trans>
            <>{instruction}</>
          </Space>
          }>
          <InfoCircleOutlined />
        </Popover>
      </span>);
    },
    responsive: true,
    pageSizeOptions: RECORD_PER_PAGE_OPTIONS,
    onChange
  };
};
 
export const getPagination = getTablePagination;