Refactor shared data source selection for dashboard and map
This commit is contained in:
@@ -17,6 +17,7 @@ import { TopCountriesBarChart } from "../components/TopCountriesBarChart";
|
||||
import { TopCountriesPieChart } from "../components/TopCountriesPieChart";
|
||||
import { useCommonSectionStyles } from "../components/commonStyles";
|
||||
import { useDashboardCountryData } from "../hooks/useDashboardCountryData";
|
||||
import { getDataSource } from "../utils/queryUtils";
|
||||
import type { BanOriginFilter, TimeRange } from "../types/ban";
|
||||
|
||||
|
||||
@@ -71,7 +72,7 @@ export function DashboardPage(): React.JSX.Element {
|
||||
const [timeRange, setTimeRange] = useState<TimeRange>("24h");
|
||||
const [originFilter, setOriginFilter] = useState<BanOriginFilter>("all");
|
||||
|
||||
const source = timeRange === "24h" ? "fail2ban" : "archive";
|
||||
const source = getDataSource(timeRange);
|
||||
|
||||
const { countries, countryNames, isLoading: countryLoading, error: countryError, reload: reloadCountry } =
|
||||
useDashboardCountryData(timeRange, originFilter, source);
|
||||
|
||||
Reference in New Issue
Block a user