feat: add option to view product certificate

This commit is contained in:
2025-04-12 18:23:10 +05:30
parent 9a893b908e
commit c00055f466
2 changed files with 64 additions and 3 deletions

View File

@@ -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 (
<div className="flex flex-col md:flex-row gap-4 p-4 sm:w-[70%] ">
@@ -44,7 +46,15 @@ const ProductGallery = ({ productId }) => {
))}
</div>
<div className="flex-grow h-full">
<Card className="p-4 h-[380px] sm:h-[80vh]">
<Card className="p-4 h-[380px] sm:h-[80vh] relative">
{/* Certificate Badge */}
{hasCertificate && (
<div className="absolute top-2 right-2 z-10 bg-green-100 text-green-800 px-2 py-1 rounded-md flex items-center text-xs font-medium">
<Award className="w-3 h-3 mr-1" />
Certified
</div>
)}
{/* Main image with carousel controls */}
<div className="relative mb-4 h-full">
<Image
@@ -81,6 +91,11 @@ const ProductGallery = ({ productId }) => {
<h3 className="p-1 px-2 rounded-3xl border text-xs border-yellow-700">
Expert Rating
</h3>
{hasCertificate && (
<h3 className="p-1 px-2 rounded-3xl border text-xs border-green-700 bg-green-50">
Certificate Available
</h3>
)}
</div>
<h2 className="mt-3">Note: Free Shipping on order above $ 300</h2>
<h2 className="my-1">100% Secured Payment</h2>