'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'; 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); setTimeout(() => setAdded(false), 1500); }; 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} {/* Badge marka */} {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 ? ( ) : ( )}
); }