SolarEnergy/central_frontend/src/App.tsx

30 lines
847 B
TypeScript
Raw Normal View History

2024-06-29 14:45:28 +00:00
import {
Route,
RouterProvider,
createBrowserRouter,
createRoutesFromElements,
} from "react-router-dom";
2024-06-29 12:43:56 +00:00
import { AuthApi } from "./api/AuthApi";
import { ServerApi } from "./api/ServerApi";
2024-06-29 11:26:12 +00:00
import { LoginRoute } from "./routes/LoginRoute";
2024-06-29 14:45:28 +00:00
import { NotFoundRoute } from "./routes/NotFoundRoute";
import { HomeRoute } from "./routes/HomeRoute";
import { BaseAuthenticatedPage } from "./widgets/BaseAuthenticatedPage";
2024-06-29 11:01:50 +00:00
2024-06-29 11:26:12 +00:00
export function App() {
2024-06-29 12:43:56 +00:00
if (!AuthApi.SignedIn && !ServerApi.Config.auth_disabled)
return <LoginRoute />;
2024-06-29 14:45:28 +00:00
const router = createBrowserRouter(
createRoutesFromElements(
<Route path="*" element={<BaseAuthenticatedPage />}>
<Route path="" element={<HomeRoute />} />
<Route path="*" element={<NotFoundRoute />} />
</Route>
)
);
return <RouterProvider router={router} />;
2024-06-29 11:01:50 +00:00
}