import Link from 'next/link'; import { CompanyTable } from '@/components/company/company-table'; import { cn } from '@/lib/cn'; import { fmtInt, fmtPctSigned, fmtScore, fmtSigned } from '@/lib/format'; import { RANKING_KINDS, RANKING_WINDOWS, routes } from '@/lib/site'; import type { Rankings } from '@/lib/types'; export function RankingTabs({ kind, window, country, industry }: { kind: string; window: string; country?: string; industry?: string }) { const href = (k: string, w: string) => `${routes.rankings(k, w)}${country ? `&country=${country}` : ''}${industry ? `&industry=${industry}` : ''}`; return (
{RANKING_KINDS.map((k) => ( {k.label} ))}
{RANKING_WINDOWS.map((w) => ( {w} ))}
); } export function RankingsTable({ data }: { data: Rankings }) { const k = RANKING_KINDS.find((x) => x.id === data.kind) ?? RANKING_KINDS[0]!; const formatValue = (c: { value?: number }) => (k.unit === 'pct' ? fmtPctSigned(c.value) : k.unit === 'count' ? fmtInt(c.value) : fmtScore(c.value)); const formatDelta = (c: { delta?: number | null }) => (c.delta === null || c.delta === undefined ? null : k.unit === 'pct' ? fmtSigned(c.delta, 1) + ' pt' : fmtSigned(c.delta, 1)); return ; }