diff --git a/src/app/api/admin/stats/route.ts b/src/app/api/admin/stats/route.ts index a2cdfb1..50597ab 100644 --- a/src/app/api/admin/stats/route.ts +++ b/src/app/api/admin/stats/route.ts @@ -2,6 +2,8 @@ import { NextRequest, NextResponse } from 'next/server'; import { cookies } from 'next/headers'; import { db } from '@/lib/db'; +export const dynamic = 'force-dynamic'; + export async function GET(request: NextRequest) { try { // Check newsletter-admin cookie authentication diff --git a/src/components/analytics/GeoMap.tsx b/src/components/analytics/GeoMap.tsx index ea77896..ecd5c71 100644 --- a/src/components/analytics/GeoMap.tsx +++ b/src/components/analytics/GeoMap.tsx @@ -81,37 +81,37 @@ const countryNameToCode: Record = { }; // ISO Alpha-2 to ISO Alpha-3 mapping (for matching with TopoJSON) -const alpha2ToAlpha3: Record = { - 'US': 'USA', - 'DE': 'DEU', - 'GB': 'GBR', - 'FR': 'FRA', - 'CA': 'CAN', - 'AU': 'AUS', - 'JP': 'JPN', - 'CN': 'CHN', - 'IN': 'IND', - 'BR': 'BRA', - 'ES': 'ESP', - 'IT': 'ITA', - 'NL': 'NLD', - 'CH': 'CHE', - 'AT': 'AUT', - 'PL': 'POL', - 'SE': 'SWE', - 'NO': 'NOR', - 'DK': 'DNK', - 'FI': 'FIN', - 'BE': 'BEL', - 'PT': 'PRT', - 'IE': 'IRL', - 'MX': 'MEX', - 'AR': 'ARG', - 'KR': 'KOR', - 'SG': 'SGP', - 'NZ': 'NZL', - 'RU': 'RUS', - 'ZA': 'ZAF', +const alpha2ToNumeric: Record = { + 'US': '840', + 'DE': '276', + 'GB': '826', + 'FR': '250', + 'CA': '124', + 'AU': '036', + 'JP': '392', + 'CN': '156', + 'IN': '356', + 'BR': '076', + 'ES': '724', + 'IT': '380', + 'NL': '528', + 'CH': '756', + 'AT': '040', + 'PL': '616', + 'SE': '752', + 'NO': '578', + 'DK': '208', + 'FI': '246', + 'BE': '056', + 'PT': '620', + 'IE': '372', + 'MX': '484', + 'AR': '032', + 'KR': '410', + 'SG': '702', + 'NZ': '554', + 'RU': '643', + 'ZA': '710', }; interface CountryStat { @@ -132,9 +132,9 @@ const GeoMap: React.FC = ({ countryStats, totalScans }) => { countryStats.forEach((stat) => { const alpha2 = countryNameToCode[stat.country] || stat.country; - const alpha3 = alpha2ToAlpha3[alpha2]; - if (alpha3) { - countryData[alpha3] = stat.count; + const numericCode = alpha2ToNumeric[alpha2]; + if (numericCode) { + countryData[numericCode] = stat.count; if (stat.count > maxCount) maxCount = stat.count; } }); @@ -158,8 +158,9 @@ const GeoMap: React.FC = ({ countryStats, totalScans }) => { {({ geographies }) => geographies.map((geo) => { - const isoCode = geo.properties.ISO_A3 || geo.id; - const scanCount = countryData[isoCode] || 0; + // geo.id is the numeric ISO code as a string (e.g., "840" for US) + const geoId = geo.id; + const scanCount = countryData[geoId] || 0; const fillColor = scanCount > 0 ? colorScale(scanCount) : '#F1F5F9'; return (