From 5c30e536170e66980be38e5150c5cc863d9677ac Mon Sep 17 00:00:00 2001 From: Usman Baig Date: Fri, 16 Jan 2026 20:15:09 +0100 Subject: [PATCH] feat: separate map into its own tab in Locations component --- components/dashboard/Countries.tsx | 44 ++++++++++++++++++++---------- 1 file changed, 29 insertions(+), 15 deletions(-) diff --git a/components/dashboard/Countries.tsx b/components/dashboard/Countries.tsx index e7095e4..7fa7ffc 100644 --- a/components/dashboard/Countries.tsx +++ b/components/dashboard/Countries.tsx @@ -10,7 +10,7 @@ interface LocationProps { cities: Array<{ city: string; country: string; pageviews: number }> } -type Tab = 'countries' | 'cities' +type Tab = 'map' | 'countries' | 'cities' export default function Locations({ countries, cities }: LocationProps) { const [activeTab, setActiveTab] = useState('countries') @@ -34,26 +34,30 @@ export default function Locations({ countries, cities }: LocationProps) { } const renderContent = () => { + if (activeTab === 'map') { + if (!countries || countries.length === 0) { + return

No data available

+ } + return + } + if (activeTab === 'countries') { if (!countries || countries.length === 0) { return

No data available

} return ( -
- -
- {countries.map((country, index) => ( -
-
- {getFlagComponent(country.country)} - {getCountryName(country.country)} -
-
- {formatNumber(country.pageviews)} -
+
+ {countries.map((country, index) => ( +
+
+ {getFlagComponent(country.country)} + {getCountryName(country.country)}
- ))} -
+
+ {formatNumber(country.pageviews)} +
+
+ ))}
) } @@ -87,6 +91,16 @@ export default function Locations({ countries, cities }: LocationProps) { Locations
+