import { RoomForm } from '@/components/admin/RoomForm'
import { ArrowLeft } from 'lucide-react'
import Link from 'next/link'
import { db } from '@/lib/db'
import { notFound } from 'next/navigation'

export default async function EditRoomPage({ params }: { params: Promise<{ id: string }> }) {
  const { id } = await params
  const room = await db.room.findUnique({
    where: { id }
  })

  if (!room) {
    notFound()
  }

  return (
    <div className="space-y-6">
      <div className="flex items-center space-x-4">
        <Link href="/admin/rooms" className="text-gray-500 hover:text-gray-900 dark:hover:text-white transition-colors">
          <ArrowLeft className="h-6 w-6" />
        </Link>
        <div>
          <h2 className="text-2xl font-bold tracking-tight text-gray-900 dark:text-white">Odayı Düzenle</h2>
          <p className="text-gray-500 dark:text-gray-400 mt-2">
            Oda bilgilerini güncellemek için aşağıdaki formu kullanın.
          </p>
        </div>
      </div>

      <RoomForm initialData={room} />
    </div>
  )
}
