Files
Mav-Mobile-UI/src/hooks/useSystemConfig.ts

33 lines
1.0 KiB
TypeScript
Raw Normal View History

2025-09-15 10:27:31 +01:00
import { useMutation, useQuery } from "@tanstack/react-query";
import { sendBlobFileUpload } from "../components/SettingForms/System/Upload";
import { toast } from "sonner";
import {
handleSystemSave,
handleSystemRecall,
} from "../components/SettingForms/System/SettingSaveRecall";
export const useSystemConfig = () => {
const uploadSettingsMutation = useMutation({
mutationKey: ["uploadSettings"],
mutationFn: sendBlobFileUpload,
onError: () => console.log("upload failed"),
onSuccess: (test) => console.log(test),
});
const saveSystemSettings = useMutation({
mutationKey: ["systemSaveSettings"],
mutationFn: handleSystemSave,
onSuccess: () => toast("System Settings Saved Successfully!"),
});
const getSystemSettings = useQuery({
queryKey: ["getSystemSettings"],
queryFn: handleSystemRecall,
});
return {
uploadSettings: uploadSettingsMutation.mutate,
saveSystemSettings: saveSystemSettings.mutate,
getSystemSettingsData: getSystemSettings.data,
};
};