diff --git a/src/app/(storefront)/products/[handle]/ProductDetails.tsx b/src/app/(storefront)/products/[handle]/ProductDetails.tsx
index 6c04f3a..fceb6cb 100644
--- a/src/app/(storefront)/products/[handle]/ProductDetails.tsx
+++ b/src/app/(storefront)/products/[handle]/ProductDetails.tsx
@@ -1,9 +1,9 @@
'use client';
import { HttpTypes } from '@medusajs/types';
-import { ShoppingCart, Star } from 'lucide-react';
+import { ShoppingCart } from 'lucide-react';
import Image from 'next/image';
-import { useState } from 'react';
+import { useEffect, useState } from 'react';
import { Button } from '@/components/ui/button';
import { Card, CardContent } from '@/components/ui/card';
@@ -21,6 +21,10 @@ export default function ProductDetails({ product }: ProductDetailsProps) {
const { addToCart } = useCart();
+ useEffect(() => {
+ setSelectedVariant(product.variants?.[0] as HttpTypes.StoreProductVariant);
+ }, [product]);
+
return (
@@ -46,40 +50,42 @@ export default function ProductDetails({ product }: ProductDetailsProps) {
*/}
-
{product.title}
-
-
- {[...Array(5)].map((_, i) => (
-
+
{product.title} {' '}
+
{product.subtitle}
+ {product.tags && product.tags.length > 0 && (
+
+ {product.tags.map((tag) => (
+
+ {tag.value}
+
))}
-
(128 reviews)
-
-
₹{selectedVariant?.calculated_price?.calculated_amount?.toFixed(2)}
+ )}
+
₹{selectedVariant?.calculated_price?.calculated_amount?.toFixed(2)}
{product.description}
-
-
-
Choose Variant:
-
- setSelectedVariant(
- product.variants?.find((v) => v.id === value) ||
- (product.variants?.[0] as HttpTypes.StoreProductVariant),
- )
- }
- >
- {product.variants?.map((variant) => (
-
-
-
- {variant.title} - ₹{variant.calculated_price?.calculated_amount?.toFixed(2)}
-
-
- ))}
-
-
-
+ {product.variants && product.variants.length > 1 && (
+
+
Variants:
+
+ setSelectedVariant(
+ product.variants?.find((v) => v.id === value) ||
+ (product.variants?.[0] as HttpTypes.StoreProductVariant),
+ )
+ }
+ >
+ {product.variants?.map((variant) => (
+
+
+
+ {variant.title} - ₹{variant.calculated_price?.calculated_amount?.toFixed(2)}
+
+
+ ))}
+
+
+ )}
setQuantity(Math.max(1, quantity - 1))}>
-
@@ -92,42 +98,24 @@ export default function ProductDetails({ product }: ProductDetailsProps) {
addToCart(selectedVariant?.id as string, quantity)}>
Add to Cart
-
- Product Details
-
- Single-origin cocoa beans from Ecuador
- Fair trade certified
+ {product.material && (
+
+
Ingredients
+
+ {product.material}
+
+
+
+ )}
+ Product Details
+
+ Single-origin cocoa beans
No artificial flavors or preservatives
- 100g (3.5oz) bar
Available in different cocoa percentages
-
-
Customer Reviews
-
- {[...Array(3)].map((_, i) => (
-
-
-
-
- {[...Array(5)].map((_, j) => (
-
- ))}
-
-
John Doe
-
-
- This chocolate is absolutely divine! The rich flavor and smooth texture make it a perfect treat for
- any chocolate lover. I especially love the 85% cocoa variant for its intense flavor.
-
-
-
- ))}
-
-
-
Related Products
@@ -143,7 +131,7 @@ export default function ProductDetails({ product }: ProductDetailsProps) {
/>
Milk Chocolate Truffles
Smooth, creamy milk chocolate truffles
-
$9.99
+
₹{selectedVariant?.calculated_price?.calculated_amount?.toFixed(2)}
))}