import { observer } from "mobx-react-lite";
import { useTranslation } from "react-i18next";
import i18n from "@/i18n";
import { cn } from "@/lib/utils";
import { getInitialTheme, loadTheme } from "@/utils/theme";
import LocaleSelect from "./LocaleSelect";
import ThemeSelect from "./ThemeSelect";

interface Props {
  className?: string;
}

const AuthFooter = observer(({ className }: Props) => {
  const { i18n: i18nInstance } = useTranslation();
  const currentLocale = i18nInstance.language as Locale;
  const currentTheme = getInitialTheme();

  const handleLocaleChange = (locale: Locale) => {
    i18n.changeLanguage(locale);
  };

  const handleThemeChange = (theme: string) => {
    loadTheme(theme);
  };

  return (
    <div className={cn("mt-4 flex flex-row items-center justify-center w-full gap-2", className)}>
      <LocaleSelect value={currentLocale} onChange={handleLocaleChange} />
      <ThemeSelect value={currentTheme} onValueChange={handleThemeChange} />
    </div>
  );
});

export default AuthFooter;
