1
|
|
|
import React, { useContext } from 'react'; |
2
|
|
|
import PropTypes from 'prop-types'; |
3
|
|
|
import AppContext from '../../../context/Context'; |
4
|
|
|
import { Button, CardFooter } from 'reactstrap'; |
5
|
|
|
import Flex from '../../common/Flex'; |
6
|
|
|
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome'; |
7
|
|
|
import { getPaginationArray } from '../../../helpers/utils'; |
8
|
|
|
|
9
|
|
|
const EquipmentFooter = ({ meta, handler }) => { |
10
|
|
|
const { isRTL } = useContext(AppContext); |
11
|
|
|
const { total, pageNo, itemsPerPage, nextPageNo, prevPageNo } = meta; |
12
|
|
|
const { nextPage, prevPage, currentPage } = handler; |
13
|
|
|
|
14
|
|
|
return ( |
15
|
|
|
<CardFooter tag={Flex} justify="center" align="center" className="bg-light border-top"> |
16
|
|
|
<Button color="falcon-default" size="sm" className="ml-1 ml-sm-2" onClick={prevPage} disabled={!prevPageNo}> |
17
|
|
|
<FontAwesomeIcon icon={`chevron-${isRTL ? 'right' : 'left'}`} /> |
18
|
|
|
</Button> |
19
|
|
|
{getPaginationArray(total, itemsPerPage).map(page => ( |
20
|
|
|
<Button |
21
|
|
|
color={pageNo === page ? 'falcon-primary' : 'falcon-default'} |
22
|
|
|
size="sm" |
23
|
|
|
className="ml-2" |
24
|
|
|
onClick={() => currentPage(page)} |
25
|
|
|
key={page} |
26
|
|
|
> |
27
|
|
|
{page} |
28
|
|
|
</Button> |
29
|
|
|
))} |
30
|
|
|
<Button color="falcon-default" size="sm" className="ml-1 ml-sm-2" onClick={nextPage} disabled={!nextPageNo}> |
31
|
|
|
<FontAwesomeIcon icon={`chevron-${isRTL ? 'left' : 'right'}`} /> |
32
|
|
|
</Button> |
33
|
|
|
</CardFooter> |
34
|
|
|
); |
35
|
|
|
}; |
36
|
|
|
|
37
|
|
|
EquipmentFooter.propTypes = { |
38
|
|
|
meta: PropTypes.object.isRequired, |
39
|
|
|
handler: PropTypes.object.isRequired |
40
|
|
|
}; |
41
|
|
|
|
42
|
|
|
export default EquipmentFooter; |
43
|
|
|
|