/** * Protected Route Component */ import React from 'react' import { Navigate } from 'react-router-dom' import { useAuth } from '../context/AuthContext' export const ProtectedRoute = ({ children, adminOnly = false }) => { const { user, loading } = useAuth() if (loading) { return (
) } if (!user) { return } if (adminOnly && !user.is_admin) { return } return children }