add: tree / search

This commit is contained in:
h z
2025-03-05 01:23:09 +00:00
parent 39a69ca5b8
commit 2911f8722e
4 changed files with 96 additions and 93 deletions

19
src/utils/tree-queries.js Normal file
View File

@@ -0,0 +1,19 @@
import {useQuery, useMutation, useQueryClient} from "react-query";
import {fetch_} from "./request-utils";
import {useConfig} from "../ConfigProvider";
export const useTree = () => {
const queryClient = useQueryClient();
const config = useConfig();
return useQuery(
"tree",
() => fetch_(`${config.BACKEND_HOST}/api/tree/`),
{
onSuccess: data => {
if(data)
queryClient.setQueryData("tree", data);
}
}
);
}