Files
Checkmate/Client/src/App.jsx
T

108 lines
3.6 KiB
React
Raw Normal View History

2024-05-22 17:46:58 +03:30
import { Routes, Route } from "react-router-dom";
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-05-14 11:06:34 +03:30
import Login from "./Pages/Login";
2024-05-22 17:46:58 +03:30
import Register from "./Pages/Register";
import HomeLayout from "./Layouts/HomeLayout";
import Demo from "./Pages/Demo/Demo";
import PlayGround from "./Pages/PlayGround/PlayGround";
2024-06-27 19:19:36 -04:00
import Account from "./Pages/Account";
2024-05-28 21:28:15 +03:30
import Monitors from "./Pages/Monitors";
import CreateNewMonitor from "./Pages/CreateNewMonitor";
import Incidents from "./Pages/Incidents";
import Status from "./Pages/Status";
import Integrations from "./Pages/Integrations";
import Settings from "./Pages/Settings";
2024-05-28 21:28:15 +03:30
import ForgotPassword from "./Pages/ForgotPassword";
2024-05-29 11:08:59 +03:30
import CheckEmail from "./Pages/CheckEmail";
2024-05-29 22:11:16 +03:30
import SetNewPassword from "./Pages/SetNewPassword";
import NewPasswordConfirmed from "./Pages/NewPasswordConfirmed";
import ToastComponent from "./Components/Toast";
2024-06-24 11:56:25 -07:00
import ProtectedRoute from "./Components/ProtectedRoute";
2024-07-02 10:50:18 -07:00
import { useState, useEffect } from "react";
2024-07-02 11:14:12 -07:00
import axios from "axios";
2024-05-14 11:06:34 +03:30
function App() {
2024-07-02 11:14:12 -07:00
const BASE_URL = import.meta.env.VITE_APP_API_BASE_URL;
2024-07-02 10:50:18 -07:00
const [adminExists, setAdminExists] = useState(false); // Assuming admin exists by default
2024-07-02 11:14:12 -07:00
useEffect(() => {
const checkAdminExists = async () => {
try {
// Replace this URL with your actual API endpoint
const response = await axios.get(`${BASE_URL}/auth/users/admin`);
console.log(response);
} catch (error) {
console.error("Failed to check admin existence:", error);
}
};
checkAdminExists();
}, []);
return (
<>
2024-05-22 17:46:58 +03:30
<Routes>
2024-05-28 21:28:15 +03:30
<Route exact path="/" element={<HomeLayout />}>
<Route
exact
path="/"
element={<ProtectedRoute Component={Monitors} />}
/>
2024-06-24 11:56:25 -07:00
<Route
path="/monitors"
element={<ProtectedRoute Component={Monitors} />}
/>
<Route
path="/monitors/create"
element={<ProtectedRoute Component={CreateNewMonitor} />}
/>
<Route
path="incidents"
element={<ProtectedRoute Component={Incidents} />}
/>
<Route
path="status"
element={<ProtectedRoute Component={Status} />}
/>
<Route
path="integrations"
element={<ProtectedRoute Component={Integrations} />}
/>
<Route
path="settings"
element={<ProtectedRoute Component={Settings} />}
/>
2024-06-27 19:19:36 -04:00
<Route
path="account/profile"
element={<ProtectedRoute Component={Account} open="profile" />}
/>
<Route
path="account/password"
element={<ProtectedRoute Component={Account} open="password" />}
/>
<Route
path="account/team"
element={<ProtectedRoute Component={Account} open="team" />}
/>
</Route>
<Route exact path="/login" element={<Login />} />
<Route exact path="/register" element={<Register />} />
2024-05-14 11:06:34 +03:30
<Route exact path="/demo" element={<Demo />} />
{/* <Route path="/toast" element={<ToastComponent />} /> */}
2024-05-14 11:06:34 +03:30
<Route path="*" element={<NotFound />} />
2024-05-20 09:53:02 +03:30
<Route path="/playground" element={<PlayGround />} />
2024-05-28 21:28:15 +03:30
<Route path="/forgot-password" element={<ForgotPassword />} />
2024-05-29 11:08:59 +03:30
<Route path="/check-email" element={<CheckEmail />} />
<Route path="/set-new-password/:token" element={<SetNewPassword />} />
<Route
path="/new-password-confirmed"
element={<NewPasswordConfirmed />}
/>
2024-05-22 17:46:58 +03:30
</Routes>
</>
2024-05-11 22:48:09 +03:30
);
}
2024-05-11 22:48:09 +03:30
export default App;