Use larger page size in credential query temporarily (#1835)

This commit is contained in:
Shuchang Zheng
2025-02-25 08:08:19 -08:00
committed by GitHub
parent c4ca3ca0e8
commit 71307ce1ec
2 changed files with 22 additions and 15 deletions

View File

@@ -1,5 +1,3 @@
import { getClient } from "@/api/AxiosClient";
import { CredentialApiResponse } from "@/api/types";
import {
Select,
SelectContent,
@@ -8,8 +6,7 @@ import {
SelectValue,
} from "@/components/ui/select";
import { Skeleton } from "@/components/ui/skeleton";
import { useCredentialGetter } from "@/hooks/useCredentialGetter";
import { useQuery } from "@tanstack/react-query";
import { useCredentialsQuery } from "../hooks/useCredentialsQuery";
type Props = {
value: string;
@@ -17,17 +14,7 @@ type Props = {
};
function CredentialSelector({ value, onChange }: Props) {
const credentialGetter = useCredentialGetter();
const { data: credentials, isFetching } = useQuery<
Array<CredentialApiResponse>
>({
queryKey: ["credentials"],
queryFn: async () => {
const client = await getClient(credentialGetter);
return await client.get("/credentials").then((res) => res.data);
},
});
const { data: credentials, isFetching } = useCredentialsQuery();
if (isFetching) {
return <Skeleton className="h-10 w-full" />;

View File

@@ -0,0 +1,20 @@
import { getClient } from "@/api/AxiosClient";
import { CredentialApiResponse } from "@/api/types";
import { useCredentialGetter } from "@/hooks/useCredentialGetter";
import { useQuery } from "@tanstack/react-query";
function useCredentialsQuery() {
const credentialGetter = useCredentialGetter();
return useQuery<Array<CredentialApiResponse>>({
queryKey: ["credentials"],
queryFn: async () => {
const client = await getClient(credentialGetter);
const params = new URLSearchParams();
params.set("page_size", "25");
return client.get("/credentials", { params }).then((res) => res.data);
},
});
}
export { useCredentialsQuery };