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

export const metadata = {
  title: 'Kategori Düzenle - Admin',
}

export default async function EditCategoryPage({ params }: { params: Promise<{ id: string }> }) {
  const resolvedParams = await params
  const id = parseInt(resolvedParams.id, 10)

  if (isNaN(id)) {
    notFound()
  }

  const category = await prisma.categories.findUnique({
    where: { id }
  })

  if (!category) {
    notFound()
  }

  return (
    <div className="space-y-6">
      <h1 className="text-2xl font-bold text-gray-900">Kategori Düzenle</h1>
      
      <div className="bg-white p-6 rounded-xl shadow-sm border border-gray-100 max-w-2xl">
        <CategoryForm category={category} />
      </div>
    </div>
  )
}
