Proyectos de Subversion LeadersLinked - Backend

Rev

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

Rev 11938 Rev 14164
Línea 1... Línea 1...
1
import React, { useEffect } from 'react'
1
import React from 'react'
2
import styled from 'styled-components'
2
import styled from 'styled-components'
3
import { Pagination } from 'react-bootstrap'
3
import { Pagination } from 'react-bootstrap'
Línea 4... Línea 4...
4
 
4
 
5
const StyledDefaultPagination = styled(Pagination)`
5
const StyledDefaultPagination = styled(Pagination)`
Línea 17... Línea 17...
17
  flex-direction: initial !important;
17
  flex-direction: initial !important;
18
  position: inherit !important;
18
  position: inherit !important;
19
  transform: inherit !important;
19
  transform: inherit !important;
20
`
20
`
Línea 21... Línea -...
21
 
-
 
22
const PaginationComponent = (props) => {
21
 
-
 
22
const PaginationComponent = ({ pages = 1, currentActivePage = 1, onChangePage, isRow = true }) => {
23
	const { pages = 1, currentActivePage = 1, onChangePage } = props
23
 
24
	const currentPage = currentActivePage
24
	const currentPage = currentActivePage
25
	const StyledPagination = props.isRow ? StyledRowPagination : StyledDefaultPagination
25
	const StyledPagination = isRow ? StyledRowPagination : StyledDefaultPagination
26
	// const pages = 10;
26
	// const pages = 10;
27
	const nextPages = []
27
	const nextPages = []
28
	const previousPages = []
28
	const previousPages = []
Línea 29... Línea -...
29
	const maxPages = 5 > pages ? pages : 5
-
 
30
 
-
 
31
	useEffect(() => { }, [currentPage, pages])
29
	const maxPages = 5 > pages ? pages : 5
32
 
30
 
33
	const generateCurrentPages = () => {
31
	const generateCurrentPages = () => {
34
		let isPreviousOrNext = false
32
		let isPreviousOrNext = false
35
		let pagesCont = 1
33
		let pagesCont = 1
Línea 67... Línea 65...
67
		onChangePage(pageToNavigate)
65
		onChangePage(pageToNavigate)
68
	}
66
	}
Línea 69... Línea 67...
69
 
67
 
70
	generateCurrentPages()
68
	generateCurrentPages()
71
	return (
-
 
72
		<React.Fragment>
69
	return (
-
 
70
		pages > 1
73
			{pages > 1 ? (
71
		&&
74
				<StyledPagination>
72
		<StyledPagination>
75
					<Pagination.Prev
73
			<Pagination.Prev
76
						disabled={currentPage - 1 <= 0}
74
				disabled={currentPage - 1 <= 0}
77
						onClick={previousPageHandler}
75
				onClick={previousPageHandler}
78
					/>
76
			/>
79
					{previousPages.map((previousPage) => (
77
			{previousPages.map((previousPage) =>
80
						<Pagination.Item
78
				<Pagination.Item
81
							key={previousPage}
79
					key={previousPage}
82
							onClick={() => onClickHandler(previousPage)}
80
					onClick={() => onClickHandler(previousPage)}
83
						>
81
				>
84
							{previousPage}
82
					{previousPage}
85
						</Pagination.Item>
83
				</Pagination.Item>
86
					))}
84
			)}
87
					<Pagination.Item active>{currentPage}</Pagination.Item>
85
			<Pagination.Item active>{currentPage}</Pagination.Item>
88
					{nextPages.map((nextPage) => (
86
			{nextPages.map((nextPage) =>
89
						<Pagination.Item
87
				<Pagination.Item
90
							key={nextPage}
88
					key={nextPage}
91
							onClick={() => onClickHandler(nextPage)}
89
					onClick={() => onClickHandler(nextPage)}
92
						>
90
				>
93
							{nextPage}
91
					{nextPage}
94
						</Pagination.Item>
-
 
95
					))}
-
 
96
					<Pagination.Next
-
 
97
						onClick={nextPageHandler}
-
 
98
						disabled={currentPage + 1 > pages}
-
 
99
					/>
-
 
100
				</StyledPagination>
-
 
101
			) : (
-
 
102
				''
92
				</Pagination.Item>
-
 
93
			)}
-
 
94
			<Pagination.Next
-
 
95
				onClick={nextPageHandler}
-
 
96
				disabled={currentPage + 1 > pages}
103
			)}
97
			/>
104
		</React.Fragment>
98
		</StyledPagination>
105
	)
99
	)
Línea 106... Línea 100...
106
}
100
}
107
 
101