import React from 'react'; import { Product, ProductVariant } from './ProductDetail.tsx'; import { Button } from '../ui/button'; import { RiSubtractLine, RiAddLine, RiTruckLine, RiArrowGoBackLine, RiSecurePaymentLine, RiLoader4Line, } from '@remixicon/react'; interface ProductDetailInfoProps { product: Product; selectedVariant: ProductVariant | null; selectedOptions: Record; quantity: number; setQuantity: (quantity: number) => void; handleAddToCart: () => void; onOptionChange: (optionName: string, value: string) => void; isAddingToCart?: boolean; } const ProductDetailInfo: React.FC = ({ product, selectedVariant, selectedOptions, quantity, setQuantity, handleAddToCart, onOptionChange, isAddingToCart = false }) => { const formatPrice = (price: { amount: string; currencyCode: string }) => { return new Intl.NumberFormat('en-US', { style: 'currency', currency: 'USD', }).format(parseFloat(price.amount)); }; const price = selectedVariant?.price || product.priceRange.minVariantPrice; const compareAtPrice = product.compareAtPriceRange?.minVariantPrice; const hasDiscount = compareAtPrice && parseFloat(compareAtPrice.amount) > parseFloat(price.amount); return (

{product.title}

{/* Price */}
{formatPrice(price)} {hasDiscount && compareAtPrice && ( <> {formatPrice(compareAtPrice)}
{Math.round(((parseFloat(compareAtPrice.amount) - parseFloat(price.amount)) / parseFloat(compareAtPrice.amount)) * 100)}% OFF
)}
{/* Description */} {product.description && (
{product.descriptionHtml ? (
) : (

{product.description}

)}
)} {/* Product Options */} {product.options .filter(option => option.name !== 'Title') .map(option => (
{option.values.map(value => ( ))}
))} {/* Quantity Selector */}
{quantity}
{/* Add to Cart Button */} {/* Additional Info */}
Free shipping on orders over $100
30-day return policy
Secure payment
); }; export default ProductDetailInfo;