// "Create person" page (T-504).
//
// Only covers createPerson()'s actual shipped fields (displayName, gender?,
// lifeStatus?) — see src/modules/genealogy/createPerson.ts. Everything else
// (birth date w/ precision, residence, contact) is added afterwards on the
// person's edit page, so this form redirects straight there on success
// rather than trying to be a one-shot wizard.
import { redirect } from "next/navigation";
import { getCallerMembership } from "@/lib/get-caller-membership";
import PersonCreateForm from "./person-create-form";

export default async function NewPersonPage({
  params,
}: {
  params: Promise<{ trahId: string }>;
}) {
  const { trahId } = await params;

  const caller = await getCallerMembership(trahId);
  if (!caller) {
    redirect("/login");
  }

  return (
    <main style={{ maxWidth: 480, margin: "0 auto", padding: "2rem 1rem" }}>
      <h1>Add a person</h1>
      <PersonCreateForm trahId={trahId} />
    </main>
  );
}
