Passed
Push — master ( 4f3f28...c5d2bd )
by Guangyu
04:38 queued 11s
created

src/components/MyEMS/Monitoring/EquipmentFooter.js   A

Complexity

Total Complexity 3
Complexity/F 0

Size

Lines of Code 43
Function Count 0

Duplication

Duplicated Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
wmc 3
eloc 37
mnd 3
bc 3
fnc 0
dl 0
loc 43
rs 10
bpm 0
cpm 0
noi 0
c 0
b 0
f 0
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