aboutsummaryrefslogblamecommitdiffstats
path: root/panel/src/components/PrivateRoute.jsx
blob: 341625e431e1c083eab05485b055f2356d9d7303 (plain) (tree)
1
2
3
4
5
6
7
8
9
10
11


                                                    
 

                                    
 



                                                                   



                                                             
import React from 'react';
import { Navigate, Outlet } from 'react-router-dom';
import { useAuth } from '../contexts/AuthContext';

const PrivateRoute = () => {
  const { currentUser } = useAuth();

  if (currentUser === undefined) {
    return <div>Loading...</div>; // Or a spinner/loading component
  }

  return currentUser ? <Outlet /> : <Navigate to="/login" />;
};

export default PrivateRoute;