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, Filter } from "lucide-react"; import { cn } from "@app/lib/cn"; interface FilterOption { value: string; label: string; } interface ColumnFilterProps { options: FilterOption[]; selectedValue?: string; onValueChange: (value: string | undefined) => void; placeholder?: string; searchPlaceholder?: string; emptyMessage?: string; className?: string; } export function ColumnFilter({ options, selectedValue, onValueChange, placeholder, searchPlaceholder = "Search...", emptyMessage = "No options found", className }: ColumnFilterProps) { 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} ))} ); }