1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768 |
- import React, { Suspense, lazy } from "react";
- import { Switch, Route } from "react-router-dom";
- import * as routes from './constants/routes';
- import Header from "./containers/Header";
- import landingPage from './components/public-components/landingPage';
- import Footer from './components/public-components/footer';
- import PrivateRouter from './components/common/privateRouter';
- import PrivateAdminRouter from './components/common/privateAdminRouter';
- import Spinner from "./components/common/spinner";
- const notFound = lazy(() => import("./components/public-components/notFound"));
- // const permissionDenied = lazy(() => import("./components/public-components/permissionDenied"));
- const homePage = lazy(() => import("./components/user-components/homePage"));
- const signInPage = lazy(() => import("./containers/auth/SignInPage"));
- const signUpPage = lazy(() => import("./containers/auth/SignUpPage"));
- const createTestForm = lazy(() => import("./components/user-components/admin-components/createTestForm"));
- class Router extends React.Component {
- checkUserInLocalStorage = () => {
- // localStorage.getItem(token)
- }
- getSomeUsers() {
- fetch('localhost:3306')
- .then(res => console.log(res))
- .catch(exc => console.warn(exc.message))
- }
- componentDidMount() {
- this.getSomeUsers();
- }
- render() {
- return (
- <div className="app">
- <Header />
- <Suspense fallback={<Spinner />}>
- <Switch>
- <Route path={routes.LANDING} exact component={landingPage} />
- <Route path={routes.SIGN_IN} exact component={signInPage} />
- <Route path={routes.SIGN_UP} exact component={signUpPage} />
- <Route path={routes.HOME} exact component={homePage} />
- <PrivateRouter path={routes.HOME} exact component={homePage} />
- <PrivateRouter path={routes.TESTS} exact component={null} />
- <PrivateRouter path={routes.CATEGORIES} exact component={null} />
- <PrivateRouter path={routes.PROFILE} exact component={null} />
- <PrivateAdminRouter path={routes.CREATE_TEST} exact component={createTestForm} />
- <PrivateAdminRouter path={routes.CREATE_CATEGORY} exact component={null} />
- <PrivateAdminRouter path={routes.DELETE_USER} exact component={null} />
- {/* <Route path={routes.PERMISSON_DENIED} exact component={permissionDenied} /> */}
- <Route component={notFound} />
- </Switch>
- </Suspense>
- <Footer />
- </div>
- )
- }
- }
- export default Router;
|