'use client' import { formatNumber } from '@/lib/utils/format' import * as Flags from 'country-flag-icons/react/3x2' interface RegionsProps { regions: Array<{ region: string; country: string; pageviews: number }> } export default function Regions({ regions }: RegionsProps) { if (!regions || regions.length === 0) { return (

Regions

No data available

) } const getFlagComponent = (countryCode: string) => { if (!countryCode || countryCode === 'Unknown') return null const FlagComponent = (Flags as any)[countryCode] return FlagComponent ? : null } return (

Regions

{regions.map((region, index) => (
{getFlagComponent(region.country)} {region.region === 'Unknown' ? 'Unknown' : region.region}
{formatNumber(region.pageviews)}
))}
) }