import ProductDetailPage from '@/components/ProductPage';
import { getProductById } from '@/lib/products';

// Generate dynamic metadata for the product page
export async function generateMetadata({ params }) {
  const { id } = await params;
  const product = await getProductById(id);

  return {
    title: `${product?.name} | Medication`,
    description: `${product?.name} kopen met iDEAL & Bancontact`,
    openGraph: {
      title: product?.name,
      description: `${product?.name} kopen met iDEAL & Bancontact`,
      images: [product?.image],
    },
    twitter: {
      card: 'summary_large_image',
      title: product?.name,
      description: `${product?.name} kopen met iDEAL & Bancontact`,
      images: [product?.image],
    },
  };
}

// Default page component that renders the product
export default async function ProductPageWrapper({ params }) {
  const { id } = await params;
  const product = await getProductById(id);

  return <ProductDetailPage product={product} />;
}
