maccounter
29 строк · 1.1 Кб
1import React, { lazy, Suspense } from 'react'
2import { Redirect, Route, Switch } from 'react-router-dom'
3import { useAppSelector } from '@store/hooks'
4import Home from '../Home/Home'
5import styles from './ContentPage.module.scss'
6
7const Accountancy = lazy(() => import('@pages/Accountancy/Accountancy'))
8const Statistics = lazy(() => import('@pages/Statistics/Statistics'))
9const Settings = lazy(() => import('@pages/Settings/Settings'))
10
11const ContentPage: React.FC = () => {
12const links = useAppSelector((state) => state.app.links)
13return (
14<main className={styles.container}>
15<Suspense fallback="Загрузка...">
16<Switch>
17<Route path={links.basedir} exact render={() => <Redirect to={links.home} />} />
18<Route path={links.home} component={Home} />
19<Route path={links.accountancy} component={Accountancy} />
20<Route path={links.statistics} component={Statistics} />
21<Route path={links.settings} component={Settings} />
22</Switch>
23
24</Suspense>
25</main>
26)
27}
28
29export default ContentPage
30