MSP-3107 connect AppAccessPage to app
This commit is contained in:
1 parent
76404b06e9
commit
90e9485f19
4 files changed
+51
-13
No files matched your search
@@ -1,7 +1,7 @@
|
||||
import { ProfileOutlined } from '@ant-design/icons'
|
||||
import { LockOutlined, ProfileOutlined } from '@ant-design/icons'
|
||||
import { Divider, Layout, Menu, Spin } from 'antd'
|
||||
import { useEffect, useState } from 'react'
|
||||
import { Navigate, Outlet, useLocation } from 'react-router-dom'
|
||||
import { Navigate, Outlet, useLocation, useNavigate } from 'react-router-dom'
|
||||
|
||||
import { localStorageKeys } from '@constants/localStorageKeys.ts'
|
||||
|
||||
@@ -26,10 +26,11 @@ import { PermissionKeys } from '@type/roles.type.ts'
|
||||
|
||||
import './layout.scss'
|
||||
|
||||
|
||||
const { Content, Sider } = Layout
|
||||
|
||||
const LayoutComponent = () => {
|
||||
const navigate = useNavigate()
|
||||
|
||||
const [collapsed, setCollapsed] = useState<boolean>(false)
|
||||
const [selectedMenuKeys, setSelectedMenuKeys] = useState<MenuItemKeys[]>([])
|
||||
const [openKeys, setOpenKeys] = useState<string[]>([])
|
||||
@@ -51,6 +52,12 @@ const LayoutComponent = () => {
|
||||
return hasPermission(permission) ? '' : 'hide-item'
|
||||
}
|
||||
const menuItems: MenuItemType[] = [
|
||||
{
|
||||
label: 'Доступы приложений',
|
||||
key: 'appAccess',
|
||||
className: hideItem([PermissionKeys.user_view]),
|
||||
icon: <LockOutlined />
|
||||
},
|
||||
{
|
||||
label: 'Пользователи и роли',
|
||||
key: 'sessionManagement',
|
||||
@@ -85,6 +92,9 @@ const LayoutComponent = () => {
|
||||
|
||||
const handlerOnClickMenu = ({ key }: any): void => {
|
||||
switch (key) {
|
||||
case MenuItemKeys.appAccess:
|
||||
navigate(routePaths.appAccess)
|
||||
break
|
||||
default:
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
import { MenuProps } from 'antd'
|
||||
|
||||
export enum MenuItemKeys {
|
||||
users = 'users'
|
||||
users = 'users',
|
||||
appAccess = 'appAccess'
|
||||
}
|
||||
|
||||
type MenuItem = {
|
||||
@@ -12,6 +13,10 @@ export const menuKeys: Record<MenuItemKeys, MenuItem> = {
|
||||
[MenuItemKeys.users]: {
|
||||
key: MenuItemKeys.users,
|
||||
parent: ['sessionManagement']
|
||||
},
|
||||
[MenuItemKeys.appAccess]: {
|
||||
key: MenuItemKeys.appAccess,
|
||||
parent: []
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { Spin } from 'antd'
|
||||
import { Suspense, lazy } from 'react'
|
||||
import { lazy, Suspense } from 'react'
|
||||
import { Route, Routes } from 'react-router-dom'
|
||||
|
||||
import Layout from '@components/Layout'
|
||||
@@ -10,11 +10,9 @@ import PrivateRoute from '@routes/PrivateRoute'
|
||||
import { routePaths } from '@routes/routePaths.ts'
|
||||
|
||||
const LoginPage = lazy(() => import('@pages/LoginPage'))
|
||||
|
||||
const ErrorPage = lazy(() => import('@components/ErrorPage'))
|
||||
|
||||
|
||||
const ProfilePage = lazy(() => import('@pages/ProfilePage'))
|
||||
const AppAccessPage = lazy(() => import('@pages/AppAccessPage'))
|
||||
|
||||
const Routers = () => {
|
||||
return (
|
||||
@@ -29,17 +27,35 @@ const Routers = () => {
|
||||
</Suspense>
|
||||
}
|
||||
/>
|
||||
<Route
|
||||
path={`${routePaths.profile}`}
|
||||
element={
|
||||
<Suspense fallback={<Spin />}>
|
||||
<ProfilePage />
|
||||
</Suspense>
|
||||
}
|
||||
/>
|
||||
<Route
|
||||
path={`${routePaths.appAccess}`}
|
||||
element={
|
||||
<Suspense fallback={<Spin />}>
|
||||
<AppAccessPage />
|
||||
</Suspense>
|
||||
}
|
||||
>
|
||||
<Route
|
||||
path={`${routePaths.profile}`}
|
||||
path=":id"
|
||||
element={
|
||||
<Suspense fallback={<Spin />}>
|
||||
<ProfilePage />
|
||||
<AppAccessPage />
|
||||
</Suspense>
|
||||
}
|
||||
/>
|
||||
</Route>
|
||||
</Route>
|
||||
<Route path={routePaths.error}
|
||||
</Route>
|
||||
<Route
|
||||
path={routePaths.error}
|
||||
element={
|
||||
<Suspense fallback={<Spin />}>
|
||||
<ErrorPage />
|
||||
|
||||
@@ -1,9 +1,16 @@
|
||||
type RoutePaths = 'home' | 'notFound' | 'error' | 'login' | 'profile'
|
||||
type RoutePaths =
|
||||
| 'home'
|
||||
| 'notFound'
|
||||
| 'error'
|
||||
| 'login'
|
||||
| 'profile'
|
||||
| 'appAccess'
|
||||
|
||||
export const routePaths: Record<RoutePaths, string> = {
|
||||
home: '/',
|
||||
error: '/error',
|
||||
notFound: '*',
|
||||
login: '/login',
|
||||
profile: '/profile'
|
||||
profile: '/profile',
|
||||
appAccess: '/appAccess'
|
||||
}
|
||||
Reference in new issue
Block a user