import FormField, { fieldDescribedBy } from '@/components/ui/FormField'
import Select from '@/components/ui/Select'
import ReadOnlyValue from './ReadOnlyValue'
export interface SelectOption {
value: string
label: string
}
export interface SelectFieldProps {
id: string
label: string
value: string
options: readonly SelectOption[]
/** A choice is a confirmation: it commits at once. */
onCommit: (value: string) => void
readOnly?: boolean
hint?: string
error?: string
}
/** A choice among fixed options; read-only, the chosen option's label as text. */
export default function SelectField({
id,
label,
value,
options,
onCommit,
readOnly,
hint,
error,
}: SelectFieldProps) {
if (readOnly) {
const chosen = options.find((option) => option.value === value)
return
}
return (
)
}