'use client'; import { Download } from 'lucide-react'; import Link from 'next/link'; import { useState } from 'react'; import { t } from '@/i18n'; import { cn } from '@/lib/cn'; import { routes } from '@/lib/site'; import { EntityPicker, type PickedEntity } from './entity-picker'; /** Typeahead → CSV / JSON download links for a country or an indicator dataset. */ export function DownloadPicker({ type }: { type: 'country' | 'indicator' }) { const [picked, setPicked] = useState(null); const href = (fmt: 'csv' | 'json') => (picked ? (type === 'country' ? routes.countryDownload(picked.id, fmt) : routes.indicatorDownload(picked.slug, fmt)) : '#'); const disabled = !picked; const cls = cn('inline-flex min-h-[44px] items-center gap-1.5 rounded-sm border px-3 text-sm md:min-h-[36px]', disabled ? 'pointer-events-none border-rule text-ink-3' : 'border-rule text-ink hover:bg-surface-2'); return (
CSV JSON {picked ? ( {picked.flag ? {picked.flag} : null} {picked.name} → ) : ( {t('data.pick')} )}
); }