'use client' import * as SelectPrimitive from '@radix-ui/react-select' import { Check } from 'lucide-react' import { useTranslations } from 'next-intl' import { Select, SelectContent, SelectTrigger, SelectValue } from '@/components/ui/select' import { cn } from '@/lib/utils' import { VAT_TREATMENT_OPTIONS } from './transaction-types' import type { VatTreatment } from '@/types' type VatSelectValue = VatTreatment | 'none' | 'auto' // The "auto" option is opt-in (allowAuto): it means "no explicit treatment, // the server derives it from the picked category" and is only meaningful in // flows that submit category + treatment together (batch booking). const AUTO_OPTION = { value: 'auto', labelKey: 'vat_auto', descriptionKey: 'vat_auto_desc' } as const interface VatTreatmentSelectProps { value: T onValueChange: (value: T) => void disabled?: boolean allowAuto?: boolean } export default function VatTreatmentSelect({ value, onValueChange, disabled, allowAuto, }: VatTreatmentSelectProps) { const t = useTranslations('tx_categories') const options: ReadonlyArray<{ value: VatSelectValue; labelKey: string; descriptionKey?: string }> = allowAuto ? [AUTO_OPTION, ...VAT_TREATMENT_OPTIONS] : VAT_TREATMENT_OPTIONS return ( ) }