Krishya | b5ef96d | 2025-06-05 13:57:05 +0800 | [diff] [blame] | 1 | import React from 'react'; |
| 2 | import { useGroupStore } from '../../context/useGroupStore'; |
| 3 | |
| 4 | const GroupPagination = () => { |
| 5 | const { page, totalPages, setPage } = useGroupStore(); |
| 6 | |
| 7 | const handlePrevPage = () => { |
| 8 | if (page > 1) setPage(page - 1); |
| 9 | }; |
| 10 | |
| 11 | const handleNextPage = () => { |
| 12 | if (page < totalPages) setPage(page + 1); |
| 13 | }; |
| 14 | |
| 15 | return ( |
| 16 | <div className="pagination"> |
| 17 | <button onClick={handlePrevPage} disabled={page <= 1}> |
| 18 | 上一页 |
| 19 | </button> |
| 20 | <span>第 {page} 页 / 共 {totalPages} 页</span> |
| 21 | <button onClick={handleNextPage} disabled={page >= totalPages}> |
| 22 | 下一页 |
| 23 | </button> |
| 24 | </div> |
| 25 | ); |
| 26 | }; |
| 27 | |
| 28 | export default GroupPagination; |