SolarEnergy/central_frontend/src/App.tsx

41 lines
1.5 KiB
TypeScript
Raw Permalink 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";
import { DeviceRoute } from "./routes/DeviceRoute/DeviceRoute";
import { DevicesRoute } from "./routes/DevicesRoute";
import { HomeRoute } from "./routes/HomeRoute";
2024-06-29 11:26:12 +00:00
import { LoginRoute } from "./routes/LoginRoute";
2024-10-02 19:54:54 +00:00
import { LogsRoute } from "./routes/LogsRoute";
2024-06-29 14:45:28 +00:00
import { NotFoundRoute } from "./routes/NotFoundRoute";
import { PendingDevicesRoute } from "./routes/PendingDevicesRoute";
import { RelaysListRoute } from "./routes/RelaysListRoute";
import { BaseAuthenticatedPage } from "./widgets/BaseAuthenticatedPage";
2024-10-07 20:04:57 +00:00
import { OTARoute } from "./routes/OTARoute";
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="pending_devices" element={<PendingDevicesRoute />} />
2024-07-18 18:06:46 +00:00
<Route path="devices" element={<DevicesRoute />} />
<Route path="dev/:id" element={<DeviceRoute />} />
<Route path="relays" element={<RelaysListRoute />} />
2024-10-07 20:04:57 +00:00
<Route path="ota" element={<OTARoute />} />
2024-10-02 19:54:54 +00:00
<Route path="logs" element={<LogsRoute />} />
2024-06-29 14:45:28 +00:00
<Route path="*" element={<NotFoundRoute />} />
</Route>
)
);
return <RouterProvider router={router} />;
2024-06-29 11:01:50 +00:00
}