![]() Server : Apache System : Linux server2.corals.io 4.18.0-348.2.1.el8_5.x86_64 #1 SMP Mon Nov 15 09:17:08 EST 2021 x86_64 User : corals ( 1002) PHP Version : 7.4.33 Disable Function : exec,passthru,shell_exec,system Directory : /home/corals/mets.corals.io/wp-content/plugins/give/src/Views/Components/Pagination/ |
import PropTypes from 'prop-types'; import { __ } from '@wordpress/i18n' const Pagination = ({currentPage, totalPages, disabled, setPage}) => { if (1 >= totalPages) { return false; } const nextPage = parseInt(currentPage) + 1; const previousPage = parseInt(currentPage) - 1; return ( <div className="tablenav bottom"> <div className="tablenav-pages"> <div className="pagination-links"> {previousPage > 0 ? ( <> <a href="#" className="tablenav-pages-navspan button" onClick={(e) => { e.preventDefault(); if (!disabled) { setPage(1); } }} > « </a>{' '} <a href="#" className="tablenav-pages-navspan button" onClick={(e) => { e.preventDefault(); if (!disabled) { setPage(parseInt(currentPage) - 1); } }} > ‹ </a> </> ) : ( <span className="tablenav-pages-navspan button disabled">‹</span> )} <span className="screen-reader-text">{__('Current Page', 'give')}</span> <span id="table-paging" className="paging-input"> <span className="tablenav-paging-text"> {' '} {currentPage} {__('of', 'give')} <span className="total-pages">{totalPages}</span>{' '} </span> </span> {nextPage <= totalPages ? ( <> <a href="#" className="tablenav-pages-navspan button" onClick={(e) => { e.preventDefault(); if (!disabled) { setPage(parseInt(currentPage) + 1); } }} > › </a>{' '} <a href="#" className="tablenav-pages-navspan button" onClick={(e) => { e.preventDefault(); if (!disabled) { setPage(totalPages); } }} > » </a> </> ) : ( <span className="tablenav-pages-navspan button disabled">›</span> )} </div> </div> </div> ); }; Pagination.propTypes = { // Current page currentPage: PropTypes.number.isRequired, // Total number of pages totalPages: PropTypes.number.isRequired, // Function to set the next/previous page setPage: PropTypes.func.isRequired, // Is pagination disabled disabled: PropTypes.bool.isRequired, }; Pagination.defaultProps = { currentPage: 1, totalPages: 0, setPage: () => {}, disabled: false, }; export default Pagination;