2024-07-17 20:15:45 -04:00
|
|
|
import { Routes, Route } from "react-router-dom";
|
2024-07-19 10:40:40 -07:00
|
|
|
import "react-toastify/dist/ReactToastify.css";
|
|
|
|
|
import { ToastContainer } from "react-toastify";
|
2024-05-22 19:09:13 +03:30
|
|
|
// import "./App.css";
|
2024-05-22 17:46:58 +03:30
|
|
|
import NotFound from "./Pages/NotFound";
|
2024-07-17 20:15:45 -04:00
|
|
|
import Login from "./Pages/Auth/Login";
|
2024-07-19 10:05:18 -07:00
|
|
|
import Register from "./Pages/Auth/Register/Register";
|
2024-05-22 17:46:58 +03:30
|
|
|
import HomeLayout from "./Layouts/HomeLayout";
|
2024-06-27 19:19:36 -04:00
|
|
|
import Account from "./Pages/Account";
|
2024-08-27 15:18:18 -07:00
|
|
|
import Monitors from "./Pages/Monitors/Home";
|
2024-07-17 20:15:45 -04:00
|
|
|
import CreateMonitor from "./Pages/Monitors/CreateMonitor";
|
2024-05-22 17:14:34 -04:00
|
|
|
import Incidents from "./Pages/Incidents";
|
|
|
|
|
import Status from "./Pages/Status";
|
|
|
|
|
import Integrations from "./Pages/Integrations";
|
|
|
|
|
import Settings from "./Pages/Settings";
|
2024-07-17 20:15:45 -04:00
|
|
|
import ForgotPassword from "./Pages/Auth/ForgotPassword";
|
|
|
|
|
import CheckEmail from "./Pages/Auth/CheckEmail";
|
|
|
|
|
import SetNewPassword from "./Pages/Auth/SetNewPassword";
|
|
|
|
|
import NewPasswordConfirmed from "./Pages/Auth/NewPasswordConfirmed";
|
2024-06-24 11:56:25 -07:00
|
|
|
import ProtectedRoute from "./Components/ProtectedRoute";
|
2024-07-17 20:15:45 -04:00
|
|
|
import Details from "./Pages/Monitors/Details";
|
2024-09-27 10:55:37 +08:00
|
|
|
import AdvancedSettings from "./Pages/AdvancedSettings";
|
2024-07-07 22:02:08 -04:00
|
|
|
import Maintenance from "./Pages/Maintenance";
|
2024-07-19 10:40:40 -07:00
|
|
|
import withAdminCheck from "./HOC/withAdminCheck";
|
2024-08-27 12:54:44 -07:00
|
|
|
import withAdminProp from "./HOC/withAdminProp";
|
2024-07-19 14:35:11 -04:00
|
|
|
import Configure from "./Pages/Monitors/Configure";
|
2024-07-28 16:51:47 -04:00
|
|
|
import PageSpeed from "./Pages/PageSpeed";
|
|
|
|
|
import CreatePageSpeed from "./Pages/PageSpeed/CreatePageSpeed";
|
2024-10-03 09:12:59 +08:00
|
|
|
import CreateNewMaintenanceWindow from "./Pages/Maintenance/CreateMaintenance";
|
2024-08-02 17:47:22 -04:00
|
|
|
import PageSpeedDetails from "./Pages/PageSpeed/Details";
|
2024-08-08 15:41:15 -04:00
|
|
|
import PageSpeedConfigure from "./Pages/PageSpeed/Configure";
|
2024-08-28 22:14:55 -04:00
|
|
|
import { ThemeProvider } from "@emotion/react";
|
2024-08-29 17:14:17 -04:00
|
|
|
import lightTheme from "./Utils/Theme/lightTheme";
|
|
|
|
|
import darkTheme from "./Utils/Theme/darkTheme";
|
2024-08-28 22:14:55 -04:00
|
|
|
import { useSelector } from "react-redux";
|
2024-09-06 16:32:38 -04:00
|
|
|
import { CssBaseline } from "@mui/material";
|
2024-09-27 10:55:37 +08:00
|
|
|
import { useEffect } from "react";
|
|
|
|
|
import { useDispatch } from "react-redux";
|
|
|
|
|
import { getAppSettings } from "./Features/Settings/settingsSlice";
|
2024-09-27 12:13:39 +08:00
|
|
|
import { logger } from "./Utils/Logger"; // Import the logger
|
|
|
|
|
import { networkService } from "./main";
|
2024-05-03 12:29:37 -04:00
|
|
|
function App() {
|
2024-07-19 10:40:40 -07:00
|
|
|
const AdminCheckedRegister = withAdminCheck(Register);
|
2024-08-27 12:54:44 -07:00
|
|
|
const MonitorsWithAdminProp = withAdminProp(Monitors);
|
2024-09-25 10:09:56 +08:00
|
|
|
const MonitorDetailsWithAdminProp = withAdminProp(Details);
|
2024-08-27 15:26:16 -07:00
|
|
|
const PageSpeedWithAdminProp = withAdminProp(PageSpeed);
|
2024-09-25 10:09:56 +08:00
|
|
|
const PageSpeedDetailsWithAdminProp = withAdminProp(PageSpeedDetails);
|
2024-10-03 09:12:59 +08:00
|
|
|
const MaintenanceWithAdminProp = withAdminProp(Maintenance);
|
2024-08-30 10:09:38 -07:00
|
|
|
const SettingsWithAdminProp = withAdminProp(Settings);
|
2024-09-27 10:55:37 +08:00
|
|
|
const AdvancedSettingsWithAdminProp = withAdminProp(AdvancedSettings);
|
2024-08-29 02:19:19 -04:00
|
|
|
const mode = useSelector((state) => state.ui.mode);
|
2024-09-27 10:55:37 +08:00
|
|
|
const { authToken } = useSelector((state) => state.auth);
|
|
|
|
|
const dispatch = useDispatch();
|
|
|
|
|
|
|
|
|
|
useEffect(() => {
|
2024-09-30 11:30:52 +08:00
|
|
|
if (authToken) {
|
|
|
|
|
dispatch(getAppSettings({ authToken }));
|
|
|
|
|
}
|
2024-09-27 10:55:37 +08:00
|
|
|
}, [dispatch, authToken]);
|
2024-08-28 22:14:55 -04:00
|
|
|
|
2024-09-27 12:13:39 +08:00
|
|
|
// Cleanup
|
|
|
|
|
useEffect(() => {
|
|
|
|
|
return () => {
|
|
|
|
|
logger.cleanup();
|
|
|
|
|
networkService.cleanup();
|
|
|
|
|
};
|
|
|
|
|
}, []);
|
|
|
|
|
|
2024-05-03 12:29:37 -04:00
|
|
|
return (
|
2024-08-29 17:14:17 -04:00
|
|
|
<ThemeProvider theme={mode === "light" ? lightTheme : darkTheme}>
|
2024-09-06 16:32:38 -04:00
|
|
|
<CssBaseline />
|
2024-05-22 17:46:58 +03:30
|
|
|
<Routes>
|
2024-10-08 12:01:19 -04:00
|
|
|
<Route
|
|
|
|
|
exact
|
|
|
|
|
path="/"
|
|
|
|
|
element={<HomeLayout />}
|
|
|
|
|
>
|
2024-06-24 13:27:38 -07:00
|
|
|
<Route
|
|
|
|
|
exact
|
|
|
|
|
path="/"
|
2024-08-27 12:54:44 -07:00
|
|
|
element={<ProtectedRoute Component={MonitorsWithAdminProp} />}
|
2024-06-24 13:27:38 -07:00
|
|
|
/>
|
2024-06-24 11:56:25 -07:00
|
|
|
<Route
|
|
|
|
|
path="/monitors"
|
2024-08-27 12:54:44 -07:00
|
|
|
element={<ProtectedRoute Component={MonitorsWithAdminProp} />}
|
2024-06-24 11:56:25 -07:00
|
|
|
/>
|
2024-06-25 14:36:20 -07:00
|
|
|
<Route
|
2024-08-23 00:28:21 +05:30
|
|
|
path="/monitors/create/:monitorId?"
|
2024-07-17 20:15:45 -04:00
|
|
|
element={<ProtectedRoute Component={CreateMonitor} />}
|
2024-06-25 14:36:20 -07:00
|
|
|
/>
|
2024-06-24 13:03:42 -07:00
|
|
|
<Route
|
2024-07-10 09:59:48 -07:00
|
|
|
path="/monitors/:monitorId/"
|
2024-09-25 10:09:56 +08:00
|
|
|
element={<ProtectedRoute Component={MonitorDetailsWithAdminProp} />}
|
2024-06-24 13:03:42 -07:00
|
|
|
/>
|
2024-07-19 14:35:11 -04:00
|
|
|
<Route
|
|
|
|
|
path="/monitors/configure/:monitorId/"
|
|
|
|
|
element={<ProtectedRoute Component={Configure} />}
|
|
|
|
|
/>
|
2024-07-03 20:07:45 -07:00
|
|
|
<Route
|
2024-09-13 11:23:03 +08:00
|
|
|
path="incidents/:monitorId?"
|
2024-07-10 09:59:48 -07:00
|
|
|
element={<ProtectedRoute Component={Incidents} />}
|
2024-07-03 20:07:45 -07:00
|
|
|
/>
|
2024-07-10 09:59:48 -07:00
|
|
|
|
2024-06-24 13:03:42 -07:00
|
|
|
<Route
|
|
|
|
|
path="status"
|
|
|
|
|
element={<ProtectedRoute Component={Status} />}
|
|
|
|
|
/>
|
|
|
|
|
<Route
|
|
|
|
|
path="integrations"
|
|
|
|
|
element={<ProtectedRoute Component={Integrations} />}
|
|
|
|
|
/>
|
2024-07-07 22:02:08 -04:00
|
|
|
<Route
|
|
|
|
|
path="maintenance"
|
2024-08-28 10:28:02 -04:00
|
|
|
element={<ProtectedRoute Component={MaintenanceWithAdminProp} />}
|
2024-07-07 22:02:08 -04:00
|
|
|
/>
|
2024-08-03 09:40:08 +03:30
|
|
|
<Route
|
2024-10-09 12:06:01 +08:00
|
|
|
path="/maintenance/create/:maintenanceWindowId?"
|
2024-08-03 09:40:08 +03:30
|
|
|
element={<CreateNewMaintenanceWindow />}
|
|
|
|
|
/>
|
2024-06-24 13:03:42 -07:00
|
|
|
<Route
|
|
|
|
|
path="settings"
|
2024-08-30 10:09:38 -07:00
|
|
|
element={<ProtectedRoute Component={SettingsWithAdminProp} />}
|
2024-06-24 13:03:42 -07:00
|
|
|
/>
|
2024-09-27 10:55:37 +08:00
|
|
|
<Route
|
|
|
|
|
path="advanced-settings"
|
2024-10-08 12:01:19 -04:00
|
|
|
element={<ProtectedRoute Component={AdvancedSettingsWithAdminProp} />}
|
2024-09-27 10:55:37 +08:00
|
|
|
/>
|
2024-06-27 19:19:36 -04:00
|
|
|
<Route
|
|
|
|
|
path="account/profile"
|
2024-10-08 12:01:19 -04:00
|
|
|
element={
|
|
|
|
|
<ProtectedRoute
|
|
|
|
|
Component={Account}
|
|
|
|
|
open="profile"
|
|
|
|
|
/>
|
|
|
|
|
}
|
2024-06-27 19:19:36 -04:00
|
|
|
/>
|
|
|
|
|
<Route
|
|
|
|
|
path="account/password"
|
2024-10-08 12:01:19 -04:00
|
|
|
element={
|
|
|
|
|
<ProtectedRoute
|
|
|
|
|
Component={Account}
|
|
|
|
|
open="password"
|
|
|
|
|
/>
|
|
|
|
|
}
|
2024-06-27 19:19:36 -04:00
|
|
|
/>
|
|
|
|
|
<Route
|
|
|
|
|
path="account/team"
|
2024-10-08 12:01:19 -04:00
|
|
|
element={
|
|
|
|
|
<ProtectedRoute
|
|
|
|
|
Component={Account}
|
|
|
|
|
open="team"
|
|
|
|
|
/>
|
|
|
|
|
}
|
2024-06-27 19:19:36 -04:00
|
|
|
/>
|
2024-07-28 16:51:47 -04:00
|
|
|
<Route
|
2024-08-02 18:08:36 -04:00
|
|
|
path="pagespeed"
|
2024-08-27 15:26:16 -07:00
|
|
|
element={<ProtectedRoute Component={PageSpeedWithAdminProp} />}
|
2024-07-28 16:51:47 -04:00
|
|
|
/>
|
|
|
|
|
<Route
|
2024-08-02 18:08:36 -04:00
|
|
|
path="pagespeed/create"
|
2024-07-28 16:51:47 -04:00
|
|
|
element={<ProtectedRoute Component={CreatePageSpeed} />}
|
|
|
|
|
/>
|
2024-08-02 17:47:22 -04:00
|
|
|
<Route
|
2024-08-02 18:17:52 -04:00
|
|
|
path="pagespeed/:monitorId"
|
2024-10-08 12:01:19 -04:00
|
|
|
element={<ProtectedRoute Component={PageSpeedDetailsWithAdminProp} />}
|
2024-08-02 17:47:22 -04:00
|
|
|
/>
|
2024-08-08 15:41:15 -04:00
|
|
|
<Route
|
|
|
|
|
path="pagespeed/configure/:monitorId"
|
|
|
|
|
element={<ProtectedRoute Component={PageSpeedConfigure} />}
|
|
|
|
|
/>
|
2024-05-22 17:14:34 -04:00
|
|
|
</Route>
|
2024-06-24 13:27:38 -07:00
|
|
|
|
2024-10-08 12:01:19 -04:00
|
|
|
<Route
|
|
|
|
|
exact
|
|
|
|
|
path="/login"
|
|
|
|
|
element={<Login />}
|
|
|
|
|
/>
|
2024-07-19 10:40:40 -07:00
|
|
|
|
2024-10-08 12:01:19 -04:00
|
|
|
<Route
|
|
|
|
|
exact
|
|
|
|
|
path="/register"
|
|
|
|
|
element={<AdminCheckedRegister />}
|
|
|
|
|
/>
|
|
|
|
|
<Route
|
|
|
|
|
exact
|
|
|
|
|
path="/register/:token"
|
|
|
|
|
element={<Register />}
|
|
|
|
|
/>
|
2024-06-21 15:11:54 -07:00
|
|
|
{/* <Route path="/toast" element={<ToastComponent />} /> */}
|
2024-10-08 12:01:19 -04:00
|
|
|
<Route
|
|
|
|
|
path="*"
|
|
|
|
|
element={<NotFound />}
|
|
|
|
|
/>
|
|
|
|
|
<Route
|
|
|
|
|
path="/forgot-password"
|
|
|
|
|
element={<ForgotPassword />}
|
|
|
|
|
/>
|
|
|
|
|
<Route
|
|
|
|
|
path="/check-email"
|
|
|
|
|
element={<CheckEmail />}
|
|
|
|
|
/>
|
|
|
|
|
<Route
|
|
|
|
|
path="/set-new-password/:token"
|
|
|
|
|
element={<SetNewPassword />}
|
|
|
|
|
/>
|
2024-05-30 11:08:50 +03:30
|
|
|
<Route
|
|
|
|
|
path="/new-password-confirmed"
|
|
|
|
|
element={<NewPasswordConfirmed />}
|
|
|
|
|
/>
|
2024-05-22 17:46:58 +03:30
|
|
|
</Routes>
|
2024-07-12 14:00:16 -04:00
|
|
|
<ToastContainer />
|
2024-08-28 22:14:55 -04:00
|
|
|
</ThemeProvider>
|
2024-05-11 22:48:09 +03:30
|
|
|
);
|
2024-05-03 12:29:37 -04:00
|
|
|
}
|
|
|
|
|
|
2024-05-11 22:48:09 +03:30
|
|
|
export default App;
|