2021-08-26 11:50:47 +05:30
|
|
|
import NotFound from 'components/NotFound';
|
|
|
|
|
import Spinner from 'components/Spinner';
|
2021-11-17 16:29:58 +05:30
|
|
|
import ROUTES from 'constants/routes';
|
2021-10-20 09:24:55 +05:30
|
|
|
import AppLayout from 'container/AppLayout';
|
2021-09-23 15:43:43 +05:30
|
|
|
import history from 'lib/history';
|
2021-08-26 11:50:47 +05:30
|
|
|
import React, { Suspense } from 'react';
|
2021-12-02 18:53:05 +05:30
|
|
|
import { useSelector } from 'react-redux';
|
2021-11-22 11:49:09 +05:30
|
|
|
import { Redirect, Route, Router, Switch } from 'react-router-dom';
|
2021-12-02 18:53:05 +05:30
|
|
|
import { AppState } from 'store/reducers';
|
|
|
|
|
import AppReducer from 'types/reducer/app';
|
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
|
|
|
|
2022-03-22 12:10:31 +05:30
|
|
|
function App(): JSX.Element {
|
2021-12-02 18:53:05 +05:30
|
|
|
const { isLoggedIn } = useSelector<AppState, AppReducer>((state) => state.app);
|
|
|
|
|
|
|
|
|
|
return (
|
|
|
|
|
<Router history={history}>
|
|
|
|
|
<AppLayout>
|
|
|
|
|
<Suspense fallback={<Spinner size="large" tip="Loading..." />}>
|
|
|
|
|
<Switch>
|
2022-03-14 20:12:42 +05:30
|
|
|
{routes.map(({ path, component, exact }) => (
|
|
|
|
|
<Route key={`${path}`} exact={exact} path={path} component={component} />
|
2021-12-02 18:53:05 +05:30
|
|
|
))}
|
|
|
|
|
<Route
|
|
|
|
|
path="/"
|
|
|
|
|
exact
|
|
|
|
|
render={(): JSX.Element =>
|
|
|
|
|
isLoggedIn ? (
|
|
|
|
|
<Redirect to={ROUTES.APPLICATION} />
|
|
|
|
|
) : (
|
|
|
|
|
<Redirect to={ROUTES.SIGN_UP} />
|
|
|
|
|
)
|
|
|
|
|
}
|
|
|
|
|
/>
|
|
|
|
|
<Route path="*" component={NotFound} />
|
|
|
|
|
</Switch>
|
|
|
|
|
</Suspense>
|
|
|
|
|
</AppLayout>
|
|
|
|
|
</Router>
|
|
|
|
|
);
|
2022-03-22 12:10:31 +05:30
|
|
|
}
|
2021-12-02 18:53:05 +05:30
|
|
|
|
2021-08-23 11:38:25 +05:30
|
|
|
export default App;
|