]> Untitled Git - lemmy-ui.git/blob - src/shared/components/common/paginator.tsx
2c877575d7daa2b370c5d8442f3b094b381c5f0d
[lemmy-ui.git] / src / shared / components / common / paginator.tsx
1 import { Component, linkEvent } from "inferno";
2 import { i18n } from "../../i18next";
3
4 interface PaginatorProps {
5   page: bigint;
6   onChange(val: bigint): any;
7 }
8
9 export class Paginator extends Component<PaginatorProps, any> {
10   constructor(props: any, context: any) {
11     super(props, context);
12   }
13   render() {
14     return (
15       <div className="my-2">
16         <button
17           className="btn btn-secondary mr-2"
18           disabled={this.props.page == 1n}
19           onClick={linkEvent(this, this.handlePrev)}
20         >
21           {i18n.t("prev")}
22         </button>
23         <button
24           className="btn btn-secondary"
25           onClick={linkEvent(this, this.handleNext)}
26         >
27           {i18n.t("next")}
28         </button>
29       </div>
30     );
31   }
32
33   handlePrev(i: Paginator) {
34     i.props.onChange(i.props.page - 1n);
35   }
36
37   handleNext(i: Paginator) {
38     i.props.onChange(i.props.page + 1n);
39   }
40 }