import { prisma } from '@/lib/prisma'
import ProjectsPageClient from './ProjectsPageClient'

export default async function ProjectsPage() {
  const projects = await prisma.project.findMany({
    orderBy: { createdAt: 'desc' }
  })

  // Normalize data for client (Prisma returns Dates, Client expects standard objects if needed)
  const serializedProjects = projects.map(p => ({
    ...p,
    createdAt: p.createdAt.toISOString(),
    updatedAt: p.updatedAt.toISOString(),
  }))

  return <ProjectsPageClient initialProjects={serializedProjects} />
}
