"use client"; import { ArrowIcon } from "@/app/utils/svgs/arrowIcon"; import { FeatureTag } from "@/app/utils/svgs/featureTag"; import { getFullImageUrl } from "@/app/utils/functions"; import Image from "next/image"; import Link from "next/link"; import PrimaryButton from "./primaryButton"; import React, { useState } from "react"; export interface ProductCardProps { id: string; name: string; image: string; href: string; price: number; category_id: string; category: string; discount?: number | null; isFeatured?: boolean; onSale: boolean; skus?: Array | string; } export const ProductCard = ({ id, name, image, href, price, category, discount, isFeatured = false, onSale, skus, }: ProductCardProps) => { const [loaded, setLoaded] = useState(false); const hasDiscount = discount != null && discount > 0; const priceValue = hasDiscount ? price + discount : price; const fallbackImage = "/no-image-avail-large.png"; // Ensure image URL has full S3 path if it's relative const fullImageUrl = getFullImageUrl(image) || fallbackImage; return ( {/* Featured badge */} {isFeatured && ( {FeatureTag} )} {/* On sale pill */} {onSale && ( )}
{/* Image area with skeleton */}
{!loaded && (

{category}

{name}

{skus && (

PART #:{" "} {Array.isArray(skus) ? skus[0] : skus || "N/A"}

)}
); };