diff --git a/app/products/[id]/page.tsx b/app/products/[id]/page.tsx index 876bc6f..546f306 100644 --- a/app/products/[id]/page.tsx +++ b/app/products/[id]/page.tsx @@ -1,7 +1,212 @@ -import React from "react"; +import { getProductById, getSimilarProducts } from "@/lib/actions"; +import { redirect } from "next/navigation"; +import Image from "next/image"; +import Link from "next/link"; +import { Product } from "@/types"; +import { formatNumber } from "@/lib/utils"; +import PriceInfoCard from "@/components/PriceInfoCard"; +import ProductCard from "@/components/ProductCard"; +import Modal from "@/components/Modal"; -const ProductDetails = () => { - return
ProductDetails
; +type Props = { + params: { id: string }; +}; + +const ProductDetails = async ({ params: { id } }: Props) => { + const product: Product = await getProductById(id); + + if (!product) redirect("/"); + + const similarProducts = await getSimilarProducts(id); + return ( +
+
+
+ {product.title} +
+ +
+
+
+

+ {product.title} +

+ + Visit Product + +
+ +
+
+ heart + +

+ {product.reviewsCount} +

+
+ +
+ bookmark +
+ +
+ share +
+
+
+ + {/* Product Price */} + +
+
+

+ {product.currency} {formatNumber(product.currentPrice)} +

+

+ {product.currency} {formatNumber(product.originalPrice)} +

+
+ + {/* Product Stars */} + +
+
+
+ star +

+ {product.stars || "25"} +

+
+ + {/* Product Reviews */} +
+ comment +

+ {product.reviewsCount} Reviews +

+
+
+ +

+ 93% of + buyers have recommended this. +

+
+
+ + {/* Product Info Cards */} +
+
+ + + + +
+
+ + +
+
+ + {/* Product Description */} +
+
+

+ Product Description +

+ +
+ {product?.description?.split("\n")} +
+
+ + {/* Track Button */} + +
+ + {similarProducts && similarProducts?.length > 0 && ( +
+

Similar Products

+ +
+ {similarProducts.map((product) => ( + + ))} +
+
+ )} +
+ ); }; export default ProductDetails;