import { notFound } from "next/navigation";
import { ProductForm } from "@/components/admin/ProductForm";
import { saveProductAction } from "@/app/admin/actions";
import { getAdminProductsData } from "@/lib/admin-data";

export default async function EditProductPage({
  params,
}: {
  params: Promise<{ id: string }>;
}) {
  const { id } = await params;
  const { scooters, brands } = await getAdminProductsData();
  const product = scooters.find((scooter: any) => scooter.id === id);

  if (!product) {
    notFound();
  }

  return (
    <div className="space-y-5">
      <h1 className="text-2xl font-bold text-navy-deep">Edit Product</h1>
      <ProductForm brands={brands} initialProduct={product as any} onSave={saveProductAction} />
    </div>
  );
}
