import 'leaflet/dist/leaflet.css'; import { useEffect } from 'react'; import { Routes, Route, Navigate, Outlet } from 'react-router-dom'; import { useRecipe, Grid, GridItem, useDialog, Flex, Heading } from "@chakra-ui/react"; // --- NEW AUTH IMPORTS --- import useAuthStore from './store/authStore'; import ProtectedRoute from './components/layout/ProtectedRoute.jsx'; // Pages & Components 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"; function AppFoundation() { const recipe = useRecipe({ key: "dashboard" }); const styles = recipe(); const dialog = useDialog(); return ( <>
) } const Placeholder = ({ name }) => ( {name} Dashboard - Coming Soon ); function App() { // 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]); return ( {/* --- Public Routes --- */} } /> {/* --- SECURE ROUTES --- */} }> {/* --- Non-Public Routes (Now completely locked down) --- */} }> }> } /> } /> } /> } /> } /> } /> } /> } /> } /> {/* --- Redirect Routes --- */} } /> ); } export default App;