import { Language } from "../lib/types";
import "./LanguageSwitcher.css";

function LanguageSwitcher({
  defaultLang,
  onChange,
}: {
  defaultLang: Language;
  onChange: (lang: Language) => void;
}) {
  return (
    <>
      <select
        defaultValue={defaultLang}
        onChange={(ev) => onChange(ev.currentTarget.value as Language)}
        className="language-switcher"
      >
        {Object.values(Language).map((lang) => (
          <option key={lang} value={lang}>
            {lang.toUpperCase()}
          </option>
        ))}
      </select>
    </>
  );
}

export default LanguageSwitcher;
