diff --git a/assets/js/react/components/SelectLanguage.tsx b/assets/js/react/components/SelectLanguage.tsx index 983d0b0..b528c81 100644 --- a/assets/js/react/components/SelectLanguage.tsx +++ b/assets/js/react/components/SelectLanguage.tsx @@ -1,6 +1,8 @@ import * as React from "react" import { SelectProps } from "@mui/base/Select" +import type { Language } from "../types/Language" + import { Select, Option } from "./Select" import { useFetchLanguages } from "../utils/queries" @@ -11,31 +13,29 @@ export const SelectLanguage = React.forwardRef(function SelectLanguage( ref: React.ForwardedRef ) { const id = React.useId() - const [options, setOptions] = React.useState([ - { value: "", label: "Loading..." }, - ]) + const [options, setOptions] = React.useState(null) const { defaultValue, ...other } = props const { isLoading, data } = useFetchLanguages() React.useEffect(() => { - if (!data) { - return + if (data) { + setOptions(data) } - setOptions(data.map((row) => ({ value: row.code, label: row.name }))) }, [data]) return (