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

export default async function Home() {
  const projects = await prisma.project.findMany({
    orderBy: { createdAt: 'desc' },
    take: 10 // Limit for the slider
  })

  // Serialize projects for the client
  const serializedProjects = projects.map(p => ({
    ...p,
    createdAt: p.createdAt.toISOString(),
    updatedAt: p.updatedAt.toISOString(),
  }))

  return <HomePageClient initialProjects={serializedProjects} />
}
