'use client'; import Link from 'next/link'; import Image from 'next/image'; import { ShoppingCart, GitCompare, Phone, Check } from 'lucide-react'; import { Product } from '@/content/products'; import { useCartStore } from '@/lib/cart-store'; import { useCompareStore } from '@/lib/compare-store'; import { useState } from 'react'; const brandLogos: Record = { 'Gree': '/brands/gree.webp', 'Rotenso': '/brands/rotenso.png', 'Toshiba': '/brands/toshiba.jpg', 'Daikin': '/brands/daikin.png', 'CHV': '/brands/chv.jpeg', 'Haier': '/brands/haier.jpg', 'Aux': '/brands/aux.png', 'LG': '/brands/lg.png', 'Samsung': '/brands/samsung.png', 'Mitsubishi Electric': '/brands/mitsubishi-electric.png', 'Fuji Electric': '/brands/fuji-electric.png', }; interface ProductCardProps { product: Product; } export function ProductCard({ product }: ProductCardProps) { const addItem = useCartStore((s) => s.addItem); const { addItem: addCompare, removeItem: removeCompare, isAdded, items: compareItems } = useCompareStore(); const [added, setAdded] = useState(false); const handleAddToCart = (e: React.MouseEvent) => { e.preventDefault(); if (!product.price) return; addItem({ slug: product.slug, name: product.name, brand: product.brand, image: product.image, price: product.price, }); setAdded(true); }; const handleCompare = (e: React.MouseEvent) => { e.preventDefault(); if (isAdded(product.slug)) { removeCompare(product.slug); } else { addCompare({ slug: product.slug, name: product.name, brand: product.brand, price: product.price, image: product.image, specs: product.specs, }); } }; const inCompare = isAdded(product.slug); const compareDisabled = compareItems.length >= 3 && !inCompare; return (
{/* Zdjęcie */} {product.name} {/* Brand Logo or Name */}
{brandLogos[product.brand] ? (
{product.brand}
) : ( {product.brand} )}
{/* Badge multisplit */} {product.category === 'multisplit' && ( Multisplit )} {/* Porównywarka - pojawia się na hover */} {/* Treść */}

{product.name}

{/* Kluczowe specs */}
{product.specs['Moc chłodnicza'] && ( {product.specs['Moc chłodnicza']} kW )} {product.specs['Klasa energetyczna'] && ( {product.specs['Klasa energetyczna']} )} {product.specs['Czynnik chłodniczy'] && ( {product.specs['Czynnik chłodniczy']} )}
{/* Cena + CTA */}
{product.price !== null ? (

{product.price.toLocaleString('pl-PL')} zł

brutto

) : (
Zapytaj o cenę
)} {product.price !== null ? ( added ? ( e.stopPropagation()} > Zobacz koszyk ) : ( ) ) : ( )}
); }