Skip to content

Commit 7547393

Browse files
committed
Rerange routes
1 parent 280487c commit 7547393

File tree

5 files changed

+52
-173
lines changed

5 files changed

+52
-173
lines changed

src/routes/AuthRoutes.tsx

Lines changed: 0 additions & 42 deletions
This file was deleted.

src/routes/ErrorRoutes.tsx

Lines changed: 0 additions & 9 deletions
This file was deleted.

src/routes/ProductRoutes.tsx

Lines changed: 0 additions & 38 deletions
This file was deleted.

src/routes/StaticPageRoutes.tsx

Lines changed: 0 additions & 75 deletions
This file was deleted.

src/routes/index.tsx

Lines changed: 52 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,58 @@
1-
import React from 'react';
1+
import React, { lazy, Suspense } from 'react';
22
import { BrowserRouter } from 'react-router-dom';
3-
import { StaticPageRoutes } from './StaticPageRoutes';
4-
import { AuthRoutes } from './AuthRoutes';
5-
import { ProductRoutes } from './ProductRoutes';
3+
import { PATH } from 'src/constants/paths';
4+
import { Loading } from 'src/components/Loading';
5+
import { AppHeader } from 'src/components/Header';
6+
import { Route, Switch } from 'react-router-dom';
7+
const NotFoundPage = lazy(() => import('src/pages/ErrorPages/404Pages'));
8+
const HomePage = lazy(() => import('src/pages/HomePages/HomePage'));
9+
const ContactPage = lazy(() => import('src/pages/StaticPages/ContactPage'));
10+
const AboutPage = lazy(() => import('src/pages/StaticPages/AboutPage'));
11+
const Demo1Page = lazy(() => import('src/pages/StaticPages/Demo1Page'));
12+
const Demo2Page = lazy(() => import('src/pages/StaticPages/Demo2Page'));
13+
const Feature1Page = lazy(() => import('src/pages/StaticPages/Feature1Page'));
14+
const Feature2Page = lazy(() => import('src/pages/StaticPages/Feature2Page'));
15+
const LoginPage = lazy(() => import('src/pages/AuthPages/LoginPage'));
16+
const RegisterPage = lazy(() => import('src/pages/AuthPages/RegisterPage'));
17+
const ProfilePage = lazy(() => import('src/pages/AuthPages/ProfilePage'));
18+
const ProductListPage = lazy(
19+
() => import('src/pages/ProductPages/ProductListPage'),
20+
);
21+
const ProductItemPage = lazy(
22+
() => import('src/pages/ProductPages/ProductItemPage'),
23+
);
624

725
export const Routes = () => {
826
return (
9-
<BrowserRouter>
10-
<StaticPageRoutes />
11-
<AuthRoutes />
12-
<ProductRoutes />
13-
</BrowserRouter>
27+
<Suspense fallback={<Loading />}>
28+
<BrowserRouter>
29+
<Switch>
30+
{/* Static pages routes */}
31+
<Route exact path={PATH.HOME} component={HomePage} />
32+
<Route exact path={PATH.ABOUT} component={AboutPage} />
33+
<Route exact path={PATH.DEMO1} component={Demo1Page} />
34+
<Route exact path={PATH.DEMO2} component={Demo2Page} />
35+
<Route exact path={PATH.FEATURE1} component={Feature1Page} />
36+
<Route exact path={PATH.FEATURE2} component={Feature2Page} />
37+
<Route exact path={PATH.CONTACT} component={ContactPage} />
38+
39+
{/* Auth routes */}
40+
<Route exact path={PATH.LOGIN} component={LoginPage} />
41+
<Route exact path={PATH.REGISTER} component={RegisterPage} />
42+
<Route exact path={PATH.PROFILE} component={ProfilePage} />
43+
44+
{/* Products routes */}
45+
<Route exact path={PATH.PRODUCTS} component={ProductListPage} />
46+
<Route
47+
exact
48+
path={PATH.PRODUCTS + '/:id'}
49+
component={ProductItemPage}
50+
/>
51+
52+
{/* Error routes */}
53+
<Route component={NotFoundPage} />
54+
</Switch>
55+
</BrowserRouter>
56+
</Suspense>
1457
);
1558
};

0 commit comments

Comments
 (0)