mirror of
https://github.com/aaronpo97/the-biergarten-app.git
synced 2026-02-16 20:13:49 +00:00
38 lines
842 B
TypeScript
38 lines
842 B
TypeScript
import { useRouter } from 'next/router';
|
|
import { FC } from 'react';
|
|
|
|
interface PaginationProps {
|
|
pageNum: number;
|
|
pageCount: number;
|
|
}
|
|
|
|
const Pagination: FC<PaginationProps> = ({ pageCount, pageNum }) => {
|
|
const router = useRouter();
|
|
|
|
return (
|
|
<div className="btn-group">
|
|
<button
|
|
className="btn"
|
|
disabled={pageNum <= 1}
|
|
onClick={async () =>
|
|
router.push({ pathname: '/beers', query: { page_num: pageNum - 1 } })
|
|
}
|
|
>
|
|
«
|
|
</button>
|
|
<button className="btn">Page {pageNum}</button>
|
|
<button
|
|
className="btn"
|
|
disabled={pageNum >= pageCount}
|
|
onClick={async () =>
|
|
router.push({ pathname: '/beers', query: { page_num: pageNum + 1 } })
|
|
}
|
|
>
|
|
»
|
|
</button>
|
|
</div>
|
|
);
|
|
};
|
|
|
|
export default Pagination;
|