mirror of
https://github.com/khairul169/garage-webui.git
synced 2026-09-15 00:43:21 +07:00
feat: add cluster & bucket management
This commit is contained in:
@@ -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"),
|
||||
});
|
||||
};
|
||||
@@ -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;
|
||||
};
|
||||
Reference in New Issue
Block a user