import { useState } from "react"; import { Button } from "@app/components/ui/button"; import { Popover, PopoverContent, PopoverTrigger } from "@app/components/ui/popover"; import { Command, CommandEmpty, CommandGroup, CommandInput, CommandItem, CommandList } from "@app/components/ui/command"; import { CheckIcon, ChevronDownIcon, Funnel } from "lucide-react"; import { cn } from "@app/lib/cn"; import { Badge } from "./ui/badge"; interface FilterOption { value: string; label: string; } interface ColumnFilterButtonProps { options: FilterOption[]; selectedValue?: string; onValueChange: (value: string | undefined) => void; placeholder?: string; searchPlaceholder?: string; emptyMessage?: string; className?: string; label: string; } export function ColumnFilterButton({ options, selectedValue, onValueChange, placeholder, searchPlaceholder = "Search...", emptyMessage = "No options found", className, label }: ColumnFilterButtonProps) { const [open, setOpen] = useState(false); const selectedOption = options.find( (option) => option.value === selectedValue ); return ( {emptyMessage} {/* Clear filter option */} {selectedValue && ( { onValueChange(undefined); setOpen(false); }} className="text-muted-foreground" > Clear filter )} {options.map((option) => ( { onValueChange( selectedValue === option.value ? undefined : option.value ); setOpen(false); }} > {option.label} ))} ); }