From 0240a7e5c7f5e8b3a594e2b2569c0665eb0c2c18 Mon Sep 17 00:00:00 2001 From: Sajid Mehmood Date: Thu, 30 Apr 2026 20:22:56 +0000 Subject: [PATCH] Filter analytics by country on world map click Clicking a country in the WorldMap now adds a `country=eq.` filter to the URL, mirroring the existing FilterLink behavior used elsewhere in the dashboard. Adds a pointer cursor on filterable shapes. Run-on: Niteshift Co-Authored-By: Claude Opus 4.7 --- src/components/metrics/WorldMap.tsx | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/src/components/metrics/WorldMap.tsx b/src/components/metrics/WorldMap.tsx index 3c8fadb80f..10155cb95b 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 } = useNavigation(); const visitorsLabel = formatMessage(labels.visitors).toLocaleLowerCase(locale); const unknownLabel = formatMessage(labels.unknown); @@ -64,6 +66,11 @@ export function WorldMap({ websiteId, data, ...props }: WorldMapProps) { ); }; + const handleClick = (code: string) => { + if (!code || code === 'AQ') return; + router.replace(updateParams({ country: `eq.${code}` })); + }; + return ( handleHover(code)} onMouseOut={() => setTooltipPopup(null)} + onClick={() => handleClick(code)} /> ); });