Добавлена страница-заглушка для Suspense

This commit is contained in:
Александр Сироткин 2021-12-21 17:41:02 +05:00
parent 3c4b98366d
commit c12ce68a96
2 changed files with 11 additions and 1 deletions

View File

@ -2,6 +2,7 @@ import { Layout, Menu } from 'antd'
import { lazy, Suspense } from 'react'
import { Switch, Link, useParams, Redirect, Route } from 'react-router-dom'
import { PrivateMenuItem, PrivateRoute } from '../../components/Private'
import { SuspenseFallback } from '../SuspenseFallback'
const ClusterController = lazy(() => import('./ClusterController'))
const CompanyController = lazy(() => import('./CompanyController'))
@ -47,7 +48,7 @@ export const AdminPanel = () => {
<Layout>
<Layout.Content className={'site-layout-background'}>
<Suspense fallback={<div>Loading...</div>}>
<Suspense fallback={<SuspenseFallback />}>
<Switch>
<PrivateRoute permission={ 'deposit_editor'} path={`${rootPath}/deposit` } component={ DepositController} />
<PrivateRoute permission={ 'cluster_editor'} path={`${rootPath}/cluster` } component={ ClusterController} />

View File

@ -0,0 +1,9 @@
import { LoadingOutlined } from '@ant-design/icons'
import { Flex } from '../components/Grid'
export const SuspenseFallback = ({ style }) => (
<Flex style={{ justifyContent: 'center', alignItems: 'center', minHeight: '400px', ...style }}>
<LoadingOutlined />
<div style={{ marginLeft: '10px' }}>Страница загружается, пожалуйста, подождите...</div>
</Flex>
)