feat: add cluster & bucket management

This commit is contained in:
2024-08-16 01:23:55 +07:00
parent b0e5d53ee0
commit dfb4e30e23
41 changed files with 1394 additions and 67 deletions
+10
View File
@@ -0,0 +1,10 @@
import api from "@/lib/api";
import { Config } from "@/types/garage";
import { useQuery } from "@tanstack/react-query";
export const useConfig = () => {
return useQuery<Config>({
queryKey: ["config"],
queryFn: () => api.get("/config"),
});
};
+20
View File
@@ -0,0 +1,20 @@
import { useCallback, useRef } from "react";
export const useDebounce = <T extends (...args: any[]) => void>(
fn: T,
delay: number = 500
) => {
const timerRef = useRef<NodeJS.Timeout | null>(null);
const debouncedFn = useCallback(
(...args: any[]) => {
if (timerRef.current) {
clearTimeout(timerRef.current);
}
timerRef.current = setTimeout(() => fn(...args), delay);
},
[fn]
);
return debouncedFn as T;
};