import './i18n';
import { ConfigProvider } from 'antd';
import { useTranslation } from 'react-i18next';

import { theme } from './customTheme';

import en from 'antd/locale/en_US';
import ru from 'antd/locale/ru_RU';

const antdLocales = {
  en: en,
  ru: ru,
};

export default function AppWrapper({ children }: any) {
  const { i18n } = useTranslation();
  const currentLang = i18n.language.split('-')[0] as 'en' | 'ru';

  return (
    <ConfigProvider locale={antdLocales[currentLang]} theme={theme}>
      {children}
    </ConfigProvider>
  );
}
