/** * API functions for the world map / bans-by-country endpoint. */ import { get } from "./client"; import { ENDPOINTS } from "./endpoints"; import type { BansByCountryResponse, TimeRange } from "../types/map"; import type { BanOriginFilter } from "../types/ban"; /** * Fetch ban counts aggregated by country for the given time window. * * @param range - Time-range preset. * @param origin - Origin filter: `"blocklist"`, `"selfblock"`, or `"all"` * (default `"all"`, which omits the parameter entirely). */ export async function fetchBansByCountry( range: TimeRange = "24h", origin: BanOriginFilter = "all", ): Promise { const params = new URLSearchParams({ range }); if (origin !== "all") { params.set("origin", origin); } return get(`${ENDPOINTS.dashboardBansByCountry}?${params.toString()}`); }