"use client"; import { CircleMarker, MapContainer, TileLayer, Tooltip } from "react-leaflet"; import "leaflet/dist/leaflet.css"; import { useTheme } from "next-themes"; import { useEffect, useState } from "react"; import { getLocalizedCountryName } from "../lib/localization"; interface CountryData { code: string; count: number; coordinates: [number, number]; } interface MapProps { countryData: CountryData[]; maxCount: number; } const CountryMap = ({ countryData, maxCount }: MapProps) => { const { theme } = useTheme(); const [mounted, setMounted] = useState(false); useEffect(() => { setMounted(true); }, []); // Don't render until mounted to avoid hydration mismatch if (!mounted) { return
; } const isDark = theme === "dark"; // Use different tile layers based on theme const tileLayerUrl = isDark ? "https://{s}.basemaps.cartocdn.com/dark_all/{z}/{x}/{y}{r}.png" : "https://{s}.basemaps.cartocdn.com/light_all/{z}/{x}/{y}{r}.png"; const tileLayerAttribution = isDark ? '© OpenStreetMap contributors © CARTO' : '© OpenStreetMap contributors © CARTO'; return ( {countryData.map((country) => (
{getLocalizedCountryName(country.code)}
Sessions: {country.count}
))}
); }; export default CountryMap;