forked from canada-ca/tracker
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathRelayPaginationControls.js
More file actions
67 lines (61 loc) · 1.45 KB
/
RelayPaginationControls.js
File metadata and controls
67 lines (61 loc) · 1.45 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
import { Button, Stack, Select, Text } from '@chakra-ui/core'
import { Trans } from '@lingui/macro'
import React from 'react'
import { array, bool, func, number } from 'prop-types'
export function RelayPaginationControls({
previous,
hasPreviousPage,
next,
hasNextPage,
selectedDisplayLimit,
setSelectedDisplayLimit,
displayLimitOptions,
...props
}) {
const options = displayLimitOptions.map((limit) => {
return (
<option value={limit} key={`option-${limit}`}>
{limit}
</option>
)
})
return (
<Stack isInline align="center" mb="4" {...props}>
<Button
id="previousPageBtn"
onClick={previous}
isDisabled={!hasPreviousPage}
aria-label="Previous page"
>
<Trans>Previous</Trans>
</Button>
<Button
id="nextPageBtn"
onClick={next}
isDisabled={!hasNextPage}
aria-label="Next page"
>
<Trans>Next</Trans>
</Button>
<Text ml="auto">
<Trans>Page Size:</Trans>
</Text>
<Select
value={selectedDisplayLimit}
onChange={(e) => setSelectedDisplayLimit(parseInt(e.target.value))}
width="fit-content"
>
{options}
</Select>
</Stack>
)
}
RelayPaginationControls.propTypes = {
previous: func,
hasPreviousPage: bool,
next: func,
hasNextPage: bool,
selectedDisplayLimit: number,
setSelectedDisplayLimit: func,
displayLimitOptions: array,
}