feat(lst): added update settings into the entire app
This commit is contained in:
3
frontend/src/utils/delay.ts
Normal file
3
frontend/src/utils/delay.ts
Normal file
@@ -0,0 +1,3 @@
|
||||
export function delay(ms: number) {
|
||||
return new Promise((resolve) => setTimeout(resolve, ms));
|
||||
}
|
||||
17
frontend/src/utils/querys/settings.tsx
Normal file
17
frontend/src/utils/querys/settings.tsx
Normal file
@@ -0,0 +1,17 @@
|
||||
import {queryOptions} from "@tanstack/react-query";
|
||||
import axios from "axios";
|
||||
|
||||
export function getSettings(token: string) {
|
||||
return queryOptions({
|
||||
queryKey: ["settings"],
|
||||
queryFn: () => fetchSettings(token),
|
||||
enabled: !!token,
|
||||
staleTime: 1000,
|
||||
refetchOnWindowFocus: true,
|
||||
});
|
||||
}
|
||||
|
||||
const fetchSettings = async (token: string) => {
|
||||
const {data} = await axios.get("/api/server/settings", {headers: {Authorization: `Bearer ${token}`}});
|
||||
return data.data;
|
||||
};
|
||||
Reference in New Issue
Block a user