/* eslint-disable perfectionist/sort-imports */

'use client';

import 'dayjs/locale/en';
import 'dayjs/locale/vi';
import 'dayjs/locale/fr';
import 'dayjs/locale/zh-cn';
import 'dayjs/locale/ar-sa';
import 'dayjs/locale/ru'; // Добавил русский

import dayjs from 'dayjs';

import { AdapterDayjs } from '@mui/x-date-pickers/AdapterDayjs';
import { LocalizationProvider as Provider } from '@mui/x-date-pickers/LocalizationProvider';

import { useTranslate } from './use-locales';

// ----------------------------------------------------------------------

export function LocalizationProvider({ children }) {
  const { currentLang } = useTranslate();

  const activeLocale = currentLang.adapterLocale === 'en' ? 'ru' : currentLang.adapterLocale;

  dayjs.locale(activeLocale);

  return (
    <Provider dateAdapter={AdapterDayjs} adapterLocale={activeLocale}>
      {children}
    </Provider>
  );
}
