"use client"; import { ChevronDown, TrendingUp, Zap, SortAsc, Building2, Flame, Droplet, Candy, FileCheck, Image, Activity, Leaf, Layers, Check, } from "lucide-react"; import { Button } from "@/components/ui/button"; import { DropdownMenu, DropdownMenuContent, DropdownMenuItem, DropdownMenuTrigger, } from "@/components/ui/dropdown-menu"; import { SORT_OPTIONS } from "@/lib/types"; // Mapear ícones para cada opção const SORT_ICONS: Record< string, React.ComponentType<{ className?: string }> > = { relevance: TrendingUp, nutrition_grade: Zap, name: SortAsc, brand: Building2, energy: Flame, fat: Droplet, sugars: Candy, completeness: FileCheck, with_images: Image, with_nutrition: Activity, eco_score: Leaf, nova_group: Layers, }; interface SortDropdownProps { value: string; onValueChange: (value: string) => void; className?: string; align?: "start" | "center" | "end"; } export function SortDropdown({ value, onValueChange, className = "", align = "start", }: SortDropdownProps) { const selectedOption = SORT_OPTIONS.find((option) => option.value === value) || SORT_OPTIONS[0]; return (
{SORT_OPTIONS.map((option) => { const IconComponent = SORT_ICONS[option.value]; return ( onValueChange(option.value)} className={`flex items-start gap-3 p-3 ${ value === option.value ? "bg-accent" : "" }`} > {/* Ícone */}
{IconComponent && ( )}
{/* Conteúdo */}
{option.label} {value === option.value && ( )}
{option.description && ( {option.description} )}
); })}
); } interface SortToggleProps { value: string; onValueChange: (value: string) => void; className?: string; } export function SortToggle({ value, onValueChange, className = "", }: SortToggleProps) { const isAscending = value === "asc"; return ( ); }