import { Controller, type FieldPath, type FieldValues, get, useFormContext, } from "react-hook-form"; import { FormMessage } from "~/components/FormMessage"; import { UserSearch } from "../elements/UserSearch"; export function UserSearchFormField({ label, name, bottomText, }: { label: string; name: FieldPath; bottomText?: string; }) { const methods = useFormContext(); const error = get(methods.formState.errors, name); return (
( onChange(newUser.id)} initialUserId={value} onBlur={onBlur} ref={ref} label={label} /> )} /> {error && ( {error.message as string} )} {bottomText && !error ? ( {bottomText} ) : null}
); }