import { getProductById } from '@/feactures/inventory/actions/actions';
import {ProductList} from '@/feactures/inventory/components/products/see-product'

export default async function SurveyResponsePage({
  params,
}: {
  params: Promise<{ id: string }>
}) {
  const { id } = await params; // You can still destructure id from params

  if (!id || id === '') return null;
  
  // Call the function passing the dynamic id
  const data = await getProductById(Number(id));

  if (!data?.data) {
    return (
      <main className='flex h-full flex-col items-center justify-center'>
        <p className='text-2xl'>Lo siento...</p>
        <p className='text-4xl text-primary'>Producto no encontrado</p>
      </main>
    )
  }
  
  return (
    <ProductList product={data.data} />
  );
}