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,
|
2025-09-16 14:20:38 +01:00
|
|
|
systemSettingsData: getSystemSettings.data,
|
2025-09-15 10:27:31 +01:00
|
|
|
};
|
|
|
|
|
};
|