import type { Metadata } from 'next'; import Link from 'next/link'; import { CompanyTable } from '@/components/company/company-table'; import { Pagination, withParams } from '@/components/ui/pagination'; import { Container, PageHeader, Unavailable } from '@/components/ui/section'; import { api, safe } from '@/lib/api'; import { cn } from '@/lib/cn'; import { fmtInt } from '@/lib/format'; import { flat, int, str, type SP } from '@/lib/params'; export const metadata: Metadata = { title: 'Companies', description: 'Directory of monitored companies with activity, hiring momentum, AI adoption, sensors and event counts.' }; export const revalidate = 120; const SORTS = [ ['activity', 'Activity'], ['events', 'Events'], ['hiring', 'Hiring'], ['recent', 'Most recent event'], ['importance', 'Importance'], ['name', 'Name'], ] as const; export default async function CompaniesPage({ searchParams }: { searchParams: Promise }) { const sp = await searchParams; const cur = flat(sp); const page = int(sp.page, 1); const query = { q: str(sp.q), country: str(sp.country), industry: str(sp.industry), tier: str(sp.tier), public: str(sp.public), has_events: str(sp.has_events), sort: str(sp.sort) ?? 'activity', page, per_page: 50, sparkline: 1 }; const [data, countries, industries] = await Promise.all([safe(api.companies(query)), safe(api.countries()), safe(api.industries())]); const href = (patch: Record) => withParams('/companies', cur, patch); return (
Sort {SORTS.map(([id, label]) => ( {label} ))} Public companies With events {(str(sp.q) || str(sp.country) || str(sp.industry) || str(sp.tier) || str(sp.public) || str(sp.has_events)) && ( Clear )}
{!data ? ( ) : ( <> href({ page: p > 1 ? p : undefined })} className="mt-4" /> )}
); }