import { ChevronDown } from "lucide-react";
import { useTranslation } from "react-i18next";

interface LanguageSwitcherProps {
  className?: string;
}

export function LanguageSwitcher({ className = "" }: LanguageSwitcherProps) {
  const { i18n, t } = useTranslation();
  const value = i18n.language.startsWith("pl") ? "pl" : "en";

  return (
    <div className={`relative ${className}`}>
      <select
        value={value}
        onChange={(e) => void i18n.changeLanguage(e.target.value)}
        className="select !w-auto !py-2 !pr-9 !text-sm"
        aria-label={t("language.label")}
      >
        <option value="en">EN</option>
        <option value="pl">PL</option>
      </select>
      <ChevronDown
        className="pointer-events-none absolute right-2.5 top-1/2 h-3.5 w-3.5 -translate-y-1/2 text-slate-400"
        aria-hidden="true"
      />
    </div>
  );
}
