import React from 'react';
import { Navigate } from 'react-router-dom';

const Protected = ({ children }) => {
    const isAuthenticated = localStorage.getItem('token');
    
    if (!isAuthenticated) {
        // Blocks direct URL manual entry access attempts to paths like /dashboard
        return <Navigate to="/login" replace />;
    }
    return children;
};

export default Protected;