2025-07-31 14:39:35 -07:00
|
|
|
import 'leaflet/dist/leaflet.css';
|
2026-07-08 15:05:50 -07:00
|
|
|
import { useEffect } from 'react';
|
2026-06-05 12:51:18 -07:00
|
|
|
import { Routes, Route, Navigate, Outlet } from 'react-router-dom';
|
2026-06-08 15:57:40 -07:00
|
|
|
import { useRecipe, Grid, GridItem, useDialog, Flex, Heading } from "@chakra-ui/react";
|
2026-07-08 15:05:50 -07:00
|
|
|
|
|
|
|
|
// --- NEW AUTH IMPORTS ---
|
|
|
|
|
import useAuthStore from './store/authStore';
|
|
|
|
|
import ProtectedRoute from './components/layout/ProtectedRoute.jsx';
|
|
|
|
|
|
|
|
|
|
// Pages & Components
|
2026-06-10 14:00:37 -07:00
|
|
|
import Login from "@/pages/auth/Login.jsx";
|
|
|
|
|
import Sidebar from "./components/layout/Sidebar.jsx";
|
|
|
|
|
import DialogPopup from "@/components/dashboard/DialogPopup.jsx";
|
|
|
|
|
import Header from "@/components/layout/Header.jsx";
|
|
|
|
|
import Home from "./pages/home/Home.jsx";
|
|
|
|
|
import RegionalMap from "./pages/maps/RegionalMap.jsx";
|
|
|
|
|
import Volcano from "@/pages/volcano/Volcano.jsx";
|
|
|
|
|
import GlobalMap from "./pages/maps/GlobalMap.jsx";
|
|
|
|
|
import Admin from "./pages/admin/Admin.jsx";
|
|
|
|
|
import MyDashboard from "./pages/home/tabs/MyDashboard.jsx";
|
2026-09-01 09:47:54 -07:00
|
|
|
import Settings from "./pages/auth/Settings.jsx";
|
2025-07-31 14:39:35 -07:00
|
|
|
|
2026-06-05 12:51:18 -07:00
|
|
|
function AppFoundation() {
|
2026-06-04 15:30:01 -07:00
|
|
|
const recipe = useRecipe({ key: "dashboard" });
|
|
|
|
|
const styles = recipe();
|
|
|
|
|
const dialog = useDialog();
|
|
|
|
|
|
|
|
|
|
return (
|
|
|
|
|
<>
|
|
|
|
|
<DialogPopup dialog={dialog} />
|
|
|
|
|
<Grid css={styles}
|
|
|
|
|
templateRows="1fr 11fr"
|
|
|
|
|
templateColumns="auto 1fr"
|
|
|
|
|
height="100vh"
|
|
|
|
|
width="100vw"
|
|
|
|
|
>
|
|
|
|
|
<GridItem rowSpan={1} colSpan={2}>
|
|
|
|
|
<Header />
|
|
|
|
|
</GridItem>
|
|
|
|
|
<GridItem colSpan={1}>
|
|
|
|
|
<Sidebar />
|
|
|
|
|
</GridItem>
|
|
|
|
|
<GridItem colSpan={1} width="100%" overflow="auto">
|
2026-06-05 12:51:18 -07:00
|
|
|
<Outlet />
|
2026-06-04 15:30:01 -07:00
|
|
|
</GridItem>
|
|
|
|
|
</Grid>
|
|
|
|
|
</>
|
|
|
|
|
)
|
|
|
|
|
}
|
|
|
|
|
|
2026-06-08 15:57:40 -07:00
|
|
|
const Placeholder = ({ name }) => (
|
2026-07-22 09:40:41 -07:00
|
|
|
<Flex width="100%" height="100%" align="center" justify="center">
|
|
|
|
|
<Heading color="gray.500" _dark={{ color: "gray.200" }} size="lg">{name} Dashboard - Coming Soon</Heading>
|
2026-06-08 15:57:40 -07:00
|
|
|
</Flex>
|
|
|
|
|
);
|
2026-07-08 15:05:50 -07:00
|
|
|
|
2025-07-08 11:16:51 -07:00
|
|
|
function App() {
|
2026-07-08 15:05:50 -07:00
|
|
|
// 1. Pull the initialization function from Zustand
|
|
|
|
|
const checkAuth = useAuthStore((state) => state.checkAuth);
|
|
|
|
|
|
|
|
|
|
// 2. Ping Django to verify the HttpOnly cookie the moment the app boots
|
|
|
|
|
useEffect(() => {
|
|
|
|
|
checkAuth();
|
|
|
|
|
}, [checkAuth]);
|
|
|
|
|
|
2026-06-05 11:04:17 -07:00
|
|
|
return (
|
|
|
|
|
<Routes>
|
2026-07-08 15:05:50 -07:00
|
|
|
{/* --- Public Routes --- */}
|
2026-06-05 11:04:17 -07:00
|
|
|
<Route path="/login" element={<Login />} />
|
|
|
|
|
|
2026-07-08 15:05:50 -07:00
|
|
|
{/* --- SECURE ROUTES --- */}
|
|
|
|
|
<Route element={<ProtectedRoute />}>
|
2026-06-08 15:57:40 -07:00
|
|
|
|
2026-07-08 15:05:50 -07:00
|
|
|
{/* --- Non-Public Routes (Now completely locked down) --- */}
|
|
|
|
|
<Route element={<AppFoundation />}>
|
|
|
|
|
|
|
|
|
|
<Route path="/home" element={<Home />}>
|
|
|
|
|
<Route index element={<MyDashboard />} />
|
2026-07-22 09:40:41 -07:00
|
|
|
<Route path="gas" element={<Placeholder name="Gas" />} />
|
2026-07-08 15:05:50 -07:00
|
|
|
<Route path="seismic" element={<Placeholder name="Seismic" />} />
|
|
|
|
|
<Route path="remote" element={<Placeholder name="Remote Sensing" />} />
|
|
|
|
|
<Route path="daily" element={<Placeholder name="Daily Activity" />} />
|
|
|
|
|
</Route>
|
|
|
|
|
|
2026-09-01 09:47:54 -07:00
|
|
|
<Route path="/settings" element={<Settings />} />
|
|
|
|
|
|
2026-07-08 15:05:50 -07:00
|
|
|
<Route path="/global-map" element={<GlobalMap />} />
|
|
|
|
|
<Route path="/regional-map" element={<RegionalMap />} />
|
|
|
|
|
<Route path="/volcano" element={<Volcano />} />
|
|
|
|
|
<Route path="/admin" element={<Admin />} />
|
2026-06-08 15:57:40 -07:00
|
|
|
</Route>
|
|
|
|
|
|
2026-06-05 11:04:17 -07:00
|
|
|
</Route>
|
|
|
|
|
|
2026-07-08 15:05:50 -07:00
|
|
|
{/* --- Redirect Routes --- */}
|
2026-06-05 11:04:17 -07:00
|
|
|
<Route path="/" element={<Navigate to="/home" replace />} />
|
2026-07-08 15:05:50 -07:00
|
|
|
</Routes>
|
|
|
|
|
);
|
2025-07-08 11:16:51 -07:00
|
|
|
}
|
|
|
|
|
|
2026-07-08 15:05:50 -07:00
|
|
|
export default App;
|