import type { Metadata } from 'next'; import Link from 'next/link'; import { t } from '@/i18n'; import { isNotBuilt } from '@/lib/api'; import { apiExplore } from '@/lib/api-explore'; import { formatDate } from '@/lib/format'; import { routes } from '@/lib/site'; import type { ChangesFeedResponse } from '@/lib/types-explore'; import { ChangesFeed } from '@/components/changes/changes-feed'; import { NotBuiltState } from '@/components/data/empty-state'; import { Section } from '@/components/data/section'; import { PageHeader } from '@/components/explore/page-header'; import { Movers } from '@/components/home/movers'; import { apiAnalytics } from '@/lib/api-analytics'; import { safe } from '@/lib/api'; export const revalidate = 900; export const metadata: Metadata = { title: t('changes.title'), description: t('changes.sub'), alternates: { canonical: routes.changes() }, }; type SP = Record; export default async function ChangesPage({ searchParams }: { searchParams: Promise }) { const sp = await searchParams; const countryRaw = Array.isArray(sp.country) ? sp.country[0] : sp.country; const country = countryRaw && /^[a-z0-9-]+$/i.test(countryRaw) ? countryRaw : undefined; let data: ChangesFeedResponse | null = null; try { data = await apiExplore.changes({ limit: 100, country }); } catch (e) { if (!isNotBuilt(e)) throw e; } const winRaw = Array.isArray(sp.window) ? sp.window[0] : sp.window; const win: 5 | 10 = winRaw === '10' ? 10 : 5; const movers = await safe(apiAnalytics.movers({ window: win, limit: 12 })); return ( <> {country ? (

{t('changes.filteredCountry', { country })}{' '} {t('changes.clearCountry')}

) : null} {!data ? ( ) : ( <>
› {t('changes.methodology')}

{t('changes.how')}

{t('site.footer.methodology')} →

)} ); }