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

// Gates access to authenticated pages. This checks for a valid
// session token in localStorage; the token itself is verified
// server-side whenever a protected action (block IP, verdict) is sent.
export default function ProtectedRoute({ children }) {
  const token = localStorage.getItem('idps_token')
  if (!token) {
    return <Navigate to="/login" replace />
  }
  return children
}
