import React from 'react'; import { Navigate, Outlet } from 'react-router-dom'; import useAuthStore from '../../store/authStore'; const ProtectedRoute = () => { // Grab the state directly from your Zustand store const { isAuthenticated, isLoading } = useAuthStore(); // 1. App is currently pinging Django to verify the HttpOnly cookie if (isLoading) { return (

Loading Secure Environment...

); } // 2. The check failed (no cookie or expired cookie) if (!isAuthenticated) { return ; } // 3. The check passed! Render the layout shell and the protected children return ; }; export default ProtectedRoute;