// External imports
import * as React from "react"
// Internal imports
import * as ce from "../../../../helpers/componentEnhancer"
export interface ParentProps {
count: number
currentPageIndex: number
pageSize: number
goToPage: (pageIndex: number) => void
}
interface StateProps {}
interface DispatchProps {}
interface LocalState {}
class AdvancedTablePagination extends React.Component<
ParentProps & StateProps & DispatchProps & ce.EnhancedPropsPrivate,
LocalState
> {
render() {
// Calculate helping variables
// const firstRecordShownIndex = this.props.pageIndex * this.props.pageSize
// const lastRecordShownIndex = firstRecordShownIndex + this.props.pageSize - 1
const pagesAvailable = Math.ceil(this.props.count / this.props.pageSize)
const firstPageAvailableIndex = 0
const lastPageAvailableIndex = pagesAvailable - 1
const previousPageIndex = this.props.currentPageIndex - 1
const nextPageIndex = this.props.currentPageIndex + 1
const onFirstPage = this.props.currentPageIndex === firstPageAvailableIndex
const onLastPage = this.props.currentPageIndex === lastPageAvailableIndex
const currentPageNumberReadable = this.props.currentPageIndex + 1
const firstPageAvailableNumberReadable = firstPageAvailableIndex + 1
const lastPageAvailableNumberReadable = lastPageAvailableIndex + 1
const previousPageNumberReadable = previousPageIndex + 1
const nextPageNumberReadable = nextPageIndex + 1
if (pagesAvailable > 0) {
return (
)
} else return null
}
}
const stateMappings: ce.StateMappings = (s, props) => ({})
const dispatchMappings: ce.DispatchMappings = (d, props) => ({})
export default ((): React.ComponentType =>
ce.enhance(AdvancedTablePagination, { stateMappings, dispatchMappings }))()