'use client'; import { useEffect, useState, useRef } from 'react'; import { ChevronDown } from 'lucide-react'; import { useProductListing, sortOptions, isActiveInTree, type CategoryNode, } from '@/core/hooks/use-product-listing'; import { ProductGrid } from '@/ui/product/product-grid'; import { LoadingSpinner } from '@/ui/shared/loading-spinner'; import { Button } from '@/components/ui/button'; import { Checkbox } from '@/components/ui/checkbox'; import { Label } from '@/components/ui/label'; import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue, } from '@/components/ui/select'; import { useTranslations } from '@/core/lib/translations'; import { cn } from '@/core/lib/utils'; /** Radix Select items can't carry an empty-string value, so "no filter" * round-trips through this sentinel and is written back as ''. */ const ALL = '__all__'; /** Recursive dropdown items for nested categories */ function CategoryDropdownItems({ items, depth, selectedId, onSelect, }: { items: CategoryNode[]; depth: number; selectedId: string; onSelect: (id: string) => void; }) { return ( <> {items.map((child) => (
{total} {total === 1 ? tc('product') : tc('products')} {tc('found')}
)}