SolarEnergy/central_frontend/src/App.tsx
Pierre HUBERT bb0226577d
Some checks failed
continuous-integration/drone/push Build is failing
Can download a copy of storage
2024-11-19 20:40:49 +01:00

43 lines
1.6 KiB
TypeScript

import {
Route,
RouterProvider,
createBrowserRouter,
createRoutesFromElements,
} from "react-router-dom";
import { AuthApi } from "./api/AuthApi";
import { ServerApi } from "./api/ServerApi";
import { DeviceRoute } from "./routes/DeviceRoute/DeviceRoute";
import { DevicesRoute } from "./routes/DevicesRoute";
import { HomeRoute } from "./routes/HomeRoute";
import { LoginRoute } from "./routes/LoginRoute";
import { LogsRoute } from "./routes/LogsRoute";
import { NotFoundRoute } from "./routes/NotFoundRoute";
import { PendingDevicesRoute } from "./routes/PendingDevicesRoute";
import { RelaysListRoute } from "./routes/RelaysListRoute";
import { BaseAuthenticatedPage } from "./widgets/BaseAuthenticatedPage";
import { OTARoute } from "./routes/OTARoute";
import { ManagementRoute } from "./routes/ManagementRoute";
export function App() {
if (!AuthApi.SignedIn && !ServerApi.Config.auth_disabled)
return <LoginRoute />;
const router = createBrowserRouter(
createRoutesFromElements(
<Route path="*" element={<BaseAuthenticatedPage />}>
<Route path="" element={<HomeRoute />} />
<Route path="pending_devices" element={<PendingDevicesRoute />} />
<Route path="devices" element={<DevicesRoute />} />
<Route path="dev/:id" element={<DeviceRoute />} />
<Route path="relays" element={<RelaysListRoute />} />
<Route path="ota" element={<OTARoute />} />
<Route path="logs" element={<LogsRoute />} />
<Route path="management" element={<ManagementRoute />} />
<Route path="*" element={<NotFoundRoute />} />
</Route>
)
);
return <RouterProvider router={router} />;
}