From e1e7a992890c31981af46a43ece271f26022e00d Mon Sep 17 00:00:00 2001 From: Sajid Mehmood Date: Thu, 16 Jul 2026 14:28:52 +0000 Subject: [PATCH] feat(WorldMap): click a country to filter dashboard by location Clicking a country on the WorldMap navigates to ?country=eq., which filters all dashboard panels via useFilterParameters. Clicking the active country again clears the filter. Adds a pointer cursor for affordance. --- src/components/metrics/WorldMap.tsx | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/src/components/metrics/WorldMap.tsx b/src/components/metrics/WorldMap.tsx index 3c8fadb80..d5866b82c 100644 --- a/src/components/metrics/WorldMap.tsx +++ b/src/components/metrics/WorldMap.tsx @@ -6,6 +6,7 @@ import { useCountryNames, useLocale, useMessages, + useNavigation, useWebsiteMetricsQuery, } from '@/components/hooks'; import { getThemeColors } from '@/lib/colors'; @@ -25,6 +26,7 @@ export function WorldMap({ websiteId, data, ...props }: WorldMapProps) { const { locale } = useLocale(); const { formatMessage, labels } = useMessages(); const { countryNames } = useCountryNames(locale); + const { router, updateParams, query } = useNavigation(); const visitorsLabel = formatMessage(labels.visitors).toLocaleLowerCase(locale); const unknownLabel = formatMessage(labels.unknown); @@ -64,6 +66,12 @@ export function WorldMap({ websiteId, data, ...props }: WorldMapProps) { ); }; + const handleClick = (code: string) => { + if (code === 'AQ') return; + const isActive = query.country === `eq.${code}`; + router.replace(updateParams(isActive ? { country: undefined } : { country: `eq.${code}` })); + }; + return ( handleHover(code)} onMouseOut={() => setTooltipPopup(null)} + onClick={() => handleClick(code)} /> ); });