// components/Dashboard.tsx
// Server component that renders the dashboard surface for the
// registry overview. All data is passed in via props from the page
// (which is responsible for the PocketBase calls).
//
// Sections, top to bottom:
// 1. KPI strip — five tiles across the top
// 2. Status distribution — single progress-bar showing how the
// company portfolio splits across the four status buckets
// 3. Onboarding activity — last 5 submissions, with a CTA into
// the inbox
// 4. Recently updated — last 5 companies, last 5 directors
// 5. Quick links — replaces the old prose "What you can do here"
// with actionable links to the most useful filters
//
// All numbers are pre-formatted in the parent so this component
// stays free of formatting concerns.
import Link from "next/link";
import StatCard from "@/components/StatCard";
import StatusBadge from "@/components/StatusBadge";
import OverviewSearch, {
type OverviewSearchItem,
} from "@/components/OverviewSearch";
import { formatDate } from "@/lib/format";
import type {
YsterbaardCompany,
YsterbaardDirector,
} from "@/lib/types";
export interface DashboardProps {
kpis: {
directors: { total: number; activeRoles: number; clients: number };
companies: {
total: number;
active: number;
inProcess: number;
inactive: number;
deregistered: number;
clients: number;
};
};
statusDistribution: ReadonlyArray<{
key: "active" | "in_process" | "inactive" | "deregistered";
label: string;
count: number;
}>;
recentCompanies: YsterbaardCompany[];
recentDirectors: YsterbaardDirector[];
searchIndex: OverviewSearchItem[];
}
export default function Dashboard({
kpis,
statusDistribution,
recentCompanies,
recentDirectors,
searchIndex,
}: DashboardProps) {
const totalStatuses = statusDistribution.reduce(
(sum, b) => sum + b.count,
0
);
return (
<>
{/* ───── 0. Global tax / CK number search ─────────────────────── */}
{/* ───── 1. KPI strip ─────────────────────────────────────────── */}
{/* ───── 2. Status distribution ───────────────────────────────── */}