Converted to Vite since create-react-app is no longer being developed

This commit is contained in:
Jamie Curnow
2023-07-20 15:11:41 +10:00
parent 824a22efad
commit 6d6021c9bb
115 changed files with 2511 additions and 10015 deletions

View File

@@ -1,10 +1,11 @@
import { useQuery } from "@tanstack/react-query";
import {
getHosts,
HostsResponse,
tableSortToAPI,
tableFiltersToAPI,
} from "api/npm";
import { useQuery } from "react-query";
} from "src/api/npm";
const fetchHosts = (offset = 0, limit = 10, sortBy?: any, filters?: any) => {
return getHosts(
@@ -22,15 +23,13 @@ const useHosts = (
filters?: any,
options = {},
) => {
return useQuery<HostsResponse, Error>(
["hosts", { offset, limit, sortBy, filters }],
() => fetchHosts(offset, limit, sortBy, filters),
{
keepPreviousData: true,
staleTime: 15 * 1000, // 15 seconds
...options,
},
);
return useQuery<HostsResponse, Error>({
queryKey: ["hosts", { offset, limit, sortBy, filters }],
queryFn: () => fetchHosts(offset, limit, sortBy, filters),
keepPreviousData: true,
staleTime: 15 * 1000, // 15 seconds
...options,
});
};
export { fetchHosts, useHosts };