import { redirect } from "next/navigation"

import prisma from "@/lib/prisma"

export default async function EditUserPage({
  params,
}: {
  params: Promise<{ userId: string }>
}) {
  const { userId } = await params

  const person = await prisma.person.findFirst({
    where: { userId },
    select: { id: true },
  })

  if (!person) {
    redirect("/people")
  }

  redirect(`/people/${person.id}/edit`)
}
