Paginate the tables with queries

This commit is contained in:
Owen
2026-04-20 20:05:59 -07:00
parent c8d560d78f
commit f938e9c3c0
5 changed files with 97 additions and 49 deletions

View File

@@ -259,18 +259,24 @@ export const orgQueries = {
alertRules: ({
orgId,
limit = 20,
offset = 0
offset = 0,
query
}: {
orgId: string;
limit?: number;
offset?: number;
query?: string;
}) =>
queryOptions({
queryKey: ["ORG", orgId, "ALERT_RULES", { limit, offset }] as const,
queryKey: ["ORG", orgId, "ALERT_RULES", { limit, offset, query }] as const,
queryFn: async ({ signal, meta }) => {
const sp = new URLSearchParams();
sp.set("limit", String(limit));
sp.set("offset", String(offset));
if (query) sp.set("query", query);
const res = await meta!.api.get<
AxiosResponse<ListAlertRulesResponse>
>(`/org/${orgId}/alert-rules?limit=${limit}&offset=${offset}`, { signal });
>(`/org/${orgId}/alert-rules?${sp.toString()}`, { signal });
return {
alertRules: res.data.data.alertRules,
pagination: res.data.data.pagination
@@ -303,15 +309,21 @@ export const orgQueries = {
standaloneHealthChecks: ({
orgId,
limit = 20,
offset = 0
offset = 0,
query
}: {
orgId: string;
limit?: number;
offset?: number;
query?: string;
}) =>
queryOptions({
queryKey: ["ORG", orgId, "STANDALONE_HEALTH_CHECKS", { limit, offset }] as const,
queryKey: ["ORG", orgId, "STANDALONE_HEALTH_CHECKS", { limit, offset, query }] as const,
queryFn: async ({ signal, meta }) => {
const sp = new URLSearchParams();
sp.set("limit", String(limit));
sp.set("offset", String(offset));
if (query) sp.set("query", query);
const res = await meta!.api.get<
AxiosResponse<{
healthChecks: {
@@ -344,7 +356,7 @@ export const orgQueries = {
offset: number;
};
}>
>(`/org/${orgId}/health-checks?limit=${limit}&offset=${offset}`, { signal });
>(`/org/${orgId}/health-checks?${sp.toString()}`, { signal });
return {
healthChecks: res.data.data.healthChecks,
pagination: res.data.data.pagination