/** * Copyright 2020 Design Barn Inc. */ import React from 'react'; interface PaginationProps { disabled?: boolean; limit: number; next: () => void; page: number; prev: () => void; total: number; } export const Pagination = ({ disabled = false, limit, next, page, prev, total }: PaginationProps) => { const offset = page * limit - limit; const currentPage = Math.ceil(offset / limit) + 1; const totalPages = Math.ceil(total / limit); const hasNext = offset + limit < total; const hasPrev = offset >= limit; const prevDisabled = disabled || !hasPrev; const nextDisabled = disabled || !hasNext; if (nextDisabled && prevDisabled) return null; return (