asb_cloud_front/src/App.tsx

52 lines
1.9 KiB
TypeScript
Raw Normal View History

import { BrowserRouter as Router, Navigate, Route, Routes } from 'react-router-dom'
import { memo } from 'react'
import { ConfigProvider } from 'antd'
import locale from 'antd/lib/locale/ru_RU'
import { RootPathContext } from '@asb/context'
import { getUserToken, NoAccessComponent } from '@utils'
import { OpenAPI } from '@api'
import AdminPanel from '@pages/AdminPanel'
import Well from '@pages/Well'
import Login from '@pages/Login'
import Cluster from '@pages/Cluster'
import Deposit from '@pages/Deposit'
import Register from '@pages/Register'
import FileDownload from '@pages/FileDownload'
import '@styles/App.less'
import '@styles/include/antd_theme.less'
2021-07-26 14:40:35 +05:00
//OpenAPI.BASE = 'http://localhost:3000'
OpenAPI.TOKEN = async () => getUserToken() ?? ''
OpenAPI.HEADERS = {'Content-Type': 'application/json'}
2021-04-02 17:22:34 +05:00
export const App = memo(() => (
<ConfigProvider locale={locale}>
<RootPathContext.Provider value={''}>
<Router>
<Routes>
<Route index element={<Navigate to={Deposit.getKey()} replace />} />
<Route path={'*'} element={<NoAccessComponent />} />
{/* Public pages */}
<Route path={Login.route} element={<Login />} />
<Route path={Register.route} element={<Register />} />
{/* Admin pages */}
<Route path={AdminPanel.route} element={<AdminPanel />} />
{/* User pages */}
<Route path={Deposit.route} element={<Deposit />} />
<Route path={Cluster.route} element={<Cluster />} />
<Route path={Well.route} element={<Well />} />
<Route path={FileDownload.route} element={<FileDownload />} />
</Routes>
</Router>
</RootPathContext.Provider>
</ConfigProvider>
))
export default App