Standardise loading state naming across dashboard hooks

This commit is contained in:
2026-04-21 19:12:43 +02:00
parent 094fb4fece
commit b3eb5dc6ec
9 changed files with 25 additions and 25 deletions

View File

@@ -21,7 +21,7 @@ export interface UseBanTrendResult {
/** Human-readable bucket size label, e.g. `"1h"`. */
bucketSize: string;
/** True while a fetch is in flight. */
isLoading: boolean;
loading: boolean;
/** Error message or `null`. */
error: string | null;
/** Re-fetch the data immediately. */
@@ -46,7 +46,7 @@ export function useBanTrend(
): UseBanTrendResult {
const [buckets, setBuckets] = useState<BanTrendBucket[]>([]);
const [bucketSize, setBucketSize] = useState<string>("1h");
const [isLoading, setIsLoading] = useState<boolean>(true);
const [loading, setLoading] = useState<boolean>(true);
const [error, setError] = useState<string | null>(null);
const abortRef = useRef<AbortController | null>(null);
@@ -56,7 +56,7 @@ export function useBanTrend(
const controller = new AbortController();
abortRef.current = controller;
setIsLoading(true);
setLoading(true);
setError(null);
fetchBanTrend(timeRange, origin, source, controller.signal)
@@ -71,7 +71,7 @@ export function useBanTrend(
})
.finally(() => {
if (!controller.signal.aborted) {
setIsLoading(false);
setLoading(false);
}
});
}, [timeRange, origin, source]);
@@ -83,5 +83,5 @@ export function useBanTrend(
};
}, [load]);
return { buckets, bucketSize, isLoading, error, reload: load };
return { buckets, bucketSize, loading, error, reload: load };
}

View File

@@ -27,7 +27,7 @@ export interface UseDashboardCountryDataResult {
/** Total ban count in the window. */
total: number;
/** True while a fetch is in flight. */
isLoading: boolean;
loading: boolean;
/** Error message or `null`. */
error: string | null;
/** Re-fetch the data immediately. */
@@ -54,7 +54,7 @@ export function useDashboardCountryData(
const [countryNames, setCountryNames] = useState<Record<string, string>>({});
const [bans, setBans] = useState<DashboardBanItem[]>([]);
const [total, setTotal] = useState<number>(0);
const [isLoading, setIsLoading] = useState<boolean>(true);
const [loading, setLoading] = useState<boolean>(true);
const [error, setError] = useState<string | null>(null);
const abortRef = useRef<AbortController | null>(null);
@@ -65,7 +65,7 @@ export function useDashboardCountryData(
const controller = new AbortController();
abortRef.current = controller;
setIsLoading(true);
setLoading(true);
setError(null);
fetchBansByCountry(timeRange, origin, source)
@@ -82,7 +82,7 @@ export function useDashboardCountryData(
})
.finally(() => {
if (!controller.signal.aborted) {
setIsLoading(false);
setLoading(false);
}
});
}, [timeRange, origin, source]);
@@ -94,5 +94,5 @@ export function useDashboardCountryData(
};
}, [load]);
return { countries, countryNames, bans, total, isLoading, error, reload: load };
return { countries, countryNames, bans, total, loading, error, reload: load };
}

View File

@@ -21,7 +21,7 @@ export interface UseJailDistributionResult {
/** Total ban count for the selected window. */
total: number;
/** True while a fetch is in flight. */
isLoading: boolean;
loading: boolean;
/** Error message or `null`. */
error: string | null;
/** Re-fetch the data immediately. */
@@ -45,7 +45,7 @@ export function useJailDistribution(
): UseJailDistributionResult {
const [jails, setJails] = useState<JailBanCount[]>([]);
const [total, setTotal] = useState<number>(0);
const [isLoading, setIsLoading] = useState<boolean>(true);
const [loading, setLoading] = useState<boolean>(true);
const [error, setError] = useState<string | null>(null);
const abortRef = useRef<AbortController | null>(null);
@@ -55,7 +55,7 @@ export function useJailDistribution(
const controller = new AbortController();
abortRef.current = controller;
setIsLoading(true);
setLoading(true);
setError(null);
fetchBansByJail(timeRange, origin, "fail2ban", controller.signal)
@@ -70,7 +70,7 @@ export function useJailDistribution(
})
.finally(() => {
if (!controller.signal.aborted) {
setIsLoading(false);
setLoading(false);
}
});
}, [timeRange, origin]);
@@ -82,5 +82,5 @@ export function useJailDistribution(
};
}, [load]);
return { jails, total, isLoading, error, reload: load };
return { jails, total, loading, error, reload: load };
}