diff --git a/.prettierrc b/.prettierrc
index 42e5c63..f67786c 100644
--- a/.prettierrc
+++ b/.prettierrc
@@ -36,7 +36,7 @@
"^@type/(.*)$",
"^./*.*.ts",
"^[./]",
- "^./*.*.(scss|css)"
+ ".(scss|css)$"
],
"importOrderSeparation": true
}
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 8dadf00..df8cd57 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,3 +1,7 @@
+## 0.14.2
+- Исправлено появление экрана после логина
+- На экране ошибки добавлена кнопка "На главную"
+- Внутренние улучшения кода
## 0.14.1
- Исправлено отображение времени создания на странице Токенов
## 0.14.0
diff --git a/package.json b/package.json
index 895cdf1..0740afb 100644
--- a/package.json
+++ b/package.json
@@ -1,7 +1,7 @@
{
"name": "isp-admin-ui",
"private": true,
- "version": "0.14.1",
+ "version": "0.14.2",
"type": "module",
"scripts": {
"start": "vite",
diff --git a/src/components/App.tsx b/src/components/App.tsx
index 96bcc67..d025055 100644
--- a/src/components/App.tsx
+++ b/src/components/App.tsx
@@ -1,6 +1,7 @@
import { ConfigProvider } from 'antd'
import ruRu from 'antd/locale/ru_RU'
import { useEffect, useState } from 'react'
+import { useLocation } from 'react-router-dom'
import { darkTheme, lightTheme } from '@constants/theme.ts'
@@ -18,6 +19,15 @@ const App = () => {
: true
)
+ const location = useLocation()
+
+ useEffect(() => {
+ const prevRoute = sessionStorage.getItem('prevRoute')
+ if (location.pathname !== prevRoute) {
+ sessionStorage.setItem('prevRoute', location.pathname)
+ }
+ }, [location])
+
useEffect(() => {
setTheme(() => (changeTheme ? darkTheme : lightTheme))
}, [changeTheme])
diff --git a/src/components/ErrorPage/error.scss b/src/components/ErrorPage/error.scss
deleted file mode 100644
index c06f6bc..0000000
--- a/src/components/ErrorPage/error.scss
+++ /dev/null
@@ -1,5 +0,0 @@
-.error-page {
- min-height: 100vh;
- display: flex;
- justify-content: center;
-}
diff --git a/src/components/ErrorPage/index.tsx b/src/components/ErrorPage/index.tsx
deleted file mode 100644
index 3292fe4..0000000
--- a/src/components/ErrorPage/index.tsx
+++ /dev/null
@@ -1,9 +0,0 @@
-const ErrorPage = () => {
- return (
-
- )
-}
-
-export default ErrorPage
diff --git a/src/components/Layout/index.tsx b/src/components/Layout/index.tsx
index 4b4e0c7..6dddfe8 100644
--- a/src/components/Layout/index.tsx
+++ b/src/components/Layout/index.tsx
@@ -32,19 +32,19 @@ import { routePaths } from '@routes/routePaths.ts'
import { PermissionKeysType } from '@type/roles.type.ts'
-
-
-import './layout.scss';
-
+import './layout.scss'
const { Content, Sider } = Layout
const LayoutComponent = () => {
- const [collapsed, setCollapsed] = useState(LocalStorage.get('menu') === null ? true : LocalStorage.get('menu'))
+ const [collapsed, setCollapsed] = useState(
+ LocalStorage.get('menu') === null ? true : LocalStorage.get('menu')
+ )
const [selectedMenuKeys, setSelectedMenuKeys] = useState(
[]
)
const [openKeys, setOpenKeys] = useState([])
+ const [loading, setLoading] = useState(true)
const dispatch = useAppDispatch()
const {
status,
@@ -135,13 +135,21 @@ const LayoutComponent = () => {
)
})
}, [theme])
-
useEffect(() => {
- if (userToken) {
+ if (userToken && status === StateProfileStatus.notInit) {
dispatch(fetchProfile())
dispatch(fetchUI())
}
- }, [])
+ }, [userToken, status])
+
+ useEffect(() => {
+ if (
+ status === StateProfileStatus.resolved ||
+ status === StateProfileStatus.rejected
+ ) {
+ setLoading(false)
+ }
+ }, [status])
useEffect(() => {
const menuKey = location.pathname.split('/')[1] as MenuItemKeysType
@@ -187,6 +195,10 @@ const LayoutComponent = () => {
}
}
+ if (loading || status === StateProfileStatus.pending) {
+ return
+ }
+
if (status === StateProfileStatus.rejected) {
return
}
@@ -194,39 +206,33 @@ const LayoutComponent = () => {
return (
- {status === StateProfileStatus.pending ? (
-
- ) : (
- <>
- {
- LocalStorage.set('menu', value)
- setCollapsed(value)
- }}
- >
-
-
-
-
-
-
-
- >
- )}
+ {
+ LocalStorage.set('menu', value)
+ setCollapsed(value)
+ }}
+ >
+
+
+
+
+
+
+
)
diff --git a/src/pages/ErrorWrapperPage/index.tsx b/src/pages/ErrorWrapperPage/index.tsx
new file mode 100644
index 0000000..69347e0
--- /dev/null
+++ b/src/pages/ErrorWrapperPage/index.tsx
@@ -0,0 +1,21 @@
+import { Button } from 'antd'
+import { Layout } from 'isp-ui-kit'
+import { useNavigate } from 'react-router-dom'
+
+import { routePaths } from '@routes/routePaths.ts'
+
+const { ErrorPage } = Layout
+
+const ErrorWrapperPage = () => {
+ const navigate = useNavigate()
+
+ return (
+
+
+
+ )
+}
+
+export default ErrorWrapperPage
diff --git a/src/routes/Routers/index.tsx b/src/routes/Routers/index.tsx
index c102096..b9bbdd7 100644
--- a/src/routes/Routers/index.tsx
+++ b/src/routes/Routers/index.tsx
@@ -1,5 +1,4 @@
import { Spin } from 'antd'
-import { Layout } from 'isp-ui-kit'
import { lazy, Suspense } from 'react'
import { Navigate, Route, Routes } from 'react-router-dom'
@@ -8,13 +7,11 @@ import LayoutComponent from '@components/Layout'
// Составная часть основной страницы, поэтому без lazy
import Configurations from '@pages/ConfigurationsPage'
import Connections from '@pages/ConnectionsPage'
+import ErrorWrapperPage from '@pages/ErrorWrapperPage'
import PrivateRoute from '@routes/PrivateRoute'
import { routePaths } from '@routes/routePaths.ts'
-
-const { ErrorPage } = Layout
-
const LoginPage = lazy(() => import('@pages/LoginPage'))
const ProfilePage = lazy(() => import('@pages/ProfilePage'))
const UsersPage = lazy(() => import('@pages/UsersPage'))
@@ -204,7 +201,7 @@ const Routers = () => {
path={routePaths.error}
element={
}>
-
+
}
/>
diff --git a/vite.config.ts b/vite.config.ts
index 0b0b100..285816a 100644
--- a/vite.config.ts
+++ b/vite.config.ts
@@ -28,7 +28,7 @@ export default defineConfig(({ mode }) => {
},
host: true,
strictPort: true,
- port: 8001,
+ port: 8000,
proxy: {
'/api': env.PROXY_URL
}