2022-06-09 17:51:41 +05:00
|
|
|
import { BrowserRouter as Router, Navigate, Route, Routes } from 'react-router-dom'
|
2022-10-13 14:00:17 +05:00
|
|
|
import { lazy, memo, Suspense } from 'react'
|
2022-01-12 20:49:30 +05:00
|
|
|
import locale from 'antd/lib/locale/ru_RU'
|
2022-10-13 14:00:17 +05:00
|
|
|
import { ConfigProvider } from 'antd'
|
2022-01-12 20:49:30 +05:00
|
|
|
|
2022-06-09 17:51:41 +05:00
|
|
|
import { RootPathContext } from '@asb/context'
|
2022-10-13 14:00:17 +05:00
|
|
|
import { UserOutlet } from '@components/outlets'
|
2022-10-13 18:16:43 +05:00
|
|
|
import LayoutPortal from '@components/LayoutPortal'
|
2022-10-13 14:00:17 +05:00
|
|
|
import SuspenseFallback from '@components/SuspenseFallback'
|
2022-10-24 07:35:56 +05:00
|
|
|
import { getUser, NoAccessComponent } from '@utils'
|
2022-04-29 18:38:49 +05:00
|
|
|
import { OpenAPI } from '@api'
|
2021-03-31 15:54:02 +05:00
|
|
|
|
2022-10-13 16:35:19 +05:00
|
|
|
import '@styles/include/antd_theme.less'
|
|
|
|
import '@styles/App.less'
|
2022-01-12 20:49:30 +05:00
|
|
|
|
2022-10-13 14:00:17 +05:00
|
|
|
const Login = lazy(() => import('@pages/public/Login'))
|
|
|
|
const Register = lazy(() => import('@pages/public/Register'))
|
|
|
|
const FileDownload = lazy(() => import('@pages/FileDownload'))
|
|
|
|
|
|
|
|
const AdminPanel = lazy(() => import('@pages/AdminPanel'))
|
|
|
|
const Deposit = lazy(() => import('@pages/Deposit'))
|
|
|
|
const Cluster = lazy(() => import('@pages/Cluster'))
|
2022-10-13 16:59:16 +05:00
|
|
|
const Well = lazy(() => import('@asb/pages/Well'))
|
2022-01-12 20:49:30 +05:00
|
|
|
|
2021-07-26 14:40:35 +05:00
|
|
|
//OpenAPI.BASE = 'http://localhost:3000'
|
2022-10-24 07:35:56 +05:00
|
|
|
OpenAPI.TOKEN = async () => getUser().token ?? ''
|
2022-10-13 14:00:17 +05:00
|
|
|
OpenAPI.HEADERS = { 'Content-Type': 'application/json' }
|
2021-04-02 17:22:34 +05:00
|
|
|
|
2022-02-25 16:57:08 +05:00
|
|
|
export const App = memo(() => (
|
2021-08-17 13:01:13 +05:00
|
|
|
<ConfigProvider locale={locale}>
|
2022-06-09 17:51:41 +05:00
|
|
|
<RootPathContext.Provider value={''}>
|
2022-10-13 14:00:17 +05:00
|
|
|
<Suspense fallback={<SuspenseFallback style={{ minHeight: '100vh' }} />}>
|
|
|
|
<Router>
|
|
|
|
<Routes>
|
|
|
|
<Route index element={<Navigate to={'deposit'} replace />} />
|
|
|
|
<Route path={'*'} element={<NoAccessComponent />} />
|
|
|
|
|
|
|
|
{/* Public pages */}
|
|
|
|
<Route path={'/login'} element={<Login />} />
|
|
|
|
<Route path={'/register'} element={<Register />} />
|
|
|
|
|
|
|
|
{/* User pages */}
|
|
|
|
<Route element={<UserOutlet />}>
|
|
|
|
<Route path={'/file_download/:idWell/:idFile/*'} element={<FileDownload />} />
|
2022-10-13 18:16:43 +05:00
|
|
|
|
|
|
|
<Route element={<LayoutPortal />}>
|
|
|
|
{/* Admin pages */}
|
|
|
|
<Route path={'/admin/*'} element={<AdminPanel />} />
|
|
|
|
|
|
|
|
{/* Client pages */}
|
|
|
|
<Route path={'/deposit/*'} element={<Deposit />} />
|
|
|
|
<Route path={'/cluster/:idCluster'} element={<Cluster />} />
|
|
|
|
<Route path={'/well/:idWell/*'} element={<Well />} />
|
|
|
|
</Route>
|
2022-10-13 14:00:17 +05:00
|
|
|
</Route>
|
|
|
|
</Routes>
|
|
|
|
</Router>
|
|
|
|
</Suspense>
|
2022-06-09 17:51:41 +05:00
|
|
|
</RootPathContext.Provider>
|
2021-08-17 13:01:13 +05:00
|
|
|
</ConfigProvider>
|
2022-02-25 16:57:08 +05:00
|
|
|
))
|
2022-01-12 20:49:30 +05:00
|
|
|
|
|
|
|
export default App
|