fix(auth): i18n и react-hook-form на странице логина
Добавлены i18next, схема zod и react-hook-form для формы входа. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -0,0 +1,30 @@
|
||||
import React, { useEffect } from 'react';
|
||||
import { ConfigProvider } from 'antd';
|
||||
import ruRU from 'antd/locale/ru_RU';
|
||||
import enUS from 'antd/locale/en_US';
|
||||
import dayjs from 'dayjs';
|
||||
import 'dayjs/locale/ru';
|
||||
import 'dayjs/locale/en';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
import { useAuthStore } from '../store/authStore';
|
||||
|
||||
const antdLocales = { ru: ruRU, en: enUS } as const;
|
||||
|
||||
const LocaleProvider: React.FC<{ children: React.ReactNode }> = ({ children }) => {
|
||||
const { i18n } = useTranslation();
|
||||
const language = useAuthStore((s) => s.user?.language);
|
||||
const locale = language === 'en' ? 'en' : 'ru';
|
||||
|
||||
useEffect(() => {
|
||||
void i18n.changeLanguage(locale);
|
||||
dayjs.locale(locale);
|
||||
}, [i18n, locale]);
|
||||
|
||||
return (
|
||||
<ConfigProvider locale={antdLocales[locale]}>
|
||||
{children}
|
||||
</ConfigProvider>
|
||||
);
|
||||
};
|
||||
|
||||
export default LocaleProvider;
|
||||
Reference in New Issue
Block a user