"use client" import { CheckIcon, ChevronsUpDownIcon } from "lucide-react" import { useState } from "react" 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" import { useI18n } from "@/i18n/provider" import { cn } from "@/lib/utils" export type ComboboxOption = { value: string label: string } type OptionComboboxProps = { value: string options: ComboboxOption[] placeholder: string searchPlaceholder?: string emptyText?: string disabled?: boolean onChange: (value: string) => void } export function OptionCombobox({ value, options, placeholder, searchPlaceholder, emptyText, disabled = false, onChange, }: OptionComboboxProps) { const t = useI18n() const [open, setOpen] = useState(false) const selectedLabel = options.find((option) => option.value === value)?.label ?? placeholder return ( } > {selectedLabel} {emptyText ?? t("common.emptyOptions")} {options.map((option) => ( { onChange(option.value) setOpen(false) }} > {option.label} ))} ) }