Proyectos de Subversion LeadersLinked - Backend

Rev

Rev 12475 | Rev 12712 | Ir a la última revisión | Mostrar el archivo completo | | | Autoría | Ultima modificación | Ver Log |

Rev 12475 Rev 12711
Línea 80... Línea 80...
80
	)
80
	)
81
}
81
}
Línea 82... Línea 82...
82
 
82
 
Línea 83... Línea -...
83
export const TablePagination = ({ onDecrement, onIncrement, currentPage, totalPages }) => {
-
 
84
 
-
 
85
	const maxPages = 5 > totalPages ? totalPages : 5
-
 
86
	const [pages, setPages] = useState([])
-
 
87
	let nextPage = currentPage + 1
-
 
88
	let previousPage = currentPage - 1
-
 
89
 
-
 
90
	useEffect(() => {
-
 
91
		while (pages.length < maxPages) {
-
 
92
			const pagesArray = [currentPage]
-
 
93
 
-
 
94
			if (previousPage > 0) {
-
 
95
				pagesArray.unshift(previousPage)
-
 
96
			}
-
 
97
			if (nextPage <= totalPages) {
-
 
98
				pagesArray.push(nextPage)
-
 
99
			}
-
 
100
 
-
 
101
			return setPages(pagesArray)
-
 
102
		}
-
 
103
 
-
 
104
	}, [currentPage, totalPages])
83
export const TablePagination = ({ onDecrement, onIncrement, currentPage, totalPages }) => {
105
 
84
 
106
	return (
85
	return (
107
		<ul className="pagination mb-0">
86
		<ul className="pagination mb-0">
108
			<li className="paginate_button page-item previous disabled">
87
			<li className={`paginate_button page-item previous ${currentPage === 1 ? 'disabled' : ''}`}>
109
				<button
88
				<button
110
					type='button'
89
					type='button'
111
					className="page-link"
90
					className="page-link"
Línea 118... Línea 97...
118
			<li className="paginate_button page-item">
97
			<li className="paginate_button page-item">
119
				<button className="page-link">
98
				<button className="page-link">
120
					{currentPage}
99
					{currentPage}
121
				</button>
100
				</button>
122
			</li>
101
			</li>
123
			<li className="paginate_button page-item next">
102
			<li className={`paginate_button page-item next ${currentPage === totalPages ? 'disabled' : ''}`}>
124
				<button
103
				<button
125
					type='button'
104
					type='button'
126
					className="page-link"
105
					className="page-link"
127
					disabled={currentPage === totalPages}
106
					disabled={currentPage === totalPages}
128
					onClick={onIncrement}
107
					onClick={onIncrement}