/* istanbul ignore file */

import React from 'react';
import PropTypes from 'prop-types';
import { connectPagination } from 'react-instantsearch-dom';

import classes from './style.module.scss';

var CustomPagination = function CustomPagination(_ref) {
  var currentRefinement = _ref.currentRefinement,
      nbPages = _ref.nbPages,
      refine = _ref.refine;

  if (nbPages <= 1) return null;

  var handlePageChange = function handlePageChange(e, i) {
    refine(currentRefinement + i);
    e.stopPropagation();
  };

  return React.createElement(
    'footer',
    { className: classes.SearchPagination },
    currentRefinement !== nbPages && React.createElement(
      'button',
      {
        className: classes['SearchPagination-Button'],
        'focus-hit': 'firstElementChild',
        onClick: function onClick(e) {
          return handlePageChange(e, 1);
        },
        type: 'button'
      },
      'Next'
    ),
    React.createElement(
      'span',
      { className: classes['SearchPagination-State'] },
      currentRefinement,
      ' of ',
      nbPages
    ),
    currentRefinement !== 1 && React.createElement(
      'button',
      {
        className: classes['SearchPagination-Button'],
        'focus-hit': 'lastElementChild',
        onClick: function onClick(e) {
          return handlePageChange(e, -1);
        },
        type: 'button'
      },
      'Back'
    )
  );
};

var Pagination = connectPagination(CustomPagination);

CustomPagination.propTypes = process.env.NODE_ENV !== "production" ? {
  currentRefinement: PropTypes.number,
  nbPages: PropTypes.number,
  refine: PropTypes.func
} : {};

export default Pagination;