import {ConfigProvider} from "antd";
import {Routes, Route, Navigate, HashRouter} from "react-router-dom";
import {LazyLoginPage} from './pages/LoginPage/Loadbale.jsx'
import {LazyMainPage} from "./pages/MainPage/Loadable";
import {useAppSlice} from './slice'
import {antdLocales} from "../locales/i18n";
import {useTranslation} from "react-i18next";
import {PATH} from './constants';

export function AppRouter() {
  useAppSlice();
  const { i18n } = useTranslation();
  return (
    <ConfigProvider locale={antdLocales[i18n.language]}>
      <HashRouter >
        <Routes>
          <Route path={PATH.ROOT} element={<Navigate replace to={PATH.LOGIN}/>}/>
          <Route path={PATH.LOGIN} Component={LazyLoginPage} />
          <Route path={PATH.MAIN + '/*'} Component={LazyMainPage} />
        </Routes>
      </HashRouter>
    </ConfigProvider>
  );
}
