import { notFound } from 'next/navigation';
import { ContactDetailBoard } from '../../../../components/contact-detail-board';
import { DashboardShell } from '../../../../components/dashboard-shell';
import { requireAuthToken } from '../../../../lib/auth';
import { fetchContactDetail } from '../../../../lib/api';

export default async function ContactDetailPage({ params }: { params: Promise<{ id: string }> }) {
  const token = await requireAuthToken();
  const { id } = await params;

  let detail;
  try {
    detail = await fetchContactDetail(token, id);
  } catch {
    notFound();
  }

  return (
    <DashboardShell currentPath="/dashboard/contacts">
      <ContactDetailBoard contact={detail.contact} />
    </DashboardShell>
  );
}
