diff --git a/components/products/AddToCardLeftSection.jsx b/components/products/AddToCardLeftSection.jsx index 35bbbf4..64f114a 100644 --- a/components/products/AddToCardLeftSection.jsx +++ b/components/products/AddToCardLeftSection.jsx @@ -2,7 +2,7 @@ import React, { useContext, useState } from "react"; import { Button } from "@/components/ui/button"; import { Card } from "@/components/ui/card"; -import { ChevronLeft, ChevronRight } from "lucide-react"; +import { ChevronLeft, ChevronRight, Award } from "lucide-react"; // Added Award icon import ProductContext from "@/app/contexts/productContext"; import { backendUrl } from "@/utils/axios"; import Image from "next/image"; @@ -26,7 +26,9 @@ const ProductGallery = ({ productId }) => { if (!product) { return null; } + const productImages = product?.images?.map((img) => img.image) || []; + const hasCertificate = product.certificate && product.certificate !== "NA"; return (
@@ -44,7 +46,15 @@ const ProductGallery = ({ productId }) => { ))}
- + + {/* Certificate Badge */} + {hasCertificate && ( +
+ + Certified +
+ )} + {/* Main image with carousel controls */}
{

Expert Rating

+ {hasCertificate && ( +

+ Certificate Available +

+ )}

Note: Free Shipping on order above $ 300

100% Secured Payment

diff --git a/components/products/AddToCardRightSection.jsx b/components/products/AddToCardRightSection.jsx index d82f5c4..d0e3023 100644 --- a/components/products/AddToCardRightSection.jsx +++ b/components/products/AddToCardRightSection.jsx @@ -1,6 +1,6 @@ "use client"; import React, { useContext, useState } from "react"; -import { Plus, Minus } from "lucide-react"; +import { Plus, Minus, FileText } from "lucide-react"; // Added FileText icon import ProductContext from "@/app/contexts/productContext"; import { backendUrl } from "@/utils/axios"; import { useCurrency } from "@/app/contexts/currencyContext"; @@ -12,6 +12,7 @@ function ProductDetails({ productId }) { const [selectedSize, setSelectedSize] = useState(null); const [selectedDesign, setSelectedDesign] = useState(null); const [termsAccepted, setTermsAccepted] = useState(false); + const [showCertificate, setShowCertificate] = useState(false); const { products, cartFn } = useContext(ProductContext); const { formatPrice, isLoading } = useCurrency(); @@ -27,6 +28,7 @@ function ProductDetails({ productId }) { const hasVariants = product.variants?.length > 0; const hasDesigns = product.design_associations?.length > 0; + const hasCertificate = product.certificate && product.certificate !== "NA"; const selectedVariant = hasVariants ? product.variants.find((v) => v.size.size_name === selectedSize) @@ -39,6 +41,15 @@ function ProductDetails({ productId }) { : 0; const totalPrice = currentPrice + designPrice; + + const handleViewCertificate = () => { + setShowCertificate(true); + // If it's a PDF, open in a new tab + if (product.certificate.toLowerCase().endsWith('.pdf')) { + window.open(`${backendUrl}${product.certificate}`, '_blank'); + setShowCertificate(false); + } + }; return (
@@ -133,6 +144,18 @@ function ProductDetails({ productId }) { )}
+ {hasCertificate && ( +
+ +
+ )} + {hasVariants && ( <>
@@ -200,6 +223,29 @@ function ProductDetails({ productId }) { />
+ + {showCertificate && !product.certificate.toLowerCase().endsWith('.pdf') && ( +
+
+
+

Product Certificate

+ +
+
+ Product Certificate +
+
+
+ )} ); }