Updated loading states and error states accross app
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
import { toast } from "sonner";
|
||||
import type { SystemValues } from "../../../types/types";
|
||||
import { CAM_BASE } from "../../../utils/config";
|
||||
|
||||
@@ -35,7 +36,13 @@ export async function handleSystemSave(values: SystemValues) {
|
||||
);
|
||||
}
|
||||
} catch (err) {
|
||||
console.error(err);
|
||||
if (err instanceof Error) {
|
||||
toast.error(`Failed to save system settings: ${err.message}`);
|
||||
console.error(err);
|
||||
} else {
|
||||
toast.error("An unexpected error occurred while saving.");
|
||||
console.error("Unknown error:", err);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -79,7 +86,12 @@ export async function handleSystemRecall() {
|
||||
|
||||
return { deviceName, sntpServer, sntpInterval, timeZone };
|
||||
} catch (err) {
|
||||
console.error(err);
|
||||
if (err instanceof Error) {
|
||||
toast.error(`Error: ${err.message}`);
|
||||
} else {
|
||||
toast.error("An unexpected error occurred");
|
||||
}
|
||||
|
||||
return null;
|
||||
} finally {
|
||||
clearTimeout(timeoutId);
|
||||
|
||||
Reference in New Issue
Block a user