mirror of
https://github.com/SigNoz/signoz.git
synced 2025-12-20 17:07:18 +00:00
44 lines
1.2 KiB
TypeScript
44 lines
1.2 KiB
TypeScript
|
|
import React, { Suspense } from "react";
|
||
|
|
import ROUTES from "constants/routes";
|
||
|
|
import { BrowserRouter, Route, Switch, Redirect } from "react-router-dom";
|
||
|
|
import Spinner from "components/Spinner";
|
||
|
|
import NotFound from "components/NotFound";
|
||
|
|
|
||
|
|
import { IS_LOGGED_IN } from "constants/auth";
|
||
|
|
|
||
|
|
import AppLayout from "modules/AppLayout";
|
||
|
|
import { RouteProvider } from "modules/RouteProvider";
|
||
|
|
import routes from "./routes";
|
||
|
|
|
||
|
|
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={() => {
|
||
|
|
return localStorage.getItem(IS_LOGGED_IN) === "yes" ? (
|
||
|
|
<Redirect to={ROUTES.APPLICATION} />
|
||
|
|
) : (
|
||
|
|
<Redirect to={ROUTES.SIGN_UP} />
|
||
|
|
);
|
||
|
|
}}
|
||
|
|
/>
|
||
|
|
<Route path="*" component={NotFound} />
|
||
|
|
</Switch>
|
||
|
|
</Suspense>
|
||
|
|
</AppLayout>
|
||
|
|
</RouteProvider>
|
||
|
|
</BrowserRouter>
|
||
|
|
);
|
||
|
|
|
||
|
|
export default App;
|