import { notFound } from "next/navigation";
import { db } from "@/lib/db";
import { AdminPageHeader } from "@/components/admin/page-header";
import { TeamForm, TeamFormValues } from "@/components/admin/team-form";

export const dynamic = "force-dynamic";

export default async function EditTeamMemberPage({ params }: { params: Promise<{ id: string }> }) {
  const { id } = await params;
  const m = await db.teamMember.findUnique({ where: { id } });
  if (!m) notFound();

  const initial: TeamFormValues = {
    id: m.id,
    name: m.name,
    position: m.position,
    bio: m.bio || "",
    image: m.image,
    order: m.order,
    isEnabled: m.isEnabled,
  };

  return (
    <>
      <AdminPageHeader title="Edit Team Member" description={m.name} />
      <TeamForm initial={initial} />
    </>
  );
}
