2021-08-26 11:50:47 +05:30
|
|
|
import NotFound from 'components/NotFound';
|
|
|
|
|
import Spinner from 'components/Spinner';
|
|
|
|
|
import { IS_LOGGED_IN } from 'constants/auth';
|
|
|
|
|
import ROUTES from 'constants/routes';
|
|
|
|
|
import AppLayout from 'modules/AppLayout';
|
|
|
|
|
import { RouteProvider } from 'modules/RouteProvider';
|
|
|
|
|
import React, { Suspense } from 'react';
|
|
|
|
|
import { BrowserRouter, Redirect,Route, Switch } from 'react-router-dom';
|
2021-08-23 11:38:25 +05:30
|
|
|
|
2021-08-26 11:50:47 +05:30
|
|
|
import routes from './routes';
|
2021-08-23 11:38:25 +05:30
|
|
|
|
|
|
|
|
const App = () => (
|
|
|
|
|
<BrowserRouter basename="/">
|
|
|
|
|
<RouteProvider>
|
|
|
|
|
<AppLayout>
|
|
|
|
|
<Suspense fallback={<Spinner size="large" tip="Loading..." />}>
|
|
|
|
|
<Switch>
|
|
|
|
|
{routes.map(({ path, component, exact }) => {
|
|
|
|
|
return <Route exact={exact} path={path} component={component} />;
|
|
|
|
|
})}
|
|
|
|
|
|
|
|
|
|
{/* This logic should be moved to app layout */}
|
|
|
|
|
<Route
|
|
|
|
|
path="/"
|
|
|
|
|
exact
|
|
|
|
|
render={() => {
|
2021-08-26 11:50:47 +05:30
|
|
|
return localStorage.getItem(IS_LOGGED_IN) === 'yes' ? (
|
2021-08-23 11:38:25 +05:30
|
|
|
<Redirect to={ROUTES.APPLICATION} />
|
|
|
|
|
) : (
|
|
|
|
|
<Redirect to={ROUTES.SIGN_UP} />
|
|
|
|
|
);
|
|
|
|
|
}}
|
|
|
|
|
/>
|
|
|
|
|
<Route path="*" component={NotFound} />
|
|
|
|
|
</Switch>
|
|
|
|
|
</Suspense>
|
|
|
|
|
</AppLayout>
|
|
|
|
|
</RouteProvider>
|
|
|
|
|
</BrowserRouter>
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
export default App;
|