import Select from "react-select"; import { useState } from "react"; const languageOptions = [ { value: "ar", label: "Arabic" }, { value: "fa", label: "Farsi" }, { value: "prs", label: "Dari" }, { value: "ps", label: "Pashto" }, { value: "ps-AF", label: "Pashto (Afghanistan) "}, { value: "ps-PK", label: "Pashto (Pakistan) "}, { value: "ur", label: "Urdu" }, { value: "other", label: "Other..." }, ]; function LanguageSelect({ value, onChange }: { value: string | null, onChange: (language: string | null) => void, }) { const [showingOther, setShowingOther] = useState(false); function handleChange(o: { value: string, label: string }) { if (!o) { onChange(null); } else if (o.value === "other") { setShowingOther(true); onChange(null); } else { if (showingOther) setShowingOther(false); onChange(o.value); } } return
language:
onChange(e.target.value)} type="text" className="form-control" id="otherLang" />
} ; } export default LanguageSelect;