feat(admin): optimize tender list pagination
continuous-integration/drone/push Build is passing

This commit is contained in:
AmirReza Jamali
2026-07-11 15:46:19 +03:30
parent 624614f1a9
commit a762a14026
7 changed files with 136 additions and 92 deletions
+21 -4
View File
@@ -1,6 +1,5 @@
"use client";
import { IMetaData } from "@/lib/api/types/Factory";
import { AxiosError } from "axios";
import { useCallback, useEffect, useMemo, useState } from "react";
@@ -12,7 +11,14 @@ const isInvalidCursorError = (error: unknown) => {
};
type UseHybridPaginationOptions = {
meta?: IMetaData;
meta?: {
limit: number;
offset: number;
page?: number;
pages?: number;
has_more?: boolean;
next_cursor?: string;
};
params: Record<string, unknown>;
setParams: React.Dispatch<React.SetStateAction<Record<string, any>>>;
isError?: boolean;
@@ -91,7 +97,14 @@ export const useHybridPagination = ({
if (meta?.page != null) return meta.page - 1;
return 0;
}, [cursorStack, params.cursor, params.offset, meta?.offset, meta?.page, limit]);
}, [
cursorStack,
params.cursor,
params.offset,
meta?.offset,
meta?.page,
limit,
]);
const hasPrevious = cursorStack.length > 0 || currentPageIndex > 0;
@@ -129,7 +142,11 @@ export const useHybridPagination = ({
{ cursor: nextCursor, fromPage: fromPage1Based },
]);
setParams((current) => {
const next: Record<string, any> = { ...current, cursor: nextCursor, limit };
const next: Record<string, any> = {
...current,
cursor: nextCursor,
limit,
};
delete next.offset;
return next;
});