'use client' import { Plus, Minus, Eye, Heart, ShoppingCart } from 'lucide-react' import React from 'react' import { Badge } from '@/components/ui/badge' import { Button } from '@/components/ui/button' import { Card } from '@/components/ui/card' import { WholesalerProduct } from './types' interface ProductCardProps { product: WholesalerProduct selectedQuantity: number onQuantityChange: (quantity: number) => void formatCurrency: (amount: number) => string } export function ProductCard({ product, selectedQuantity, onQuantityChange, formatCurrency }: ProductCardProps) { const discountedPrice = product.discount ? product.price * (1 - product.discount / 100) : product.price const handleQuantityChange = (newQuantity: number) => { const clampedQuantity = Math.max(0, Math.min(product.quantity, newQuantity)) onQuantityChange(clampedQuantity) } return (
{product.name} {/* Количество в наличии */}
50 ? 'bg-green-500/80' : product.quantity > 10 ? 'bg-yellow-500/80' : 'bg-red-500/80' } text-white border-0 backdrop-blur text-xs`} > {product.quantity}
{/* Скидка */} {product.discount && (
-{product.discount}%
)} {/* Overlay с кнопками */}
{/* Заголовок и бренд */}
{product.brand && ( {product.brand} )}
{product.isNew && ( NEW )} {product.isBestseller && ( HIT )}

{product.name}

{/* Основная характеристика */}
{product.color && {product.color}} {product.size && {product.size}}
{/* Цена */}
{formatCurrency(discountedPrice)}
{product.discount && (
{formatCurrency(product.price)}
)}
{/* Управление количеством */}
{ const value = e.target.value.replace(/[^0-9]/g, '') const numValue = parseInt(value) || 0 handleQuantityChange(numValue) }} onFocus={(e) => e.target.select()} className="h-8 w-12 text-center bg-white/10 border border-white/20 text-white text-sm rounded focus:outline-none focus:ring-2 focus:ring-blue-500 focus:border-transparent [appearance:textfield] [&::-webkit-outer-spin-button]:appearance-none [&::-webkit-inner-spin-button]:appearance-none" /> {selectedQuantity > 0 && ( {selectedQuantity} )}
{/* Сумма для выбранного товара */} {selectedQuantity > 0 && (
{formatCurrency(discountedPrice * selectedQuantity)}
)}
) }