import { FC, useState, useEffect } from "react"; import { Select as InternalSelect, MenuItem } from "@mui/material"; export type SelectOption = { value: string; label: string; }; type SelectProps = { name: string; label: string; formState: Record; required?: boolean; getOptions?: (formState: any) => Promise; }; export const Select: FC = ({ name, label, formState, required = false, getOptions, }) => { const [options, setOptions] = useState([] as SelectOption[]); useEffect(() => { const fetchData = async () => { if (getOptions) { const opts = await getOptions(formState); setOptions(opts); } }; fetchData(); }, [getOptions, formState]); return ( {options.map((option: SelectOption) => ( {option.label} ))} ); };