'use client'; import Link from 'next/link'; import Image from 'next/image'; import { usePathname } from 'next/navigation'; import { GitCompare, X } from 'lucide-react'; import { useCartStore } from '@/store/cartStore'; import { getImageUrl } from '@/lib/utils'; import { COMPARE_LIMIT } from '@/lib/compare'; export function CompareBar() { const pathname = usePathname(); const compareList = useCartStore((s) => s.compareList) || []; const removeFromCompare = useCartStore((s) => s.removeFromCompare); const clearCompare = useCartStore((s) => s.clearCompare); const hydrated = useCartStore((s) => s._hasHydrated); if (!hydrated || pathname === '/compare' || compareList.length === 0) return null; return (
Compare
{compareList.length} of {COMPARE_LIMIT} selected
{product.name}