import { ProjectForm } from "@/features/projects/project-form";
import { verifySession } from "@/core/security/session";
import { redirect } from "@/i18n/routing";
import { getLocale } from "next-intl/server";
import { prisma } from "@/core/db/prisma";
import { notFound } from "next/navigation";

export default async function EditProjectPage({ 
  params 
}: { 
  params: Promise<{ id: string }> 
}) {
  const session = await verifySession();
  const locale = await getLocale();

  if (!session) {
    redirect({ href: "/admin/login", locale });
  }
  
  const { id } = await params;

  const project = await prisma.project.findUnique({
    where: { id }
  });

  if (!project) return notFound();

  return (
    <div className="min-h-screen bg-muted/10 px-6 py-12">
      <ProjectForm initialData={project} projectId={project.id} />
    </div>
  );
}
