import { createClient } from "@/lib/supabase-server"
import { ProductForm } from "@/components/dashboard/product-form"
import { notFound } from "next/navigation"

interface ProductEditPageProps {
    params: {
        productId: string
    }
}

export default async function ProductEditPage({ params }: ProductEditPageProps) {
    const supabase = createClient()
    const { data: product } = await supabase
        .from("products")
        .select("*")
        .eq("id", params.productId)
        .single()

    if (!product) {
        notFound()
    }

    return (
        <div className="flex-1 space-y-4 p-8 pt-6">
            <div className="flex items-center justify-between">
                <h2 className="text-3xl font-bold tracking-tight">Ürün Düzenle</h2>
            </div>
            <div className="max-w-2xl">
                <ProductForm initialData={product} />
            </div>
        </div>
    )
}
