more enhancements to loading and error feedback

This commit is contained in:
2025-10-06 15:18:58 +01:00
parent f275f50383
commit a95c9077c4
10 changed files with 127 additions and 167 deletions

View File

@@ -5,25 +5,43 @@ import {
handleSystemSave,
handleSystemRecall,
} from "../components/SettingForms/System/SettingSaveRecall";
import { useEffect } from "react";
export const useSystemConfig = () => {
const uploadSettingsMutation = useMutation({
mutationKey: ["uploadSettings"],
mutationFn: sendBlobFileUpload,
onError: (error) => toast.error(error.message),
onSuccess: (test) => toast(test),
onError: (error) =>
toast.error(error.message, {
id: "uploadSettings",
}),
onSuccess: (test) =>
toast(test, {
id: "uploadSettings",
}),
});
const saveSystemSettings = useMutation({
mutationKey: ["systemSaveSettings"],
mutationFn: handleSystemSave,
onError: (error) => console.error(error.message),
onError: (error) =>
toast.error(error.message, {
id: "systemSettings",
}),
});
const getSystemSettings = useQuery({
queryKey: ["getSystemSettings"],
queryFn: handleSystemRecall,
});
useEffect(() => {
if (getSystemSettings.isError)
toast.error(getSystemSettings.error.message, {
id: "systemSettings",
});
}, [getSystemSettings?.error?.message, getSystemSettings.isError]);
return {
uploadSettings: uploadSettingsMutation.mutate,
saveSystemSettings: saveSystemSettings.mutate,