import Link from 'next/link' import { useTranslation } from 'next-i18next' import { LeftIcon, DoubleLeftIcon, RightIcon, DoubleRightIcon } from 'shared/components/icons.mjs' const pageButtonClasses = 'btn btn-primary btn-ghost text-base leading-none' const PageButton = ({ pageNum, label, title, hrefBuilder, visible = true }) => ( {label} ) const defaultHrefBuilder = (pageNum) => `${pageNum}` export const Pagination = ({ current, total, hrefBuilder = defaultHrefBuilder }) => { const { t } = useTranslation('common') const prevButtons = [] const nextButtons = [] const buttonProps = { hrefBuilder } for (let i = 1; i < 4; i++) { const isEnd = i === 3 prevButtons.unshift( : current - i, visible: current > i, ...buttonProps, }} /> ) nextButtons.push( : current + i, visible: current < total + 1 - i, ...buttonProps, }} /> ) } return (
, title: t('previous'), visible: current !== 1, ...buttonProps, }} />
{prevButtons} {current} {nextButtons}
, title: t('next'), visible: current !== total, ...buttonProps, }} />
) }