add network error state to hooks
This commit is contained in:
1 parent
d2d2e87184
commit
4559215316
5 files changed
+40
-17
No files matched your search
@@ -46,6 +46,7 @@ export const useMonitorFetch = ({
|
||||
const [monitors, setMonitors] = useState(undefined);
|
||||
const [filteredMonitors, setFilteredMonitors] = useState(undefined);
|
||||
const [monitorsSummary, setMonitorsSummary] = useState(undefined);
|
||||
const [networkError, setNetworkError] = useState(false);
|
||||
|
||||
const theme = useTheme();
|
||||
|
||||
@@ -72,6 +73,7 @@ export const useMonitorFetch = ({
|
||||
setFilteredMonitors(mappedMonitors);
|
||||
setMonitorsSummary(summary);
|
||||
} catch (error) {
|
||||
setNetworkError(true);
|
||||
createToast({
|
||||
body: error.message,
|
||||
});
|
||||
@@ -92,7 +94,13 @@ export const useMonitorFetch = ({
|
||||
theme,
|
||||
triggerUpdate,
|
||||
]);
|
||||
return { monitors, filteredMonitors, monitorsSummary, monitorsAreLoading };
|
||||
return {
|
||||
monitors,
|
||||
filteredMonitors,
|
||||
monitorsSummary,
|
||||
monitorsAreLoading,
|
||||
networkError,
|
||||
};
|
||||
};
|
||||
|
||||
export default useMonitorFetch;
|
||||
Reference in new issue
Block a user