import { Navigate } from 'react-router-dom'
import { useAuth } from '../context/AuthContext'

/** Nur Super-Admins; andere Nutzer → Startseite. */
export default function PlatformAdminRoute({ children }) {
  const { user } = useAuth()
  const ok = user?.role === 'superadmin'
  if (!ok) return <Navigate to="/" replace />
  return children
}
