From 4eb498280add01ca810136cdf2d8d2550e1ca937 Mon Sep 17 00:00:00 2001 From: bender Date: Thu, 12 Mar 2026 06:25:32 +0000 Subject: [PATCH] Update src/app/product/[id]/page.tsx --- src/app/product/[id]/page.tsx | 330 ++++++++++++++++++++-------------- 1 file changed, 191 insertions(+), 139 deletions(-) diff --git a/src/app/product/[id]/page.tsx b/src/app/product/[id]/page.tsx index 7946d79..d25539c 100644 --- a/src/app/product/[id]/page.tsx +++ b/src/app/product/[id]/page.tsx @@ -3,9 +3,10 @@ import { ThemeProvider } from "@/providers/themeProvider/ThemeProvider"; import NavbarStyleCentered from "@/components/navbar/NavbarStyleCentered/NavbarStyleCentered"; import FooterCard from "@/components/sections/footer/FooterCard"; -import { Instagram, Twitter, Youtube, ShoppingCart, Heart } from "lucide-react"; +import { Instagram, Twitter, Youtube, Heart, Share2, ShoppingCart } from "lucide-react"; import Link from "next/link"; import { useState } from "react"; +import { useParams } from "next/navigation"; const TikTok = (props: React.SVGProps) => ( ) => ( ); -interface PageProps { - params: { id: string }; -} +const products: Record< + string, + { + id: string; + name: string; + price: number; + imageSrc: string; + imageAlt: string; + description: string; + sizes: string[]; + colors: string[]; + specs: { label: string; value: string }[]; + } +> = { + "1": { + id: "1", name: "Classic Black Hoodie", price: 89.99, + imageSrc: "http://img.b2bpic.net/free-photo/medium-shot-man-posing-with-hoodie-indoors_23-2149359859.jpg", imageAlt: "Classic black oversized hoodie", description: + "Premium comfort meets timeless style with our Classic Black Hoodie. Crafted from 100% organic cotton, this essential piece features a relaxed fit perfect for everyday wear. The durable construction ensures it'll be a staple in your wardrobe for years to come.", sizes: ["XS", "S", "M", "L", "XL", "XXL"], + colors: ["Black", "Gray", "Navy"], + specs: [ + { label: "Material", value: "100% Organic Cotton" }, + { label: "Weight", value: "280g" }, + { label: "Care", value: "Machine wash cold" }, + { label: "Fit", value: "Relaxed" }, + ], + }, + "2": { + id: "2", name: "Vintage Denim Jacket", price: 129.99, + imageSrc: "http://img.b2bpic.net/free-photo/fashionable-woman-wearing-denim-jacket_23-2148859621.jpg", imageAlt: "Vintage style denim jacket", description: + "Elevate your streetwear game with our Vintage Denim Jacket. Featuring authentic distressing and premium indigo denim, this jacket adds instant character to any outfit. Perfect for layering or wearing standalone.", sizes: ["XS", "S", "M", "L", "XL"], + colors: ["Indigo", "Light Blue", "Black"], + specs: [ + { label: "Material", value: "100% Cotton Denim" }, + { label: "Weight", value: "650g" }, + { label: "Care", value: "Wash separately" }, + { label: "Fit", value: "Classic" }, + ], + }, +}; + +export default function ProductPage() { + const params = useParams(); + const productId = params.id as string; + const product = products[productId]; + + const [selectedSize, setSelectedSize] = useState(product?.sizes[2] || ""); + const [selectedColor, setSelectedColor] = useState(product?.colors[0] || ""); + const [quantity, setQuantity] = useState(1); + const [isFavorited, setIsFavorited] = useState(false); -export default function ProductDetailPage({ params }: PageProps) { const navItems = [ { name: "Shop", id: "products" }, { name: "Collections", id: "collections" }, @@ -33,32 +79,6 @@ export default function ProductDetailPage({ params }: PageProps) { { name: "Contact", id: "contact" }, ]; - const [quantity, setQuantity] = useState(1); - const [selectedSize, setSelectedSize] = useState("M"); - const [selectedColor, setSelectedColor] = useState("Black"); - const [isFavorited, setIsFavorited] = useState(false); - - const productId = params.id; - - const products: Record = { - "1": { - id: "1", name: "Classic Black Hoodie", price: 89.99, - description: "Experience ultimate comfort with our signature Classic Black Hoodie. Crafted from premium cotton blend, this versatile piece is perfect for any casual occasion. Features a spacious front pocket and adjustable drawstrings.", imageSrc: "http://img.b2bpic.net/free-photo/medium-shot-man-posing-with-hoodie-indoors_23-2149359859.jpg", sizes: ["XS", "S", "M", "L", "XL", "XXL"], - colors: ["Black", "Navy", "Charcoal"], - rating: 4.8, - reviews: 156, - }, - "2": { - id: "2", name: "Vintage Denim Jacket", price: 129.99, - description: "Make a statement with our Vintage Denim Jacket. This timeless piece features authentic fading and distressing for that perfect worn-in look. Premium quality denim with reinforced stitching ensures durability.", imageSrc: "http://img.b2bpic.net/free-photo/fashionable-woman-wearing-denim-jacket_23-2148859621.jpg", sizes: ["XS", "S", "M", "L", "XL"], - colors: ["Indigo", "Light Blue", "Black"], - rating: 4.9, - reviews: 203, - }, - }; - - const product = products[productId] || products["1"]; - const socialLinks = [ { icon: Instagram, href: "https://instagram.com/umbra", ariaLabel: "Instagram" }, { icon: Twitter, href: "https://twitter.com/umbra", ariaLabel: "Twitter" }, @@ -66,6 +86,48 @@ export default function ProductDetailPage({ params }: PageProps) { { icon: Youtube, href: "https://youtube.com/@umbra", ariaLabel: "YouTube" }, ]; + if (!product) { + return ( + + + +
+
+

Product Not Found

+ + Return to Shop + +
+
+ + +
+ ); + } + return ( -
-
-
- - ← Back to Shop - +
+
+ + ← Back to Shop + -
- {/* Product Image */} -
- {product.name} +
+
+ {product.imageAlt} +
+ +
+

{product.name}

+

+ ${product.price.toFixed(2)} +

+

{product.description}

+ +
+ +
+ {product.sizes.map((size) => ( + + ))} +
- {/* Product Details */} -
-
-

{product.name}

-
- {product.rating}★ - ({product.reviews} reviews) -
+
+ +
+ {product.colors.map((color) => ( + + ))}
+
-
- ${product.price.toFixed(2)} -
- -

{product.description}

- - {/* Size Selection */} -
- -
- {product.sizes.map((size: string) => ( - - ))} -
-
- - {/* Color Selection */} -
- -
- {product.colors.map((color: string) => ( - - ))} -
-
- - {/* Quantity Selection */} -
- -
-
- - {quantity} - -
-
-
- - {/* Action Buttons */} -
- +
+ +
+ {quantity} +
+
- {/* Product Info */} -
-

✓ Free shipping on orders over $150

-

✓ 30-day return policy

-

✓ Premium quality guaranteed

+
+ + + +
+ +
+

Product Details

+
+ {product.specs.map((spec, idx) => ( +
+ {spec.label}: + {spec.value} +
+ ))}
-- 2.49.1