52 lines
993 B
TypeScript
52 lines
993 B
TypeScript
import React from 'react';
|
|
import style from './pagination.module.css';
|
|
|
|
interface Pagination {
|
|
currentPage: number;
|
|
numPages: number;
|
|
rootPath: string;
|
|
}
|
|
|
|
export default ({
|
|
currentPage,
|
|
numPages,
|
|
rootPath,
|
|
}: Pagination): JSX.Element => {
|
|
let prevPageLink = null;
|
|
if (currentPage === 2) {
|
|
prevPageLink = (
|
|
<a href={rootPath} className={style.prevPageLink}>
|
|
<<
|
|
</a>
|
|
);
|
|
} else if (currentPage !== 1) {
|
|
prevPageLink = (
|
|
<a
|
|
href={rootPath + '/' + (currentPage - 1)}
|
|
className={style.prevPageLink}
|
|
>
|
|
<<
|
|
</a>
|
|
);
|
|
}
|
|
|
|
if (numPages !== 1) {
|
|
return (
|
|
<p className={style.paginationNav}>
|
|
{prevPageLink}
|
|
{currentPage}
|
|
{currentPage !== numPages && (
|
|
<a
|
|
href={rootPath + '/' + (currentPage + 1)}
|
|
className={style.nextPageLink}
|
|
>
|
|
>>
|
|
</a>
|
|
)}
|
|
</p>
|
|
);
|
|
}
|
|
|
|
return null;
|
|
};
|