This repository has been archived on 2025-07-07. You can view files and clone it, but cannot push or open issues or pull requests.
Files
eternos/frontend/style/app/product/[id]/page.tsx
2025-02-22 20:12:27 +03:00

42 lines
863 B
TypeScript

import { notFound } from "next/navigation"
import { ProductDetail } from "@/components/product-detail"
async function getProduct(id: string) {
try {
const response = await fetch(`http://localhost:8080/product/${id}`, {
cache: "no-store",
})
if (!response.ok) {
if (response.status === 404) {
return null
}
throw new Error("Failed to fetch product")
}
return response.json()
} catch (error) {
console.error("Error fetching product:", error)
return null
}
}
interface ProductPageProps {
params: { id: string }
}
export default async function ProductPage({ params }: ProductPageProps) {
const product = await getProduct(params.id)
if (!product) {
notFound()
}
return (
<div className="container mx-auto px-4 py-8">
<ProductDetail product={product} />
</div>
)
}