"use client"; import * as React from "react"; import { Check, ChevronsUpDown } from "lucide-react"; import { cn } from "@/lib/utils"; import { Button } from "@/components/ui/button"; import { Command, CommandEmpty, CommandGroup, CommandInput, CommandItem, CommandList, } from "@/components/ui/command"; import { Popover, PopoverContent, PopoverTrigger, } from "@/components/ui/popover"; interface CategoryAutocompleteProps { value: string; onChange: (value: string) => void; suggestions: string[]; placeholder?: string; className?: string; disabled?: boolean; "data-testid"?: string; } export function CategoryAutocomplete({ value, onChange, suggestions, placeholder = "Select or type a category...", className, disabled = false, "data-testid": testId, }: CategoryAutocompleteProps) { const [open, setOpen] = React.useState(false); return ( No category found. {suggestions.map((suggestion) => ( { onChange(currentValue === value ? "" : currentValue); setOpen(false); }} data-testid={`category-option-${suggestion.toLowerCase().replace(/\s+/g, "-")}`} > {suggestion} ))} ); }