From bb87defe2b4a9d489e7fb965867f098951897c53 Mon Sep 17 00:00:00 2001 From: Usman Baig Date: Fri, 16 Jan 2026 19:16:20 +0100 Subject: [PATCH] feat: Implement country name retrieval in dashboard component --- components/dashboard/Countries.tsx | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/components/dashboard/Countries.tsx b/components/dashboard/Countries.tsx index d54b505..ba03ec9 100644 --- a/components/dashboard/Countries.tsx +++ b/components/dashboard/Countries.tsx @@ -27,6 +27,16 @@ export default function Countries({ countries }: CountriesProps) { return FlagComponent ? : null } + const getCountryName = (code: string) => { + if (!code || code === 'Unknown') return 'Unknown' + try { + const regionNames = new Intl.DisplayNames(['en'], { type: 'region' }) + return regionNames.of(code) || code + } catch (e) { + return code + } + } + return (

@@ -37,7 +47,7 @@ export default function Countries({ countries }: CountriesProps) {
{getFlagComponent(country.country)} - {country.country === 'Unknown' ? 'Unknown' : country.country} + {getCountryName(country.country)}
{formatNumber(country.pageviews)}