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-08-31 18:46:02 +00:00
|
|
|
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";
|
2024-07-03 17:17:47 +00:00
|
|
|
import { PendingDevicesRoute } from "./routes/PendingDevicesRoute";
|
2024-08-31 18:46:02 +00:00
|
|
|
import { RelaysListRoute } from "./routes/RelaysListRoute";
|
|
|
|
import { BaseAuthenticatedPage } from "./widgets/BaseAuthenticatedPage";
|
2024-10-07 20:04:57 +00:00
|
|
|
import { OTARoute } from "./routes/OTARoute";
|
2024-11-19 19:38:19 +00:00
|
|
|
import { ManagementRoute } from "./routes/ManagementRoute";
|
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 />} />
|
2024-07-03 17:17:47 +00:00
|
|
|
<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 />} />
|
2024-08-31 18:46:02 +00:00
|
|
|
<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-11-19 19:38:19 +00:00
|
|
|
<Route path="management" element={<ManagementRoute />} />
|
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
|
|
|
}
|