import { __ } from '@wordpress/i18n' const Pagination = ({currentPage = 1, totalPages = 0, disabled = false, setPage = (page) => {}}) => { if (1 >= totalPages) { return null; } const nextPage = parseInt(currentPage) + 1; const previousPage = parseInt(currentPage) - 1; return (
{previousPage > 0 ? ( <> { e.preventDefault(); if (!disabled) { setPage(1); } }} > « {' '} { e.preventDefault(); if (!disabled) { setPage(parseInt(currentPage) - 1); } }} > ‹ ) : ( ‹ )} {__('Current Page', 'give')} {' '} {currentPage} {__('of', 'give')} {totalPages}{' '} {nextPage <= totalPages ? ( <> { e.preventDefault(); if (!disabled) { setPage(parseInt(currentPage) + 1); } }} > › {' '} { e.preventDefault(); if (!disabled) { setPage(totalPages); } }} > » ) : ( › )}
); }; export default Pagination;