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;
};
