interface PriceDisplayProps { price: number; currency?: string; originalPrice?: number; size?: 'sm' | 'md' | 'lg' | 'xl'; showCurrency?: boolean; } const sizeClasses = { sm: 'text-sm', md: 'text-lg', lg: 'text-2xl', xl: 'text-4xl', }; export function PriceDisplay({ price, currency = 'USD', originalPrice, size = 'md', showCurrency = false, }: PriceDisplayProps) { const hasDiscount = originalPrice && originalPrice > price; const discountPercentage = hasDiscount ? Math.round((1 - price / originalPrice) * 100) : 0; const formatPrice = (value: number) => { return new Intl.NumberFormat('en-US', { style: 'currency', currency: currency, minimumFractionDigits: 2, maximumFractionDigits: 2, }).format(value); }; return (
{formatPrice(price)} {showCurrency && ( {currency} )} {hasDiscount && ( <> {formatPrice(originalPrice)} {discountPercentage}% OFF )}
); } interface PriceRangeDisplayProps { minPrice: number; maxPrice: number; currency?: string; } export function PriceRangeDisplay({ minPrice, maxPrice, currency = 'USD', }: PriceRangeDisplayProps) { const formatPrice = (value: number) => { return new Intl.NumberFormat('en-US', { style: 'currency', currency: currency, minimumFractionDigits: 0, maximumFractionDigits: 0, }).format(value); }; if (minPrice === maxPrice) { return ( {formatPrice(minPrice)} ); } return ( {formatPrice(minPrice)} - {formatPrice(maxPrice)} ); } export default PriceDisplay;