2019-03-09 15:20:43 +03:00
|
|
|
import { DropdownItem, DropdownMenu, DropdownToggle, UncontrolledDropdown } from 'reactstrap';
|
|
|
|
|
2020-08-31 19:38:27 +03:00
|
|
|
interface PaginationDropdownProps {
|
|
|
|
ranges: number[];
|
|
|
|
value: number;
|
|
|
|
setValue: (newValue: number) => void;
|
|
|
|
toggleClassName?: string;
|
|
|
|
}
|
2019-03-09 15:20:43 +03:00
|
|
|
|
2020-08-31 19:38:27 +03:00
|
|
|
const PaginationDropdown = ({ toggleClassName, ranges, value, setValue }: PaginationDropdownProps) => (
|
2019-03-09 15:20:43 +03:00
|
|
|
<UncontrolledDropdown>
|
2022-03-11 18:37:41 +03:00
|
|
|
<DropdownToggle caret color="link" className={toggleClassName}>Paginate</DropdownToggle>
|
|
|
|
<DropdownMenu end>
|
2019-03-09 15:20:43 +03:00
|
|
|
{ranges.map((itemsPerPage) => (
|
|
|
|
<DropdownItem key={itemsPerPage} active={itemsPerPage === value} onClick={() => setValue(itemsPerPage)}>
|
|
|
|
<b>{itemsPerPage}</b> items per page
|
|
|
|
</DropdownItem>
|
|
|
|
))}
|
|
|
|
<DropdownItem divider />
|
|
|
|
<DropdownItem disabled={value === Infinity} onClick={() => setValue(Infinity)}>
|
|
|
|
<i>Clear pagination</i>
|
|
|
|
</DropdownItem>
|
|
|
|
</DropdownMenu>
|
|
|
|
</UncontrolledDropdown>
|
|
|
|
);
|
|
|
|
|
|
|
|
export default PaginationDropdown;
|