mirror of
https://github.com/docmost/docmost.git
synced 2026-05-07 22:53:08 +08:00
78b1c1a453
* add cursor pagination function * support custom order modifier * refactor returned object * feat(db): migrate paginated endpoints to cursor-based pagination * sync * support hasPrevPage boolean * feat(client): migrate pagination from offset to cursor-based * support beforeCursor/prevCursor * wrap search results in items array for API consistency
45 lines
841 B
TypeScript
45 lines
841 B
TypeScript
import { Button, Group } from "@mantine/core";
|
|
import { useTranslation } from "react-i18next";
|
|
|
|
export interface PagePaginationProps {
|
|
hasPrevPage: boolean;
|
|
hasNextPage: boolean;
|
|
onPrev: () => void;
|
|
onNext: () => void;
|
|
}
|
|
|
|
export default function Paginate({
|
|
hasPrevPage,
|
|
hasNextPage,
|
|
onPrev,
|
|
onNext,
|
|
}: PagePaginationProps) {
|
|
const { t } = useTranslation();
|
|
|
|
if (!hasPrevPage && !hasNextPage) {
|
|
return null;
|
|
}
|
|
|
|
return (
|
|
<Group mt="md" justify="flex-end">
|
|
<Button
|
|
variant="default"
|
|
size="compact-sm"
|
|
onClick={onPrev}
|
|
disabled={!hasPrevPage}
|
|
>
|
|
{t("Prev")}
|
|
</Button>
|
|
|
|
<Button
|
|
variant="default"
|
|
size="compact-sm"
|
|
onClick={onNext}
|
|
disabled={!hasNextPage}
|
|
>
|
|
{t("Next")}
|
|
</Button>
|
|
</Group>
|
|
);
|
|
}
|