implement datatable sorting on non-analytics tables. (website/board/link/pixel/team/admin)
This commit is contained in:
1 parent
b5c4dbfa56
commit
5ccfb6d0a5
39 files changed
+322
-100
No files matched your search
@@ -11,11 +11,18 @@ export interface PagerProps {
|
||||
className?: string;
|
||||
}
|
||||
|
||||
export function Pager({ page, pageSize, count, isCapped, onPageChange }: PagerProps) {
|
||||
export function Pager({
|
||||
page,
|
||||
pageSize,
|
||||
count,
|
||||
isCapped,
|
||||
onPageChange,
|
||||
}: PagerProps) {
|
||||
const { t, labels } = useMessages();
|
||||
const maxPage = pageSize && count ? Math.ceil(+count / +pageSize) : 0;
|
||||
const lastPage = page === maxPage;
|
||||
const firstPage = page === 1;
|
||||
const showNavigation = maxPage > 1 || isCapped;
|
||||
|
||||
if (count === 0 || !maxPage) {
|
||||
return null;
|
||||
@@ -29,34 +36,40 @@ export function Pager({ page, pageSize, count, isCapped, onPageChange }: PagerPr
|
||||
}
|
||||
};
|
||||
|
||||
if (maxPage === 1 && !isCapped) {
|
||||
return null;
|
||||
}
|
||||
|
||||
const displayCount = isCapped ? `10,000+` : (+count).toLocaleString();
|
||||
|
||||
return (
|
||||
<Row alignItems="center" justifyContent="space-between" gap="3" flexGrow={1}>
|
||||
<Text>{t(labels.numberOfRecords, { x: displayCount })}</Text>
|
||||
<Row alignItems="center" justifyContent="flex-end" gap="3">
|
||||
<Text>
|
||||
{t(labels.pageOf, {
|
||||
current: page.toLocaleString(),
|
||||
total: maxPage.toLocaleString(),
|
||||
})}
|
||||
</Text>
|
||||
<Row gap="1">
|
||||
<Button variant="outline" onPress={() => handlePageChange(-1)} isDisabled={firstPage}>
|
||||
<Icon size="sm" rotate={180}>
|
||||
<ChevronRight />
|
||||
</Icon>
|
||||
</Button>
|
||||
<Button variant="outline" onPress={() => handlePageChange(1)} isDisabled={lastPage}>
|
||||
<Icon size="sm">
|
||||
<ChevronRight />
|
||||
</Icon>
|
||||
</Button>
|
||||
</Row>
|
||||
<Row alignItems="center" justifyContent="space-between" gap="3" flexGrow={1} wrap="wrap">
|
||||
<Text color="muted">{t(labels.numberOfRecords, { x: displayCount })}</Text>
|
||||
<Row
|
||||
alignItems="center"
|
||||
justifyContent="flex-end"
|
||||
gap="3"
|
||||
wrap="nowrap"
|
||||
style={{ whiteSpace: 'nowrap' }}
|
||||
>
|
||||
{showNavigation && (
|
||||
<>
|
||||
<Text color="muted">
|
||||
{t(labels.pageOf, {
|
||||
current: page.toLocaleString(),
|
||||
total: maxPage.toLocaleString(),
|
||||
})}
|
||||
</Text>
|
||||
<Row gap="1">
|
||||
<Button variant="outline" onPress={() => handlePageChange(-1)} isDisabled={firstPage}>
|
||||
<Icon size="sm" rotate={180}>
|
||||
<ChevronRight />
|
||||
</Icon>
|
||||
</Button>
|
||||
<Button variant="outline" onPress={() => handlePageChange(1)} isDisabled={lastPage}>
|
||||
<Icon size="sm">
|
||||
<ChevronRight />
|
||||
</Icon>
|
||||
</Button>
|
||||
</Row>
|
||||
</>
|
||||
)}
|
||||
</Row>
|
||||
</Row>
|
||||
);
|
||||
|
||||
Reference in new issue
Block a user