import { Controller, useFormContext, type FieldValues, type FieldPath, } from "react-hook-form"; import MenuItem from "@mui/material/MenuItem"; import { Select } from "@/Components/inputs"; export interface FormSelectOption { value: string | number; label: string; } interface FormSelectProps extends Omit< React.ComponentProps, "name" | "error" | "value" | "onChange" > { name: FieldPath; options: FormSelectOption[]; fallbackValue?: string | number; // display value while the field is undefined onValueChange?: (value: string | number) => void; // side effects, see Notes } export const FormSelectField = ({ name, options, fallbackValue, onValueChange, ...rest }: FormSelectProps) => { const { control } = useFormContext(); return ( ( )} /> ); };