import { type ReactNode } from 'react';

import { AdapterDateFns } from '@mui/x-date-pickers-v6/AdapterDateFns';
import { LocalizationProvider } from '@mui/x-date-pickers-v6/LocalizationProvider';
import { getCurrentLocale } from '@utils/languages';
import es from 'date-fns/locale/es';

type DatePickersV6ProviderProps = {
  children: ReactNode;
};

const DatePickersV6Provider = ({ children }: DatePickersV6ProviderProps) => {
  return (
    <LocalizationProvider
      dateAdapter={AdapterDateFns}
      adapterLocale={getCurrentLocale() || es}
    >
      {children}
    </LocalizationProvider>
  );
};

export type { DatePickersV6ProviderProps };

export default DatePickersV6Provider;
