import { db } from "@/lib/db";
import { products } from "@/lib/db/schema";
import { eq } from "drizzle-orm";
import ProductForm from "@/components/admin/ProductForm";
import { notFound } from "next/navigation";

export const dynamic = "force-dynamic";

export default async function EditProductPage({ params }: { params: Promise<{ id: string }> }) {
  const { id } = await params;
  const product = (await db.select().from(products).where(eq(products.id, id)))[0];
  if (!product) return notFound();

  return (
    <div>
      <h2 className="text-lg font-semibold mb-4">Edit Product</h2>
      <ProductForm initial={product} productId={id} />
    </div>
  );
}
