'use client' import type { OptionObject, UIField } from 'payload' import { SelectInput, useField } from '@payloadcms/ui' import { useEffect, useMemo } from 'react' interface Props { field: UIField path: string required?: boolean } const selectOptions = [ { label: 'Option 1', value: 'option-1', }, { label: 'Option 2', value: 'option-2', }, ] export function CustomInput({ field, path, required = false }: Props) { const { setValue, value } = useField({ path }) const options = useMemo(() => { const internal: OptionObject[] = [] internal.push(...selectOptions) return internal }, []) return (
{ const selectedValue = (Array.isArray(option) ? option[0]?.value : option?.value) || '' setValue(selectedValue) }} options={options} path={path} required={required} value={value} />
) }