Debian Codegraph @

jsx/src/components/PaginationFooter/PaginationFooter.jsx

raw
1 import React from "react";
2 import PropTypes from "prop-types";
3 import { Button, FormControl } from "react-bootstrap";
4
5 const PaginationFooter = (props) => {
6 const { offset, limit, visible, total, next, prev, handleLimit } = props;
7 return (
8 <div className="pagination-footer">
9 <p>
10 Displaying {visible ? offset + 1 : offset}-{offset + visible}{" "}
11 {total ? `of ${total}` : ""}
12 <br />
13 {offset >= 1 ? (
14 <Button
15 variant="light"
16 size="sm"
17 onClick={prev}
18 className="me-2"
19 data-testid="paginate-prev"
20 >
21 Previous
22 </Button>
23 ) : (
24 <Button
25 variant="light"
26 size="sm"
27 className="me-2"
28 disabled
29 aria-disabled="true"
30 >
31 Previous
32 </Button>
33 )}
34 {offset + visible < total ? (
35 <Button
36 variant="light"
37 size="sm"
38 className="me-2"
39 onClick={next}
40 data-testid="paginate-next"
41 >
42 Next
43 </Button>
44 ) : (
45 <Button
46 variant="light"
47 size="sm"
48 className="me-2"
49 disabled
50 aria-disabled="true"
51 >
52 Next
53 </Button>
54 )}
55 <label>
56 Items per page:
57 <FormControl
58 type="number"
59 min="25"
60 step="25"
61 name="pagination-limit"
62 placeholder={limit}
63 aria-label="pagination-limit"
64 defaultValue={limit}
65 onChange={handleLimit}
66 />
67 </label>
68 </p>
69 </div>
70 );
71 };
72
73 PaginationFooter.propTypes = {
74 endpoint: PropTypes.string,
75 offset: PropTypes.number,
76 limit: PropTypes.number,
77 visible: PropTypes.number,
78 total: PropTypes.number,
79 handleLimit: PropTypes.func,
80 next: PropTypes.func,
81 prev: PropTypes.func,
82 };
83
84 export default PaginationFooter;