Add MAX_PAGING_RESULTS on hooks for performance improvements.
This commit is contained in:
1 parent
a8c1f26775
commit
fbac7518fc
17 files changed
+74
-215
No files matched your search
@@ -41,7 +41,7 @@ export function DataGrid({
|
||||
const { data, error, isLoading, isFetching } = query;
|
||||
const { router, updateParams, query: queryParams } = useNavigation();
|
||||
const [search, setSearch] = useState(queryParams?.search || data?.search || '');
|
||||
const showPager = allowPaging && data && data.count > data.pageSize;
|
||||
const showPager = allowPaging && data && (data.count > data.pageSize || data.isCapped);
|
||||
const { isMobile } = useMobile();
|
||||
const displayMode = isMobile ? 'cards' : undefined;
|
||||
|
||||
@@ -95,6 +95,7 @@ export function DataGrid({
|
||||
page={data.page}
|
||||
pageSize={data.pageSize}
|
||||
count={data.count}
|
||||
isCapped={data.isCapped}
|
||||
onPageChange={handlePageChange}
|
||||
/>
|
||||
</Row>
|
||||
|
||||
@@ -6,11 +6,12 @@ export interface PagerProps {
|
||||
page: string | number;
|
||||
pageSize: string | number;
|
||||
count: string | number;
|
||||
isCapped?: boolean;
|
||||
onPageChange: (nextPage: number) => void;
|
||||
className?: string;
|
||||
}
|
||||
|
||||
export function Pager({ page, pageSize, count, 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;
|
||||
@@ -28,13 +29,15 @@ export function Pager({ page, pageSize, count, onPageChange }: PagerProps) {
|
||||
}
|
||||
};
|
||||
|
||||
if (maxPage === 1) {
|
||||
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: count.toLocaleString() })}</Text>
|
||||
<Text>{t(labels.numberOfRecords, { x: displayCount })}</Text>
|
||||
<Row alignItems="center" justifyContent="flex-end" gap="3">
|
||||
<Text>
|
||||
{t(labels.pageOf, {
|
||||
|
||||
Reference in new issue
Block a user