import { prisma } from '@/lib/prisma'
import { notFound } from 'next/navigation'
import ProjectDetailClient from './ProjectDetailClient'

interface Props {
  params: Promise<{ slug: string }>
}

export default async function ProjectDetailPage({ params }: Props) {
  const { slug } = await params
  
  const project = await prisma.project.findUnique({
    where: { slug }
  })

  if (!project) {
    notFound()
  }

  // Serialize dates and gallery
  const serializedProject = {
    ...project,
    createdAt: project.createdAt.toISOString(),
    updatedAt: project.updatedAt.toISOString(),
  }

  return <ProjectDetailClient project={serializedProject} />
}
